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 * ==================================================== */