Hi everybody,
I'm new with tesseract and I have created a project to use it and recognize 
characters from a ethernet camera. The problem is when I execute the 
program an error like this:
*Please call SetImage before attempting recognition.Please call SetImage 
before attempting recognition.terminate called after throwing an instance 
of 'std::logic_error'
  what():  basic_string::_S_construct null not valid*

is returned. I' ve tried adding SetImage and the same error is given. 
Anybody knows what is the reason of that error? Any clue?

Thanks in advance.
I paste the code where I have the problem:

if (waitKey(10) >= 0){

                imwrite("/home/adrian/workspace/Snapshots/foto.jpg", image); 
//take 
snapshot when key is pressed
                 cont=cuenta;
                 cont=cont-1;

                 // read image
                      Mat imagen = imread("/home/adrian/workspace/foto.jpg"
);                

                // initilize tesseract OCR engine

                      putenv("TESSDATA_PREFIX=/usr/local/share/");
                      setlocale(LC_ALL, "C");
                    
                      tesseract::TessBaseAPI api;


                     if (api.Init(NULL, "eng")) {
                              fprintf( stderr, " Could not intialize 
tesseract!!!!\n" );
                              exit(1);
                     }
          api.SetImage(imagen.data, imagen.size().width,imagen.size().height
, imagen.channels(), imagen.step1());
                    

                    // set region of interest (ROI), i.e. regions that 
contain text
                      Rect text1ROI(162, 110, 157 , 129);

                    // recognize text
       api.TesseractRect( imagen.data, 1, imagen.step1(), text1ROI.x,text1ROI
.y, text1ROI.width, text1ROI.height);
                       const char *text1 = api.GetUTF8Text();

                    // remove "newline"
                       string t1(text1);
                       t1.erase( std::remove(t1.begin(), t1.end(), '\n'), t1
.end() );

                    // print found text
                       printf("text: \n");
                       printf( "%s",t1.c_str() );
                       printf("\n");

                       // draw text on original image
                           Mat scratch = imread(
"/home/adrian/workspace/OCR/foto.jpg");

                           int fontFace = FONT_HERSHEY_PLAIN;
                           double fontScale = 2;
                           int thickness = 2;

        putText(scratch, t1, Point(text1ROI.x, text1ROI.y), fontFace,fontScale
, Scalar(0, 255, 0), thickness, 8);
                           rectangle(scratch, text1ROI, Scalar(0, 0, 255), 2
, 8, 0);

                           imshow("tesseract-opencv", scratch);
            }


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

--- 
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to