Character recognition in C++ Builder

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Character recognition in C++ Builder

Postby tnsloco » Sun Feb 07, 2010 5:57 pm

Hello everyone. I'm new here and I'm new in C++ Builder programming.
I have some problems: I'm trying to make an appplication that recognise some characters from a picture.
But, the problem is that I don't know how to do that.
I'm thinking about splitting the picture in small pictures, each containing a character and converting each picture to black and white and count the black pixels, then compare the number of the black pixels from my picture with the ones from a template picture.
Can you tell me please what function to use for converting one image in B&W and to copy a portion of a picture?
Or, if you have other suggestions, please tell my
Please excuse my poor english :(
tnsloco
 
Posts: 5
Joined: Sun Feb 07, 2010 5:45 pm

Re: Character recognition in C++ Builder

Postby arisme » Mon Feb 08, 2010 6:02 am

tnsloco wrote:I'm new here...

Welcome. We're always pleased to see new members.
tnsloco wrote:...and I'm new in C++ Builder programming.

What previous programming experience do you have? (Language and number of years?)
There are reasons for that question. Amongst them, having an idea of your level of skills and experience will enable us to pitch our responses more appropriately, and therefore more helpfully.

tnsloco wrote:I'm trying to make an appplication that recognise some characters from a picture.

OCR is a big field with many facets and considerations, and we will need to know considerably more about the exact nature of your project.

e.g. What kind of format is the picture file? Is it a scanned image, or a photograph? Are the characters you want to recognize printed or handwritten? Do they vary in size?

tnsloco wrote:I'm thinking about splitting the picture in small pictures, each containing a character and converting each picture to black and white and count the black pixels, then compare the number of the black pixels from my picture with the ones from a template picture.

That algorithm may or may not work, depending on other factors.

Or, if you have other suggestions, please tell my

Have you scanned the internet for OCR packages for C/C++ or C++Buillder? There are many commercial packages and some free ones, and some may have source code available.

Aris
arisme
BCBJ Master
BCBJ Master
 
Posts: 357
Joined: Thu Jun 07, 2007 9:35 pm
Location: UK

Re: Character recognition in C++ Builder

Postby tnsloco » Mon Feb 08, 2010 7:18 am

Thanks for your reply, Aris.
I need this for a project at the University, I'm a student. My project is about car number plates recognition.
I have a 4 years experience in Pascal, 3 years in Borland C (MSDOS version), some MATLAB experience.
I've looked for an SDK, but...I haven't found one yet...I need a free SDK, not commercial.
tnsloco
 
Posts: 5
Joined: Sun Feb 07, 2010 5:45 pm

Re: Character recognition in C++ Builder

Postby arisme » Mon Feb 08, 2010 9:09 am

tnsloco wrote:My project is about car number plates recognition.

That's a good narrow focus to start with.

The final output will obviously be correctly identified registration numbers, but where does the input begin? Does it start with CCTV snapshots of a street scene, or does it start with reasonable photos of number plates? In other words, does the project need a pre-OCR phase to identify and extract number plates from a street shot, and process them to present the OCR phase with a reasonably consistent set of images of alphanumeric characters?

tnsloco wrote:I have a 4 years experience in Pascal, 3 years in Borland C (MSDOS version), some MATLAB experience.

That's good - we do not have to teach you programming - just provide you with signposts in C++Builder.

Incidentally, in case you are not aware of it, C++Builder has a Pascal compiler built in, and you can add Delphi units to a C/C++ project.

Aris
arisme
BCBJ Master
BCBJ Master
 
Posts: 357
Joined: Thu Jun 07, 2007 9:35 pm
Location: UK

Re: Character recognition in C++ Builder

Postby tnsloco » Tue Feb 09, 2010 4:53 am

Let's say it's a perfect picture, in BMP format, with no noise involved.
I only need to recognise characters form a to z. I also have the font used and some template pictures with every character (a,b,c...).
I don't know Delphi.
tnsloco
 
Posts: 5
Joined: Sun Feb 07, 2010 5:45 pm

Re: Character recognition in C++ Builder

Postby tnsloco » Tue Feb 09, 2010 5:46 am

Another simple idea: localization of subimages containing characters in my image. But I don't know how to convert my picture in black and white and then into a matrix in C Builder
tnsloco
 
Posts: 5
Joined: Sun Feb 07, 2010 5:45 pm

Re: Character recognition in C++ Builder

Postby arisme » Tue Feb 09, 2010 7:58 am

To get you started -

Start a new VCL Forms project.
In the IDE, in Design Mode-

1. From the Tool Palette, drop a TImage component onto your Form.
2. Drop a TOpenDialog onto the form.
3. Drop a Button onto the form.
4. Double click on the Button. This wiil create an event handler function stub in your code.
5. Add the code below so it looks like this
Code: Select all
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   if(OpenDialog1->Execute())
      {
      Image1->Picture->LoadFromFile(OpenDialog1->FileName);
      }
}
//---------------------------------------------------------------------------

6. Compile and run the program.

When you click the button, a dialog will open, allowing you to browse to where your *.bmp files are located. Select the image you want, and open it.

You can access the graphic elements through the Picture property of TImage. The Bitmap is available with
Image1->Picture->Bitmap. Individual pixel colour values are accessible with Image1->Picture->Bitmap->Canvas->Pixels [X][Y].
When working with pixels, check out the Bitmap's Scanline property, which provides indexed access to rows of pixels, and is faster than individual pixel access.

There are a considerable number of properties and methods for you to explore - the online Help should provide most answers.

Have fun exploring.

Aris
arisme
BCBJ Master
BCBJ Master
 
Posts: 357
Joined: Thu Jun 07, 2007 9:35 pm
Location: UK

Re: Character recognition in C++ Builder

Postby tnsloco » Tue Feb 09, 2010 1:03 pm

Thanks, Aris.
I created a TBitmap object for my file.
I copied my image into a matrix and my templates into a separate matrix and...it works.
It's faster with a matrix, with Bitmap->Canvas->Pixels[i][j] it's very slow :(
Thanks again for your support!
tnsloco
 
Posts: 5
Joined: Sun Feb 07, 2010 5:45 pm

Re: Character recognition in C++ Builder

Postby arisme » Tue Feb 09, 2010 1:32 pm

tnsloco wrote:I created a TBitmap object for my file.
I copied my image into a matrix and my templates into a separate matrix and...it works.

Very good - you are obviously not quite such a newcomer to C++Builder as the first impressions gave.

Thanks for the update.

Aris
arisme
BCBJ Master
BCBJ Master
 
Posts: 357
Joined: Thu Jun 07, 2007 9:35 pm
Location: UK


Return to Technical

Who is online

Users browsing this forum: Google [Bot] and 2 guests