Skip to content

fix #27183: QRCodeEncoder does not work with more than 135 characters and auto detected version#27189

Closed
stephen-mtz wants to merge 2 commits intoopencv:4.xfrom
stephen-mtz:opencv-qrcode-fix
Closed

fix #27183: QRCodeEncoder does not work with more than 135 characters and auto detected version#27189
stephen-mtz wants to merge 2 commits intoopencv:4.xfrom
stephen-mtz:opencv-qrcode-fix

Conversation

@stephen-mtz
Copy link
Copy Markdown

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 added this to the 4.12.0 milestone Apr 2, 2025
@asmorkalov asmorkalov requested a review from dkurt April 2, 2025 07:03
@asmorkalov asmorkalov added the pr: needs test New functionality requires minimal tests set label Apr 2, 2025
@asmorkalov
Copy link
Copy Markdown
Contributor

@stephenm7777 Thanks a lot for the contribution!. Could you add some simple test to https://github.com/opencv/opencv/blob/4.x/modules/objdetect/test/test_qrcode_encode.cpp to highlight the issue?

@asmorkalov
Copy link
Copy Markdown
Contributor

There are several regressions:

[ RUN      ] Objdetect_QRCode_Encode_Decode.regression
  unknown file: Failure
  C++ exception with description "OpenCV(4.12.0-dev) /home/ci/opencv/modules/objdetect/src/qrcode_encoder.cpp:383: error: (-5:Bad argument) The given input exceeds the maximum capacity of a QR code with the selected encoding mode and error correction level  in function 'generateQR'
  " thrown in the test body.
  [  FAILED  ] Objdetect_QRCode_Encode_Decode.regression (180 ms)
  [ RUN      ] Objdetect_QRCode_Encode.regression/2, where GetParam() = "version1_mode4.png"
  unknown file: Failure
  C++ exception with description "OpenCV(4.12.0-dev) /home/ci/opencv/modules/core/src/arithm.cpp:662: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'arithm_op'
  " thrown in the test body.
  [  FAILED  ] Objdetect_QRCode_Encode.regression/2, where GetParam() = "version1_mode4.png" (9 ms)
  [ RUN      ] Objdetect_QRCode_Encode.regression/5, where GetParam() = "version2_mode4.png"
  unknown file: Failure
  C++ exception with description "OpenCV(4.12.0-dev) /home/ci/opencv/modules/core/src/arithm.cpp:662: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'arithm_op'
  " thrown in the test body.
  [  FAILED  ] Objdetect_QRCode_Encode.regression/5, where GetParam() = "version2_mode4.png" (12 ms)
  [ RUN      ] Objdetect_QRCode_Encode.regression/7, where GetParam() = "version3_mode4.png"
  unknown file: Failure
  C++ exception with description "OpenCV(4.12.0-dev) /home/ci/opencv/modules/core/src/arithm.cpp:662: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'arithm_op'
  " thrown in the test body.
  [  FAILED  ] Objdetect_QRCode_Encode.regression/7, where GetParam() = "version3_mode4.png" (17 ms)
  [ RUN      ] Objdetect_QRCode_Encode_ECI.regression/0, where GetParam() = "version1_mode7.png"
  unknown file: Failure
  C++ exception with description "OpenCV(4.12.0-dev) /home/ci/opencv/modules/core/src/arithm.cpp:662: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'arithm_op'
  " thrown in the test body.
  [  FAILED  ] Objdetect_QRCode_Encode_ECI.regression/0, where GetParam() = "version1_mode7.png" (8 ms)
  [----------] Global test environment tear-down
  [ SKIPSTAT ] 1 tests skipped
  [ SKIPSTAT ] TAG='skip_other' skip 1 tests
  [==========] 196 tests from 57 test cases ran. (31489 ms total)
  [  PASSED  ] 191 tests.
  [  FAILED  ] 5 tests, listed below:
  [  FAILED  ] Objdetect_QRCode_Encode_Decode.regression
  [  FAILED  ] Objdetect_QRCode_Encode.regression/2, where GetParam() = "version1_mode4.png"
  [  FAILED  ] Objdetect_QRCode_Encode.regression/5, where GetParam() = "version2_mode4.png"
  [  FAILED  ] Objdetect_QRCode_Encode.regression/7, where GetParam() = "version3_mode4.png"
  [  FAILED  ] Objdetect_QRCode_Encode_ECI.regression/0, where GetParam() = "version1_mode7.png"

@stephen-mtz
Copy link
Copy Markdown
Author

Understood, @asmorkalov will further work on it! 😄

@asmorkalov
Copy link
Copy Markdown
Contributor

@dkurt Could you take a look?

@dkurt dkurt self-assigned this Apr 7, 2025
@dkurt
Copy link
Copy Markdown
Member

dkurt commented Apr 11, 2025

@stephenm7777 can you please add a new test case with problematic string?

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

Labels

category: objdetect pr: needs test New functionality requires minimal tests set

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants