Skip to content
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

Use QR code alignment markers #22891

Merged
merged 1 commit into from Dec 15, 2022
Merged

Conversation

AleksandrPanov
Copy link
Contributor

@AleksandrPanov AleksandrPanov commented Nov 30, 2022

merge with opencv/opencv_extra#1024

Added detect QR code alignment marker (1 marker for 2-6 versions, 6 markers for 7-40 versions). Alignment marker uses to find the correct position of the fourth corner.

To check the correctness, a benchmark was launched:
qr.py.txt

No decode regression now.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov asmorkalov changed the title add alignment detect Use QR code alignment margkers Nov 30, 2022
@asmorkalov asmorkalov changed the title Use QR code alignment margkers Use QR code alignment markers Nov 30, 2022
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
@asmorkalov
Copy link
Contributor

It makes sense to enable all disabled tests for QR codes first. Version estimation and alignment markers should make more tests stable.

@AleksandrPanov AleksandrPanov force-pushed the qr_add_alignment branch 2 times, most recently from 429adcc to 72a1a1f Compare December 1, 2022 21:02
@AleksandrPanov AleksandrPanov force-pushed the qr_add_alignment branch 3 times, most recently from 6f099ea to 171afaf Compare December 5, 2022 03:07
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
@asmorkalov asmorkalov marked this pull request as ready for review December 6, 2022 08:18
@AleksandrPanov AleksandrPanov force-pushed the qr_add_alignment branch 2 times, most recently from 500a205 to c4a00da Compare December 6, 2022 19:40
@asmorkalov asmorkalov added this to the 4.7.0 milestone Dec 7, 2022
@asmorkalov
Copy link
Contributor

@alalek May we merge the patch?

Copy link
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.

BTW,
There is opencv_extra patch related to this (it should be marked on the first visible line instead of somewhere in the middle of description).
Test data size is >600kB for one test image.

modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
Comment on lines 31 to 35
std::string qrcode_images_multiple[] = {
"2_qrcodes.png", "3_close_qrcodes.png", "3_qrcodes.png", "4_qrcodes.png",
"2_qrcodes.png", /*"3_close_qrcodes.png",*/ "3_qrcodes.png", /*"4_qrcodes.png",*/
"5_qrcodes.png", "6_qrcodes.png", "7_qrcodes.png", "8_close_qrcodes.png"
};
// 3_close_qrcodes.png, 4_qrcodes.png DISABLED after PR #22891
Copy link
Member

Choose a reason for hiding this comment

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

Some test cases are disabled (so it is formally a regression).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixing regression

modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved

std::vector<Mat1b> straight_barcode;
qrcode.detectAndDecodeMulti(src, decoded_info, corners, straight_barcode);
EXPECT_EQ(decoded_info.size(), 9ull);
Copy link
Member

Choose a reason for hiding this comment

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

Again, wrong order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reordered

@AleksandrPanov
Copy link
Contributor Author

AleksandrPanov commented Dec 13, 2022

BTW, There is opencv_extra patch related to this (it should be marked on the first visible line instead of somewhere in the middle of description). Test data size is >600kB for one test image.

opencv_extra patch notes moved to first line, test image was scaled to 306.2 kB

There are 9 qr codes with big enough version in one test image (old test image 9_qrcodes.jpg has 290 kB size with low qrs version).

@AleksandrPanov AleksandrPanov force-pushed the qr_add_alignment branch 3 times, most recently from ec878b4 to cdc96b3 Compare December 13, 2022 18:22
modules/objdetect/src/qrcode.cpp Outdated Show resolved Hide resolved
modules/objdetect/src/qrcode.cpp Show resolved Hide resolved
@@ -114,7 +114,6 @@ PERF_TEST_P_(Perf_Objdetect_QRCode_Multi, decodeMulti)
straight_barcode_sort.push_back(result[i].second);
}
SANITY_CHECK(decoded_info_sort);
SANITY_CHECK(straight_barcode_sort);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some problem in 4_qrcodes.png, 8_close_qrcodes.png
This QRs correctly decoded, but there is no bitwise equality in straight_barcode and golds. I think this is an optional check. A successful decode should mean that the test has passed.

Copy link
Member

Choose a reason for hiding this comment

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

agreed

Copy link
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.

Thank you 👍

@asmorkalov asmorkalov merged commit 0153e79 into opencv:4.x Dec 15, 2022
@alalek alalek mentioned this pull request Jan 8, 2023
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.

None yet

4 participants