converting cv::Mat for tesseract

前端 未结 4 1533
失恋的感觉
失恋的感觉 2020-12-05 03:05

I\'m using OpenCV to extract a subimage of a scanned document and would like to use tesseract to perform OCR over this subimage.

I found out that I can use two meth

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 03:56

    tesseract::TessBaseAPI tess; 
    cv::Mat sub = image(cv::Rect(50, 200, 300, 100));
    tess.SetImage((uchar*)sub.data, sub.size().width, sub.size().height, sub.channels(), sub.step1());
    tess.Recognize(0);
    const char* out = tess.GetUTF8Text();
    

提交回复
热议问题