Link to home
Start Free TrialLog in
Avatar of emna ouerteni
emna ouerteni

asked on

tesseract ocr + opencv+ visual studio 2010

i included opencv and tesseract ocr in visual studio
#include<opencv2\core\core.hpp>
#include<opencv2\highgui\highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include<baseapi.h>
#include<allheaders.h>
#include<iostream>
#include <vector>
#include <fstream>
#define _CRT_SECURE_NO_WARNINGS
using namespace cv;
using namespace std;
tesseract::TessBaseAPI ocr;

int main()
{
   Mat input = imread("C:\\eurotext.tif",1);
   cvtColor( input, input, CV_BGR2GRAY );

  ocr.Init(NULL, "eng", tesseract::OEM_TESSERACT_ONLY);
 
  ocr.SetPageSegMode(tesseract::PSM_SINGLE_BLOCK);
  ocr.SetImage(input.data, input.cols, input.rows, 1, input.step);
  char* text = ocr.GetUTF8Text();
  cout << "Text:" << endl;
  cout << text << endl;
  cout << "Confidence: " << ocr.MeanTextConf() << endl << endl;
  

}

Open in new window

the build was succeeded but when running

User generated image
and


User generated image
Avatar of ktaczala
ktaczala
Flag of United States of America image

Are you trying to write to file? I see you're reading tif from root of C Drive. Windows doesn't like it when you use root.
Try putting file in a temp folder and making sure full permissions to read/write.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.