小编use*_*634的帖子

将带有 OpenCV 边界框的图像传递给 tesseract OCR

我正在尝试使用 OpenCV 和 Tesseract 从图像中提取文本。我已经设法检测文本区域并使用边界框来分隔它们。但现在我找不到如何将边界框传递给 Tesseract。

        for(int idx = 0; idx >= 0; idx = hierarchy[idx][0])
        {
            Rect rect = boundingRect(contours[idx]);
            Mat maskROI(mask, rect);
            maskROI = Scalar(0, 0, 0);
            // fill the contour
            drawContours(mask, contours, idx, Scalar(255, 255, 255), CV_FILLED);
            // ratio of non-zero pixels in the filled region
            double r = (double)countNonZero(maskROI)/(rect.width*rect.height);

            if (r > .45 /* assume at least 45% of the area is filled if it contains text */
                &&
                (rect.height > 8 && rect.width > 8) …
Run Code Online (Sandbox Code Playgroud)

c++ opencv tesseract opencv3.0

3
推荐指数
1
解决办法
6202
查看次数

标签 统计

c++ ×1

opencv ×1

opencv3.0 ×1

tesseract ×1