Reading video and using tesseract

asked 2018-03-03 16:18:22 -0500

baku gravatar image
VideoCapture cap1("City Traffic Surveillance.mp4");
Mat frame1;
for (;;) {;
    Mat edges;
    cvtColor(frame1, edges, CV_BGR2GRAY);
Canny(edges, edges, 100, 300, 3);

    tesseract::TessBaseAPI *ocr = new tesseract::TessBaseAPI();
    ocr->TesseractRect(, 1, edges.step1(),,,,;
    char* text = ocr->GetUTF8Text();
     putText(frame1, text, Point(, + 20), FONT_HERSHEY_SIMPLEX, 2, Scalar(0, 255, 0), 2, 8);

  imshow("Video", frame1);
    imshow("Video2", edges);

    if (waitKey(20) == 27) break;

I'm trying to use tesseract with video file like code above. I didn't write code about findGroup in above code but my original has it. The problem is that when I call ocr->TesseractRect(, 1, edges.step1(),,,,, is pointing null character. Because of that error pop up. So I check the value and I found out that frame1 and edges ' data always pointing null character. I guess the way to read video file is wrong but I dont know how to fix this. image description

edit retag flag offensive close merge delete


  1. Please remove screen shot
  2. "Because of that error pop up" give error message
  3. ocr->TesseractRect is not an opencv function : off topics
LBerger gravatar imageLBerger ( 2018-03-04 02:56:17 -0500 )edit

you never check the result from;

it will be false for the last frame of your video file, and you're trying to process an empty Mat() then.

berak gravatar imageberak ( 2018-03-04 19:21:58 -0500 )edit