Hi all,
Hopefully someone knowledgeable with be able to help me with this.

I've modified the baseapi example from here:
https://github.com/tesseract-ocr/tesseract/wiki/APIExample

#include "stdafx.h"#include <baseapi.h>#include <allheaders.h>
 using namespace tesseract;
 int main(){
        char *outText;
 
        TessBaseAPI *api = new TessBaseAPI();
 
        // Initialize tesseract-ocr with English, without specifying tessdata 
path
        if (api->Init(NULL, "eng")) {
                fprintf(stderr, "Could not initialize tesseract.\n");
                exit(1);
        }
 
        // Open input image with leptonica library
        Pix *image = pixRead("E:\\visual studio 
2015\\Projects\\TEST_TESS\\Debug\\paving.png");
        api->SetImage(image);
        // Get OCR result
 
        api->SetRectangle(161, 244, 271, 35);//this rectangle corresponds to 
the text: "FOR A FREE ESTIMATE CALL"
 
        outText = api->GetUTF8Text();
        printf("OCR output:\n%s", outText);
 
        // Destroy used object and release memory
        api->End();
        delete[] outText;
        pixDestroy(&image);
 
        return 0;}


I've added the line to SetRectangle method call, and I've specified an 
image I've obtained from a random google search
with plenty of text throughout.

<https://lh3.googleusercontent.com/-ZSo0qm99x9g/WNg9_8JRXHI/AAAAAAAAAJM/RF3v-NsDlKwa7HTamoWtUPW2avuS-5ZFQCLcB/s1600/16095018aa_f.jpg>

I've converted this to a png because I was getting the following warning:
"Warning. Invalid resolution 0 dpi. Using 70 instead."

I call SetRectangle with the pixel coordinates for: "FOR A FREE ESTIMATE 
CALL":

api->SetRectangle(161, 244, 271, 35);


Unfortunately, that's not text that is returned by GETUTF8Text(), instead I 
get: | After Hrs 647-9709 -- Saint

The width appears correct, but the left coordinate corresponding to the 
returned text is around 0, and the top is around 345.
What's the issue here?

Thanks.

-- 
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 tesseract-ocr+unsubscr...@googlegroups.com.
To post to this group, send email to tesseract-ocr@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/5d59a845-2410-4fe4-a8a3-ccbb5cd3ec5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to