Skip to content

Barcode detectAndDecode - Minor Performance Issue #3101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
saurabheights opened this issue Nov 10, 2021 · 1 comment · Fixed by #3107
Closed
4 tasks done

Barcode detectAndDecode - Minor Performance Issue #3101

saurabheights opened this issue Nov 10, 2021 · 1 comment · Fixed by #3107

Comments

@saurabheights
Copy link
Contributor

saurabheights commented Nov 10, 2021

System information (version)

4.x - Current Master Branch

Detailed description

In barcode module, detectAndDecode method calls:-

  • checkBarInputImage - which checks if image is graychannel and if not it converts it to gray channel.(among few others check).
  • detect - Next, it calls detect method with original input image, and not the graychannel image. Later on, the method detect uses the same checkBarInputImage to reconvert the original input image to graychannel.

Relevant Lines of detectAndDecode:-

if (!checkBarInputImage(img, inarr))
{
points_.release();
return false;
}
vector<Point2f> points;
bool ok = this->detect(img, points);

Relevant Lines of detect:-

Mat inarr;
if (!checkBarInputImage(img, inarr))
{
points.release();
return false;
}
Detect bardet;
bardet.init(inarr);

Steps to reproduce

Not a logic bug, just a little unnecessary computation overhead.

I will add PR once I have green light from one of contributors.

The line

bool ok = this->detect(img, points);

needs to be changed from img to inarr.

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    answers.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc
@saurabheights saurabheights changed the title Barcode detectAndDecode - Minor Performance Bug Barcode detectAndDecode - Minor Performance Issue Nov 10, 2021
@alalek
Copy link
Member

alalek commented Nov 10, 2021

Sounds reasonable. Feel free to open PR with fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants