Skip to content

QR-Code detector : multiple detection - #15338

Merged
alalek merged 61 commits into
opencv:3.4from
rayonnant14:my_detect_and_decode_3.4
Jan 26, 2020
Merged

alalek merged 61 commits into
opencv:3.4from
rayonnant14:my_detect_and_decode_3.4

Conversation

@rayonnant14

@rayonnant14 rayonnant14 commented Aug 19, 2019 •

Copy link
Copy Markdown
Contributor

Merge with extra: opencv/opencv_extra#684

@rayonnant14 rayonnant14 changed the title My detect and decode 3.4 QR-Code detector : multiple detection Aug 19, 2019
Comment thread modules/objdetect/src/qrcode.cpp Resolved
Comment thread modules/objdetect/src/qrcode.cpp Resolved
Comment thread modules/objdetect/src/qrcode.cpp Resolved
Comment thread modules/objdetect/src/qrcode.cpp Resolved
Comment thread modules/objdetect/src/qrcode.cpp Resolved
Comment thread modules/objdetect/src/qrcode.cpp Resolved
Comment thread modules/objdetect/src/qrcode.cpp Resolved
Comment thread modules/objdetect/test/test_qrcode.cpp Resolved
Comment thread modules/objdetect/src/qrcode.cpp Resolved
Comment thread modules/objdetect/src/qrcode.cpp Resolved
@asmorkalov

Copy link
Copy Markdown
Contributor

@rayonnant14, @allnes What is the PR status? Is it still WIP?

@allnes

allnes commented Oct 24, 2019

Copy link
Copy Markdown
Member

@rayonnant14, @allnes What is the PR status? Is it still WIP?

Yes, this PR in progress.

@rayonnant14
rayonnant14 requested a review from alalek January 14, 2020 13:24
@alalek

alalek commented Jan 15, 2020

Copy link
Copy Markdown
Member

Again, drawing functions should be avoided.

checkPointsInsideQuadrangle() and checkPointsInsideTriangle() should not "draw" anything.
Take a look on pointPolygonTest() function.

The similar note is about checkPoints(). Intensity check can be related for "bounding rectangle".

another one fillConvexPoly() call in findQRCodeContours().

need to revise code using of floodFill() / LineIterator() functionality.

@param img grayscale or color (BGR) image containing (or not) QR codes.
@param points Output vector of vector of vertices of the minimum-area quadrangle containing the codes.
*/
CV_WRAP bool detectMulti(InputArray img, OutputArrayOfArrays points) const;

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.

OutputArrayOfArrays
InputArrayOfArrays
std::vector< std::vector< Point > > corners;

Please avoid using of *OfArrays types and/or nested std::vector.
This is unnecessary for fixed size elements (4 points per QR code).

Lets store points as one "array" (without nesting):

  • std::vector< Point > where each 4 points define QR code instance (<0, 1, 2, 3>, <4, 5, 6 ,7> ...).
  • Mat - CV_32FC2 with one or multiple rows.
    and pass them as OutputArray.

This is continued discussion from this comment: #15338 (comment)

Comment thread samples/cpp/qrcode.cpp Outdated
break;
}
if (!out_origin_file.empty())
imwrite(out_origin_file, frame); // write original frame

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.

Saving each frame slowdowns demo significantly. Image I/O is not optimized (because it is for debug purposes here).

Original and processed frames should be saved by pressing key only (it was space ' '). Both at once.

class qrcode_detector_test(NewOpenCVTests):
def test_detect_and_decode(self):
img = cv.imread(os.path.join(self.extraTestDataPath, 'cv/qrcode/link_ocv.jpg'))
self.assertFalse(img == None)

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.

== None

In Python world checks should look like:

  • a is None
  • a is not None

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.

@alalek Which way is better img is None or np.shape(img) is () ?

@alalek
alalek merged commit acc089c into opencv:3.4 Jan 26, 2020
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
…_3.4

QR-Code detector : multiple detection

* change in qr-codes detection

* change in qr-codes detection

* change in test

* change in test

* add multiple detection

* multiple detection

* multiple detect

* add parallel implementation

* add functional for performance tests

* change in test

* add perftest

* returned implementation for 1 qr-code, added support for vector<Mat> and vector<vector<Point2f>> in MultipleDetectAndDecode

* deleted all lambda expressions

* changing in triangle sort

* fixed warnings

* fixed errors

* add java and python tests

* change in java tests

* change in java and python tests

* change in perf test

* change in qrcode.cpp

* add spaces

* change in qrcode.cpp

* change in qrcode.cpp

* change in qrcode.cpp

* change in java tests

* change in java tests

* solved problems

* solved problems

* change in java and python tests

* change in python tests

* change in python tests

* change in python tests

* change in methods name

* deleted sample qrcode_multi, change in qrcode.cpp

* change in perf tests

* change in objdetect.hpp

* deleted code duplication in sample qrcode.cpp

* returned spaces

* added spaces

* deleted draw function

* change in qrcode.cpp

* change in qrcode.cpp

* deleted all draw functions

* objdetect(QR): extractVerticalLines

* objdetect(QR): whitespaces

* objdetect(QR): simplify operations, avoid duplicated code

* change in interface, additional checks in java and python tests, added new key in sample for saving original image from camera

* fix warnings and errors in python test

* fix

* write in file with space key

* solved error with empty mat check in python test

* correct path to test image

* deleted spaces

* solved error with check empty mat in python tests

* added check of empty vector of points

* samples: rework qrcode.cpp

* objdetect(QR): fix API, input parameters must be first

* objdetect(QR): test/fix points layout
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.

5 participants