I now code the image as raw binary image and the error disappear.
However, the output is totally wrong. Strangely, if I directly call
"tesseract image.tif result -l eng" from command line, the result is
correct.
Here is my few lines of code:

tesseract::TessBaseAPI  api;
api.Init(NULL, "eng");
//construct raw image
api.SetImage(raw_image, raw_image_width, raw_image_height, 0,
char_per_line);
char* result = api.GetUTF8Text();

Any comments?

On Apr 14, 9:46 am, zl2k <[email protected]> wrote:
> I noticed it is in TessBaseAPI::Recognize
>
> int TessBaseAPI::Recognize(struct ETEXT_STRUCT* monitor) {
>   //...
>   if (thresholder_ == NULL || thresholder_->IsEmpty()) {
>     tprintf("Please call SetImage before attempting recognition.");
>     return -1;
>   }
> //...
>
> }
>
> My input image is coded binary, single char, how may I fix the
> thresholder problem? Thanks for help.
>
> zl2k
>
> On Apr 14, 9:20 am, zl2k <[email protected]> wrote:
>
>
>
>
>
>
>
> > I block the Recognize but still get the same error. Other comments?
>
> > On Apr 14, 5:23 am, Leonardo Gomes <[email protected]> wrote:
>
> > > I'm a newbie with Tesseract, but I know that api.GetUTF8Text() calls
> > > Recognize for you. Try removing the call to Recognize to see what happens.
>
> > > Cheers,
> > > Leo.
>
> > > On Thu, Apr 14, 2011 at 7:58 AM, zl2k <[email protected]> wrote:
> > > > hi, all
>
> > > > I have composed a Pix image and here are the 4 lines of code to
> > > > recognize the input image (I am using tesseract 3.00)
>
> > > > tesseract::TessBaseAPI api;
> > > > // construct pix_image
> > > > api.SetImage(pix_image);
> > > > api.SetRectangle(0, 0, pixGetWidth(pix_image),
> > > > pixGetHeight(pix_image));
> > > > api.Recognize(NULL);
> > > > std::string result = api.GetUTF8Text();
>
> > > > The code compiles fine but got the following runtime error:
> > > > 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
> > > > Aborted
>
> > > > Could you give me some hint on how to fix the problem? Thanks for
> > > > help.
>
> > > > zl2k
>
> > > > --
> > > > 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 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