Add QRCodeDetector to JavaScript Build#19284
Conversation
1021af6 to
5abb733
Compare
alalek
left a comment
There was a problem hiding this comment.
Thank you for contribution!
Please take a look on comments below.
| @endcode | ||
|
|
||
| @note | ||
| It requires the [opencv_extra repository](https://github.com/opencv/opencv.git) located in your development environment. |
There was a problem hiding this comment.
Lets keep OPENCV_TEST_DATA_PATH optional.
Prefer to use environment variable for OPENCV_TEST_DATA_PATH.
There was a problem hiding this comment.
Did i get you right, that the tests for the QRCodeDetector should be skipped when the enviroment variable OPENCV_TEST_DATA_PATH is not set? Because the tests depend on two files from the opencv_extra repository.
There was a problem hiding this comment.
Please drop OPENCV_TEST_DATA_PATH changes from the patch
modules/js/CMakeLists.txt
Outdated
| list(APPEND opencv_test_js_file_deps "${test_data_haarcascade_path}" "${opencv_test_js_bin_dir}/${test_data_haarcascade}") | ||
| # QR code | ||
| set(test_data_qrcode_1 "link_ocv.jpg") | ||
| set(test_data_qrcode_1_path "${OPENCV_TEST_DATA_PATH}/cv/qrcode/${test_data_qrcode_1}") |
There was a problem hiding this comment.
Copy data only if build_tests enabled.
modules/js/generator/embindgen.py
Outdated
| 'string':'std::string', # Side effect | ||
| 'String': 'std::string', |
There was a problem hiding this comment.
Keep existed coding style.
Please remove the comment as it doesn't help and just confuse readers.
There was a problem hiding this comment.
Thank you, i will remove the comment and fix the coding style.
If you swap the order of the entry 'string': 'std::string' (line 122) with 'String': 'std::string' (line 123) a double replacement happens and the code doesn't work anymore.
Should i add a comment there with a warning to not swap the order of the entries?
There was a problem hiding this comment.
Thank you for information! I will take a look on this behavior
modules/js/test/test_objdetect.js
Outdated
| const imgSingleQrCode = new Image(); | ||
| imgSingleQrCode.crossOrigin = 'anonymous'; | ||
| imgSingleQrCode.onload = function () { | ||
| const canvas = document.createElement('canvas'); | ||
| const ctx = canvas.getContext('2d'); |
There was a problem hiding this comment.
You are right, this is not working in Node.js.
In order to provide tests i have seen other JavaScript tests, where images are created from a hardcoded array.
In this test case it would probably be a huge array to create an image containing a QR-code.
Is there a way of loading images, which works both in the browser and in node.js? Otherwise i have to implement two different ways of loading the images.
There was a problem hiding this comment.
Until we have good images (testdata) support in JS tests infrastructure, lets check the "bindings" existence only (without any attempt to perform accuracy checks).
Please use Mat.zeros(...) as input in tests for now. And check that there are no exceptions raised. Minimal smoke test.
For accuracy demo it would be nice to add tutorial page (examples).
There was a problem hiding this comment.
I have now added tests that do not require any test images.
Therefore I have removed the copying of the test images again.
I will start writing a tutorial page. Should the tutorial include the QR code recognition algorithm? As far as I could understand QrCodeDetector::detect uses the algorithm described in this article.
3fb1088 to
14fbe63
Compare
|
WIP: Sorry, something went wrong during the rebase |
14fbe63 to
d6bd688
Compare
- cherry picked commit to solve rebase error
d6bd688 to
c22d409
Compare
|
@Ziachnix Do you have progress with the PR? |
| @endcode | ||
|
|
||
| @note | ||
| It requires the [opencv_extra repository](https://github.com/opencv/opencv.git) located in your development environment. |
There was a problem hiding this comment.
Please drop OPENCV_TEST_DATA_PATH changes from the patch
|
@Ziachnix Friendly reminder. |
Thank you, i totally forgot that there is still some work to be done. |
This PR adds javascript support for the class QRCodeDetector.
Tests for the proposed functions are derived from the equivalent python tests.
Because sample images are needed for running the tests, the build of the tests
requires now the opencv_extra repository.
(Alternatively i could copy some test images into the tutorial folder and use
them in the tests)
Due to emscripten limitations the functions decodeMulti and
detectAndDecodeMulti are excluded.
As far as i know it is not possible to use a function parameter (string array)
to return the decoded content of the QR codes.
Pull Request Readiness Checklist
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.