Closed gfiumara closed 3 weeks ago
Also consider the scenario where this same image has the middle erased, as if a hole were punched out of a scanned ink card. The image B' might look like this:
After following steps f and g, image C should be:
However, NFIQ 2 produces:
This patch may be the solution. I think one of the bigger issues is that we may have needed to find contours on the inverted mask.
diff --git src/NFIQ2/NFIQ2Algorithm/src/features/ImgProcROIFeature.cpp dst/NFIQ2/NFIQ2Algorithm/src/features/ImgProcROIFeature.cpp
index e6d631b42c4f98929ffd9c9efda97d5f8310b636..8f5997001c3d93ed1debd57c5007e014c96f4fb9 100644
--- src/NFIQ2/NFIQ2Algorithm/src/features/ImgProcROIFeature.cpp
+++ dst/NFIQ2/NFIQ2Algorithm/src/features/ImgProcROIFeature.cpp
@@ -140,21 +140,17 @@ NFIQ2::QualityFeatures::ImgProcROIFeature::computeROI(cv::Mat &img,
std::vector<cv::Vec4i> hierarchy;
// find contours in image
+ contImg = ~contImg;
cv::findContours(contImg, contours, hierarchy, cv::RETR_CCOMP,
cv::CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
// if holes are found -> close holes
- if (hierarchy.size() > 2) {
- cv::Mat filledImg;
- cv::cvtColor(threshImg2, filledImg, cv::COLOR_GRAY2BGR);
-
- for (unsigned int idx = 0; idx < (hierarchy.size() - 2);
- idx++) {
- cv::drawContours(filledImg, contours, idx,
- cv::Scalar(0, 0, 0, 0), cv::FILLED, 8, hierarchy);
+ for (int h{}; h < hierarchy.size(); ++h) {
+ // If contour on inverted image has a parent, it's a hole
+ if (hierarchy[h][3] != -1) {
+ cv::drawContours(threshImg2, contours, h, cv::Scalar(0),
+ cv::LineTypes::FILLED, 8, hierarchy);
}
-
- cv::cvtColor(filledImg, threshImg2, cv::COLOR_BGR2GRAY);
}
// 7. remove smaller blobs at the edges that are not part of the
Fixed in 0564f51.
Describe the issue 5.2.13.3 step g indicates that regions in the contour map surrounded by black shall be black. In the image 00002531_S_500_slap_03.png from NIST SD 302, this is not followed.
To reproduce Steps to reproduce the issue:
Expected behavior
OS information
Library information
NFIQ 2 version information Biometric Evaluation: 10.0 FingerJet: 5.2.1 OpenCV: 4.5.4 NFIQ 2: 2.2.0 (Date: 202208051443, Commit: e8f4914)
Code sample Is there a reliable code sample you can include?
N/A
Additional context