From bcd6475f1bdd09945ae16d4649d53c39b4ba056d Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Thu, 7 Dec 2023 18:29:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=A3=81=E5=88=87=E7=BA=A0?= =?UTF-8?q?=E5=81=8F=E7=AE=97=E6=B3=95=EF=BC=8C=E8=B0=83=E6=95=B4=E8=89=B2?= =?UTF-8?q?=E5=BD=A9=E5=A1=AB=E5=85=85=E9=97=AE=E9=A2=98=EF=BC=9BBug-758?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/ImageProcess/ImageApplyAutoCrop.cpp | 9 ++++++--- hgdriver/ImageProcess/ImageApplyAutoCrop.h | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hgdriver/ImageProcess/ImageApplyAutoCrop.cpp b/hgdriver/ImageProcess/ImageApplyAutoCrop.cpp index a453a90..c9bb4ee 100644 --- a/hgdriver/ImageProcess/ImageApplyAutoCrop.cpp +++ b/hgdriver/ImageProcess/ImageApplyAutoCrop.cpp @@ -175,7 +175,7 @@ void CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst cv::Mat temp_bgc; cv::resize(resizeMat(boudingRect), temp_bgc, cv::Size(200, 200)); - blankColor = hg::getBackGroundColor(temp_bgc, cv::Mat(), threshold); + blankColor = hg::getBackGroundColor(temp_bgc, cv::Mat(), 10); } else blankColor = cv::Scalar::all(255); @@ -186,7 +186,7 @@ void CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst if (isDesaskew) dst = cv::Mat(cv::Size(rect.size), src.type(), blankColor); else - dst = cv::Mat(rect.boundingRect().size(), src.type(), blankColor); + dst = cv::Mat(/*rect.boundingRect().size()*/ cv::boundingRect(maxContour).size(), src.type(), blankColor); else dst = cv::Mat(dHeight, dWidth, src.type(), blankColor); @@ -234,6 +234,8 @@ void CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst dstROI = dst(cv::Rect((dst.cols - bounding.width) / 2, (dst.rows - bounding.height) / 2, bounding.width, bounding.height)); src(bounding).copyTo(dstROI); + + //cv::imwrite("dst.bmp", dst); } if (isFillBlank) @@ -258,7 +260,8 @@ void CImageApplyAutoCrop::autoCrop_desaskew_fillBlank(cv::Mat& src, cv::Mat& dst } else { - cv::Rect bounding = rect.boundingRect(); + //cv::Rect bounding = rect.boundingRect(); + cv::Rect bounding = cv::boundingRect(maxContour); srcTri[0] = cv::Point(bounding.x, bounding.br().y - 1); srcTri[1] = cv::Point(bounding.x, bounding.y); srcTri[2] = cv::Point(bounding.br().x - 1, bounding.y); diff --git a/hgdriver/ImageProcess/ImageApplyAutoCrop.h b/hgdriver/ImageProcess/ImageApplyAutoCrop.h index 8f940b0..da3b302 100644 --- a/hgdriver/ImageProcess/ImageApplyAutoCrop.h +++ b/hgdriver/ImageProcess/ImageApplyAutoCrop.h @@ -36,7 +36,8 @@ 2023/11/02 v1.6 优化抗噪能力。采用自适应背景色二值化。 2023/12/05 v1.6.1 替换获取背景色方案;修复固定幅面裁切纠偏的坐标计算BUG。 2023/12/06 v1.6.2 修复固定幅面裁切纠偏的坐标计算BUG。 - * 版本号:v1.6.2 + 2023/12/07 v1.6.3 修复无纠偏条件下,图像越界导致坐标计算错误的BUG。 + * 版本号:v1.6.3 * ==================================================== */