Consider QRCode ECI encoding#24426
Conversation
|
How did you get the sample QR in PR's description? Why is it differ from test data https://github.com/opencv/opencv_extra/blob/4.x/testdata/cv/qrcode/kanji.jpg ? Which variant is correct? One more example from Internet: https://www.htmlelements.com/docs/images/qrcode-kanji.png |
API should not return In case of Python it could be: Final string should be received through (like
Ref: https://www.thonky.com/qr-code-tutorial/kanji-mode-encoding Kanji input and output must have "Shift-JIS" encoding (not a UTF-8 string / OpenCV string anymore). |
|
@opencv-alalek, https://github.com/opencv/opencv_extra/blob/4.x/testdata/cv/qrcode/kanji.jpg is not a valid Kanji QRCode (encoded in Byte mode). A sample from internet cannot be detected directly, but after removing a text under the code it worked: img = cv.imread("qrcode-kanji.png")
detect = cv.QRCodeDetector()
text, points, straight_qrcode = detect.detectAndDecode(img)
print(text)
print(detect.getEncoding(), cv.QRCodeEncoder_ECI_SHIFT_JIS)
print(text.encode("shift-jis"))
Under new API do you mean a separate naming like |
|
@dkurt Is there a chance to finish it in mean time? |
|
@asmorkalov, yes, let me refresh it. |
f00145e to
efccf18
Compare
asmorkalov
left a comment
There was a problem hiding this comment.
Java bindings are not covered also.
|
@asmorkalov added |
30d892e to
e527110
Compare
e527110 to
30fc9ed
Compare
| #ifdef OPENCV_BINDINGS_PARSER | ||
| CV_WRAP_AS(detectAndDecodeBytes) NativeByteArray detectAndDecode(InputArray img, OutputArray points = noArray(), | ||
| OutputArray straight_code = noArray()) const; | ||
| CV_WRAP_AS(decodeBytes) NativeByteArray decode(InputArray img, InputArray points, OutputArray straight_code = noArray()) const; | ||
| #endif |
There was a problem hiding this comment.
Java bindings use just cv::Mat for it. There is MatOfBytes specialization. M.b. reuse it too?
There was a problem hiding this comment.
In such way user should call an extra method:
MatOfByte output = detector.detectAndDecodeBytes(qrcode);
new String(output.toArray(), "Shift_JIS"));1bc05b2 to
901d5b6
Compare
Consider QRCode ECI encoding opencv#24426 ### Pull Request Readiness Checklist related: opencv#24350 (review) 1. Add `getEncoding` method to obtain ECI number 2. Add `detectAndDecodeBytes`, `decodeBytes`, `decodeBytesMulti`, `detectAndDecodeBytesMulti` methods in Python (return `bytes`) and Java (return `byte[]`) 3. Allow Python bytes to std::string conversion in general and add `encode(byte[] encoded_info, Mat qrcode)` in Java Python example with Kanji encoding: ```python img = cv.imread("test.png") detect = cv.QRCodeDetector() data, points, straight_qrcode = detect.detectAndDecodeBytes(img) print(data) print(detect.getEncoding(), cv.QRCodeEncoder_ECI_SHIFT_JIS) print(data.decode("shift-jis")) ``` ``` b'\x82\xb1\x82\xf1\x82\xc9\x82\xbf\x82\xcd\x90\xa2\x8aE' 20 20 こんにちは世界 ``` source: https://github.com/opencv/opencv/blob/ba4d6c859d21536f84e0328c16f4cc3e96bf3065/modules/objdetect/test/test_qrcode_encode.cpp#L332  See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake

Pull Request Readiness Checklist
related: #24350 (review)
Add
getEncodingmethod to obtain ECI numberAdd
detectAndDecodeBytes,decodeBytes,decodeBytesMulti,detectAndDecodeBytesMultimethods in Python (returnbytes) and Java (returnbyte[])Allow Python bytes to std::string conversion in general and add
encode(byte[] encoded_info, Mat qrcode)in JavaPython example with Kanji encoding:
source:
opencv/modules/objdetect/test/test_qrcode_encode.cpp
Line 332 in ba4d6c8
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.