From 7a3aef5d299f22bd2470f1f774c443aeb1b36127 Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Mon, 31 Oct 2022 14:02:14 +0800 Subject: [PATCH] =?UTF-8?q?ocr=E5=A2=9E=E5=8A=A0dpi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/imgproc/HGOCRTesseract.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/imgproc/HGOCRTesseract.cpp b/modules/imgproc/HGOCRTesseract.cpp index 7a574fd8..ac555efc 100644 --- a/modules/imgproc/HGOCRTesseract.cpp +++ b/modules/imgproc/HGOCRTesseract.cpp @@ -94,6 +94,9 @@ HGResult HGOCRTesseract::ImageOCR(HGImage image, class HGOCRRetImpl** ocrRet) HGBase_GetImageData(image2, &imageData); TessBaseAPISetImage(m_baseApi, imageData, imgInfo.width, imgInfo.height, 3, imgInfo.widthStep); + HGUInt xDpi, yDpi; + HGBase_GetImageDpi(image2, &xDpi, &yDpi); + TessBaseAPISetSourceResolution(m_baseApi, (xDpi + yDpi) / 2); char *text = TessBaseAPIGetUTF8Text(m_baseApi); if (NULL == text) @@ -159,6 +162,9 @@ HGResult HGOCRTesseract::ImageTextDirectOCR(HGImage image, HGUInt* direct) HGBase_GetImageData(image2, &imageData); TessBaseAPISetImage(m_baseApi, imageData, imgInfo.width, imgInfo.height, 3, imgInfo.widthStep); + HGUInt xDpi, yDpi; + HGBase_GetImageDpi(image2, &xDpi, &yDpi); + TessBaseAPISetSourceResolution(m_baseApi, (xDpi + yDpi) / 2); TessPageIterator* iter = TessBaseAPIAnalyseLayout(m_baseApi); if (NULL == iter)