After some hours I can answer my own question...
The imageData of IplImage is aligned 4 or 8 bytes in order to enhance
the processing speed. For example, let’s say you have a color image of
size 98-by-98 (pixel depth 8 bits) and imageData is aligned 4 bytes.
The size of each row will not be 98×3=294 bytes but 296 bytes. The
widthStep of IplImage shows the actual size of aligned image row in
bytes. This can help us access imageData correctly. Here is a code
that copy imageData to a user-created buffer.
// create a temp buffer
unsigned char *buffer,*temp2;
buffer = new unsigned char[plate->width*plate->height*plate-
>nChannels];
temp2 = buffer;
// pointer to imageData
unsigned char *temp1 = (unsigned char*) plate->imageData;
// copy imagedata to buffer row by row
for(int i=0;i<plate->height;i++)
{
memcpy(temp2, temp1, plate->width*plate->nChannels);
// imageData jump to next line
temp1 = temp1 + plate->widthStep;
// buffer jump to next line
temp2 = temp2+ plate->width*plate->nChannels;
}
TessDllAPI api("eng");
api.BeginPageUpright(plate->width, plate->height, buffer, 8);
ETEXT_DESC* output = api.Recognize_all_Words();
I hope it helps you.
A good answer returns a good result.
On 10 ago, 14:06, igm <[email protected]> wrote:
> Hello,
>
> I am trying to use an IplImage in the method BeginPageUpright but it
> always returns the same tilde '~' caracter and just only one.
>
> IplImage *plate = cvLoadImage(argv[1]);
> TessDllAPI api(argc > 3 ? argv[3] : "eng");
> api.BeginPageUpright(plate->width, plate->height, (unsigned
> char*)plate->imageData);
> ETEXT_DESC* output = api.Recognize_all_Words();
>
> I searched in the other discussions but and some people said that if
> you change the line 72 of the file docqual.cpp from "EXTERN BOOL_VAR
> (unlv_tilde_crunching, TRUE," to "EXTERN BOOL_VAR
> (unlv_tilde_crunching, FALSE," it should resolve the problem but not
> in my case. I have rebuild the solution and it returns the same fu..ng
> tilde. LOL.
>
> The code i am using is the same as the dlltest. I don't know what to
> say by this time. Can you help me?
>
> Thanks in advance.
>
> Regards.
--
You received this message because you are subscribed to the Google Groups
"tesseract-ocr" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tesseract-ocr?hl=en.