So if you have: IplImage *img;
load your image in img, delete this line: cv::Mat image = cv::imread(file_path , 0); and replace with: cv::Mat image(img); And remember: - you will have to deallocate (release) img by your own, because in this case cv::Mat won't do that for you. - image has to be 8 bpp. 2012/11/2 shari <[email protected]> > what if my image is IPlmage *img;then? > > how does the code modify? > > On Nov 2, 4:13 am, Andres <[email protected]> wrote: > > Here you have a snippet of that. If someone wants to put this in the > wiki, > > I could improve it a little (better comments, etc.). Just let me know. > > > > 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 herehttps:// > groups.google.com/forum/?fromgroups#!searchin/tesseract-ocr/p... > > 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); > > > > Cheers, > > > > Andres > > > > 2012/11/1 Phlip <[email protected]> > > > > > > > > > > > > > > > > > On Nov 1, 7:16 am, Andres <[email protected]> wrote: > > > > > > I'm not sure about what you really want, but if you need to pass an > > > OpenCV > > > > IplImage or a cv::Mat to Tesseract from inside a program I can give > you > > > the > > > > snippet. > > > > > To the OP, we are now talking about three levels of integration... > > > > > - shell to tesseract with system('tesseract.exe') > > > - plug a terresact DLL into your program (Andres's point) > > > - compile a C program with the tesseract source. > > > > > The OP seemed to be discussing the latter. I prefer the former > > > because, like Machiavelli, I prefer to exhaust persuasion first, and > > > only then use brute force. So far, everything I need is available from > > > a command line. Projects with different performance constraints might > > > need lower options on the list. > > > > > -- > > > Phlip > > > http://zeekland.zeroplayer.com/ > > > > > -- > > > 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 > -- 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

