--
You received this message because you are subscribed to the Google
Groups "tesseract-ocr" group.
To post to this group, send email to tesser...@googlegroups.com
To unsubscribe from this group, send email to
tesseract-oc...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/tesseract-ocr?hl=en
cv::Mat image = cv::imread(file_path , 0); // image should be 8 bpp, 1 channel std::string lang = "my_trained_file"; // file on disk is "my_trained_file.traineddata" tesseract::TessBaseAPI tess_api; tess_api.Init("./", lang.c_str(), tesseract::OEM_DEFAULT); tess_api.SetPageSegMode(static_cast<tesseract::PageSegMode>(7)); // using 7 here, see available modes in tesseractmain.cpp or here https://groups.google.com/forum/?fromgroups#!searchin/tesseract-ocr/psm/tesseract-ocr/JW7xKH_pH_U/0AYmLVsLqj8J tess_api.TesseractRect( image.data, 1, image.step1(), 0, 0, image.cols, image.rows); const char *txt = tess_api.GetUTF8Text(); char *boxes = tess_api.GetBoxText(0);
Nick
hey Nick,
U r right.I too understand by what is an apche license.
But the truth is that if i include "tesseractmain.h" in my opencv code it gives me an fatal error.what could be the reason?
hey all,
Thanks for actively participating in this discussion on how to integrate tesseract ocr with opencv library.
But the solution provided is not yet achieved as linking the two(tesseract ocr-opencv)has become a challenge.
And so,have attached a image which gives u a clear idea about what kind of input is
The numbers are only marked for your ease understanding which are nothing but the location of the text available.
Suppose its a input image where i have to read the contents within the box.
then how to code that.am not using any of the python tesseract library as in my case programming language used is c++.
It would be of great help if somebody comes up within the snippet to achieve this.
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
#include <opencv2/opencv.hpp>
int main() {
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();
if (api->Init("/usr/src/tesseract-ocr/", "eng")) {
fprintf(stderr, "Could not initialize tesseract.\n");
return 1;
}
IplImage *img = cvLoadImage("/home/user/sampleimage.png");
if ( img == 0 ) {
fprintf(stderr, "Cannot load input file!\n");
return 1;
}
api->SetImage((unsigned char*)img->imageData, img->width,
img->height, img->nChannels, img->widthStep);
// be aware of tesseract coord systems starting at left top corner!
api->SetRectangle(129, 184, 484, 108);
char* outText = api->GetUTF8Text();
printf("OCR output:\n\n");
printf(outText);
api->Clear();
api->End();
delete [] outText;
delete api;
cvReleaseImage(&img);
return 0;
}