Update intrin_wasm.hpp #25909
See https://github.com/microsoft/vcpkg/issues/33443 for some build context when using
```vcpkg install opencv4:wasm32-emscripten```
`__EMSCRIPTEN_major__`, `__EMSCRIPTEN_minor__` and `__EMSCRIPTEN_tiny__` in `emsdk` >= 3.1.4 are in a header, as opposed to command line.
We could potentially be more aggressive with how I'm checking this property; let me know if I should make the change.
It should also be suggested that `-msimd128` is auto-included in the associated portfile for opencv, but that's a separate issue. Someone let me know if I should also make that change as well.
Special thanks to https://github.com/youar for supporting this work; please inform if applying a copyright-header is appropriate attribution.
### Pull Request Readiness Checklist
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
Split Javascript white-list to support contrib modules #25986
Single whitelist converted to several per-module json files. They are concatenated automatically and can be overriden by user config.
Related to https://github.com/opencv/opencv/pull/25656
### Pull Request Readiness Checklist
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
- [ ] 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
modules/js/perf/perf_helpfunc.js and target tests, e.g. perf_gaussianBlur.js contained "const isNodeJs", leading to re-definition when using associated *.html files.
Use onRuntimeInitialized with OpenCV.js Node tests #25757
### Pull Request Readiness Checklist
tests: https://github.com/opencv/ci-gha-workflow/pull/174
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
Fix OpenCV.js tests #25732
### Pull Request Readiness Checklist
* Firefox tests passed
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
Add compatibility with latest (3.1.54) emsdk version #25084
### Pull Request Readiness Checklist
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
- [ ] 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
### Details
I was following [this tutorial](https://docs.opencv.org/4.9.0/d4/da1/tutorial_js_setup.html) for building opencv with wasm target. The tutorial mentions that the last verified version of emscripten that is tested with opencv is 2.0.10, but I was curious if I could get it to work with more recent versions. I've run into a few issues with the latest version, for which fixes are included in this PR. I've found a few issues that have the same problems I encountered:
- https://github.com/opencv/opencv/issues/24620
- https://github.com/opencv/opencv/issues/20313
- https://stackoverflow.com/questions/77469603/custom-opencv-js-wasm-using-cv-matfromarray-results-in-cv-mat-is-not-a-co
- https://github.com/emscripten-core/emscripten/issues/14803
- https://github.com/opencv/opencv/issues/24572
- https://github.com/opencv/opencv/issues/19493#issuecomment-857167996
I used the docker image for building and comparing results with different emsdk versions. I tested by building with `--build_wasm` and `--build-test` flags and ran the tests in the browser. I addressed the following issues with newer versions of emscripten:
- In newer versions `EMSCRIPTEN` environemnt variable was stopped being set. I added support for deriving location based on the `EMSDK` environment variable, as suggested [here](https://github.com/emscripten-core/emscripten/issues/14803)
- In newer versions emcmake started passing `-DCMAKE...` arguments, however the opencv python script didn't know how to handle them. I added processing to the args that will forward all arguments to `cmake` that start with `-D`. I opted for this in hopes of being more futureproof, but another approach could be just ignoreing them, or explicitly forwarding them instead of matching anything starting with `-D`. These approches were suggested [here](https://github.com/opencv/opencv/issues/19493#issuecomment-855529448)
- With [version 3.1.31](https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md#3131---012623) some previously exported functions stopped being automatically exported. Because of this, `_free` and `_malloc` were no longer available and had to be explicitly exported because of breaking tests.
- With [version 3.1.42](https://github.com/emscripten-core/emscripten/compare/3.1.41...3.1.42#diff-e505aa80b2764c0197acfc9afd8179b3600f0ab5dd00ff77db01879a84515cdbL3875) the `post-js` code doesn't receive the module named as `EXPORT_NAME` anymore, but only as `moduleArg`/`Module`. This broke existing code in `helpers.js`, which was referencing exported functions through `cv.Mat`, etc. I changed all of these references to use `Module.Mat`, etc. If it is preferred, alternatively the `cv` variable could be reintroduced in `helper.js` as suggested [here](https://github.com/opencv/opencv/issues/24620)
With the above changes in place, I can successfully build and run tests with the latest emscripten/emsdk docker image (also with 2.0.10 and most of the other older tags, except for a few that contain transient issues like [this](https://github.com/emscripten-core/emscripten/issues/17700)).
This is my first time contributing to opencv, so I hope I got everything correct in this PR, but please let me know if I should change anything!
In test_imgproc.js, the test_filter suite's last test assigns a variable
to `size` without declaring it with `let`, polluting the global scope.
This commit adds `let` to the statement, so that the variable is scoped
to the test block.
* Prefix global javascript functions with sub-namespaces
* js: handle 'namespace_prefix_override', update filtering
- avoid functions override with same name but different namespace
Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
* fix the perf tests of OpenCV.js so that it can run on Node.js successfully
* do not modify the CMakeLists.txt
Co-authored-by: lionkun <871518554@qq.com>
[GSoC] OpenCV.js: WASM SIMD optimization 2.0
* gsoc_2020_simd Add perf test for filter2d
* add perf test for kernel scharr and kernel gaussianBlur
* add perf test for blur, medianBlur, erode, dilate
* fix the errors for the opencv PR robot
fix the trailing whitespace.
* add perf tests for kernel remap, warpAffine, warpPersepective, pyrDown
* fix a bug in modules/js/perf/perf_imgproc/perf_remap.js
* add function smoothBorder in helpfun.js and remove replicated function in perf test of warpAffine and warpPrespective
* fix the trailing white space issues
* add OpenCV.js loader
* Implement the Loader with help of WebAssembly Feature Detection, remove trailing whitespaces
* modify the explantion for loader in js_setup.markdown and fix bug in loader.js
changed OpenCV license from BSD to Apache 2 license
* as discussed and announced earlier, changed OpenCV license from BSD to Apache 2. Many files still contain old-style copyrights though
* changed wording a bit; preserve the original OpenCV BSD license
Fix Test Case: in latest version, window.cv is a promise instance that makes most test case failed.
* Fix Browser Test Case: In latest version, window.cv is a promise instance
In latest version of opencv.js, window.cv is promise instance.
So that most of the test cases is run failed.
This commit is to fix browser test case.
* Add comment for backward compatible
Add comments for backward compatible