Looks like a simple case of Y inversion - try transforming whatever Y
values you thought were right into (height - Y) where height is the
height of the image.

On Jul 27, 1:28 am, Andres <[email protected]> wrote:
> Hello people,
>
> I'm trying to get the characters coordinates but I'm getting them misplaced.
>
> You can see the image and the rectangles with the coordinates 
> here:http://silvic.com.ar/rectangles.jpg
>
> I'm using some adapted code from dlltest, and my code uses OpenCV. I'm
> posting my code below.
>
> Basically, I'm getting the character coordinates from EANYCODE_CHAR.
>
> Any hint will be greatly appreciated.
>
> Regards,
>
> Andres
>
> #include "ocr.h"
>
> #define _UNICODE
>
> #include <imgs.h>
> #include <tessdll.h>
>
> #include <cv.h>
> #include <highgui.h>
>
> #include <iostream>
>
> using namespace std;
>
> #pragma message("hay que tener definido __MSW32__")
>
> void test()
> {
>     string file_path =
> "A:\\prj\\Patentes\\imgs_temp\\in\\solo_patente_0474.bmp";
>     string ret;
>
>     IMAGE image;
>     if (image.read_header(file_path.c_str()) < 0)
>     {
>         cerr<<"Can't open "<<file_path<<endl;
>         return;
>     }
>     if (image.read(image.get_ysize ()) < 0)
>     {
>         cerr<<"Can't read "<<file_path<<endl;
>         return;
>     }
>
>     string lang = "my_lang";
>
>     TessDllAPI api(lang.c_str());
>
>     api.BeginPageUpright(image.get_xsize(), image.get_ysize(),
> image.get_buffer(),
>                          image.get_bpp());
>
>     ETEXT_DESC* output = api.Recognize_all_Words();
>
>     IplImage *cv_image = cvLoadImage(file_path.c_str());
>
>     cvNamedWindow("read", CV_WINDOW_AUTOSIZE);
>
>     int j;
>     for (int i = 0; i < output->count; i = j)
>     {
>         const EANYCODE_CHAR* ch = &output->text[i];
>         unsigned char unistr[24];
>
>         for (j = i; j < output->count; j++)
>         {
>             const EANYCODE_CHAR* unich = &output->text[j];
>
>             if (ch->left != unich->left || ch->right != unich->right ||
>                 ch->top != unich->top || ch->bottom != unich->bottom)
>                 break;
>             unistr[j - i] = static_cast<unsigned char>(unich->char_code);
>         }
>         unistr[j - i] = '\0';
>
>         const char *txt = reinterpret_cast<const char*>(unistr);
>         ret += txt;
>
>         {
>
>             cvRectangle(cv_image, cvPoint(ch->left, ch->top),
> cvPoint(ch->right, ch->bottom), CV_RGB(255,0,0), 1);
>
>             cvShowImage("read", cv_image);
>             while(cvWaitKey(50)==-1);
>         }
>     }
>     cout<<"read ["<<ret<<"]"<<endl;
>
> }

-- 
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.

Reply via email to