Skip to content

QR code: fix false positive detection#19677

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
APrigarina:detection_fix
Mar 5, 2021
Merged

QR code: fix false positive detection#19677
opencv-pushbot merged 1 commit intoopencv:3.4from
APrigarina:detection_fix

Conversation

@APrigarina
Copy link
Copy Markdown
Contributor

@APrigarina APrigarina commented Mar 4, 2021

This PR will fix some cases of false positive detection of QR codes and prevent segmentation fault in decodeCurved() due to these cases

resolves #19626

@alalek
Copy link
Copy Markdown
Member

alalek commented Mar 4, 2021

Does it resolve #19626 ?

@APrigarina
Copy link
Copy Markdown
Contributor Author

Does it resolve #19626 ?

Yes, I have updated issue number in PR description

}
}
double mean_compactness = compactness / point2f_result.size();
double ratio = mean_compactness / min_dist;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add handling to avoid divisions by zero here.

CV_DbgAssert(!point2f_result.size()); should be enough for the first case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you
I have added condition for min_dist, but for the first case there is already condition if above

for (int coeff_epsilon = 1; coeff_epsilon < 10; coeff_epsilon++)
const int min_dist_between_points = 10;
const double max_ratio = 1.0;
for (float coeff_epsilon = 0.1; coeff_epsilon < 10.1; coeff_epsilon+=0.1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid iterations through "floating-point" vars.

for (int coeff_epsilon_i = 1; coeff_epsilon_i < 101; ++coeff_epsilon_i)
{
    const float coeff_epsilon = coeff_epsilon_i * 0.1f;
    ...

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thank you 👍

@opencv-pushbot opencv-pushbot merged commit f821530 into opencv:3.4 Mar 5, 2021
@alalek alalek mentioned this pull request Mar 6, 2021
@alalek alalek mentioned this pull request Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segmentation fault on loop calling QRCodeDetector, decodeCurved method

3 participants