Wenjing Jia
unread,Jun 26, 2008, 9:20:44 PM6/26/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to tesseract-ocr
I have been struggling with this odd problem for weeks and couldn't
find any clue at all. Wondering if anyone could give me a hint on why
this happens and especially how to fix it.
I've developed my own number-plate recognition program on MS VC by
using the Windows DLL interface for Tesseract, "tessdll.cpp",
specifically the API function "TessDllAPI::BeginPageUpright". In most
cases, the recognition are functioning very well (I have retrained the
tessdata and it has improved the recognition rate quite a lot).
However, occasionally, it outputs a single "~" result. When I look at
these trouble images, only find they are perfectly segmented binarised
images with nearly no noise.
Below are my codes. I am using OpenCV to open images:
IplImage* img = cvLoadImage(imagepath, 0) ; /// load image into
grayscale
if ( img==NULL )
return ;
api.BeginPageUpright(img->width , img->height , (unsigned char *)img-
>imageData, 8);
ETEXT_DESC *output = api.Recognize_all_Words();
char *buffer = NULL ;
buffer = new char [output->count] ;
if ( buffer == NULL )
return ;
for (int i = 0; i < output->count; ++i)
{
const EANYCODE_CHAR *ch = &output->text[i];
buffer[i] = ch->char_code ;
}
buffer[i] = '\0';
MessageBox( buffer, 0, MB_OK ) ;
To fix the problem, I have double-checked and confirmed the following
matters:
the first memory address of "imageData" is the top-left of the image;
"imageData" is a 8-bit per pixel data buffer and each pixel's value is
correct;
"img->width" is the width of line in bytes times 8.
characters are black and background are white.
To my frustration is that, all those "trouble images" are tested
perfectly well using the command line program "tesseract.exe" with my
newly trained "tessdata".
By the way, I've noticed that in the file "tessdll.cpp" under the
implementation
"TessDllAPI::BeginPageUpright(UINT32 xsize,UINT32 ysize,unsigned char
*buf, UINT8 bpp)",
there is a comment saying:
"//It looks like Adaptive thresholding is disabled so this must be a 1
bpp image".
Hence, I have also tried to convert the 8-bit per pixel "imageData"
into 1-bit per pixel data and called the function
"api.BeginPageUpright(img->width , img->height , data, 1);". Nothing
has changed significantly. There are still "~" outputs. :(
Feel very frustrated!
Your comments would be very much appreciated!