here is what I am ABLE to do:
Use the CaptureAnImage function example from msdn in order to save an image from a window handle to my computer, then use tesseract with this code:
STRING text_out;
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
// Initialize tesseract-ocr with English, without specifying tessdata path
if (api->Init(NULL, "eng")) {
fprintf(stderr, "Could not initialize tesseract.\n");
exit(1);
}
Pix *image = pixRead("captureqwsx.bmp");
api->SetImage(image);
api->SetRectangle(830, 95, 85, 25);
text_out = api->GetUTF8Text();
printf("OCR output:\n%s", text_out.string());
In order to retrieve the text from the window handle specified. And it works. Problem is: I feel like saving an image to my computer is not only useless, but probably not really good for the performance of my application...
The solution I found is, use SetImage with it's second definition:
void SetImage(const unsigned char* imagedata, int width, int height,
int bytes_per_pixel, int bytes_per_line);
And here is how I hope you guys can help me... I have no idea how to retrieve the image data, bytes per pixel, and bytes per line of a window... I feel like the original CaptureAnImage function should be able to do that easily with just little bit of modifications, but I don't know how and my searches returned nothing good...