Skip to content

Barcode detectAndDecode - Minor Performance Issue #3101

Closed
@saurabheights

Description

@saurabheights
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions