Skip to content

Added QR_Code data flip support, flip and retry after first ECC failure#23275

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
neg-c:bug/issue-23249_detected_but_not_decoded_bug
Mar 21, 2023
Merged

Added QR_Code data flip support, flip and retry after first ECC failure#23275
asmorkalov merged 1 commit intoopencv:4.xfrom
neg-c:bug/issue-23249_detected_but_not_decoded_bug

Conversation

@neg-c
Copy link
Copy Markdown
Contributor

@neg-c neg-c commented Feb 18, 2023

Merge with extra: opencv/opencv_extra#1046

Fixes #23249, fixes #23155, fixes #20724

Added quirc_flip() method to horizontally flip the data.
When the decoder fails to ECC the data we flip the image, and try one more time.

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

@neg-c neg-c changed the title Added QR_Code data flip support, flip and retry after first EEC failure Added QR_Code data flip support, flip and retry after first ECC failure Feb 18, 2023
@neg-c
Copy link
Copy Markdown
Contributor Author

neg-c commented Feb 23, 2023

@alalek The test data for this PR is in : opencv_extra/pull/1046.

@neg-c neg-c force-pushed the bug/issue-23249_detected_but_not_decoded_bug branch from de7ea8d to de944b3 Compare February 23, 2023 21:15
@neg-c
Copy link
Copy Markdown
Contributor Author

neg-c commented Feb 27, 2023

@alalek @AleksandrPanov Is there something left to do in this PR from my side ?

@AleksandrPanov
Copy link
Copy Markdown
Contributor

AleksandrPanov commented Mar 14, 2023

@genciberisha I found this issue in the quirc library:
QR code ECC failure #88
support horizontally flipped QR-codes according to ISO 18004:2015 #89

Your solution to the problem is correct, thank you. Test images must be converted to jpg to take up less space.

@asmorkalov
Copy link
Copy Markdown
Contributor

asmorkalov commented Mar 14, 2023

The PR contains 2 tests that are dependent. It's not stable solution for testing. I propose to remove generator part and hardcode information as static array. There are only 2 images, not need to dump regression data to file.

@asmorkalov asmorkalov self-requested a review March 14, 2023 11:06
@neg-c neg-c force-pushed the bug/issue-23249_detected_but_not_decoded_bug branch 2 times, most recently from 7b02524 to 36bc181 Compare March 15, 2023 22:32
@neg-c
Copy link
Copy Markdown
Contributor Author

neg-c commented Mar 15, 2023

@AleksandrPanov Converting these images to JPG decreases the size a little but also with a lot off quality loss.
I managed to compress these PNG file to under 3kb size, hope that counts.


@asmorkalov Agreed, I removed the generation test and replaced it with a simple validation test.
Please note because of the nature of the bug we need to validate the data at the end, so I saw it reasonable to
to pack the filename and expected result as a std::pair.

Copy link
Copy Markdown
Contributor

@AleksandrPanov AleksandrPanov left a comment

Choose a reason for hiding this comment

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

@genciberisha, thank you
I consider this solution to be optimal, because it's like quirc's solution.

Added regression test for the flipped images
@neg-c neg-c force-pushed the bug/issue-23249_detected_but_not_decoded_bug branch from 36bc181 to a1b4aa5 Compare March 20, 2023 13:28
@neg-c
Copy link
Copy Markdown
Contributor Author

neg-c commented Mar 21, 2023

@alalek Seems there isn't anything left here to do, thank you.

@asmorkalov asmorkalov added this to the 4.8.0 milestone Mar 21, 2023
@asmorkalov asmorkalov merged commit e6bd4c9 into opencv:4.x Mar 21, 2023
@opencv-alalek
Copy link
Copy Markdown
Contributor

There is build error:

/build/4_x_ARMv7-lin/opencv/3rdparty/quirc/src/decode.c: In function 'quirc_flip':
/build/4_x_ARMv7-lin/opencv/3rdparty/quirc/src/decode.c:923:9: warning: missing braces around initializer [-Wmissing-braces]
  struct quirc_code flipped = {0};
         ^
/build/4_x_ARMv7-lin/opencv/3rdparty/quirc/src/decode.c:923:9: warning: (near initialization for 'flipped.corners') [-Wmissing-braces]
/build/4_x_ARMv7-lin/opencv/3rdparty/quirc/src/decode.c:925:2: error: 'for' loop initial declarations are only allowed in C99 mode
  for (int y = 0; y < code->size; y++) {
  ^
/build/4_x_ARMv7-lin/opencv/3rdparty/quirc/src/decode.c:925:2: note: use option -std=c99 or -std=gnu99 to compile your code
/build/4_x_ARMv7-lin/opencv/3rdparty/quirc/src/decode.c:926:3: error: 'for' loop initial declarations are only allowed in C99 mode
   for (int x = 0; x < code->size; x++) {
   ^

@asmorkalov
Copy link
Copy Markdown
Contributor

@AleksandrPanov Could you fix it?

@asmorkalov asmorkalov mentioned this pull request Apr 12, 2023
6 tasks
@asmorkalov asmorkalov mentioned this pull request May 31, 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.

QRCodeDetector - QR Code detected but no decoded text QrCodeReader decodes only when flipping image QR_code not detected

5 participants