Repository: opencv
Issue: [Feature Request] Generating bindings for tracking (contrib) modules in JS
Labels: feature,category: javascript (js)

<!--
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
<!-- Example
- OpenCV => 4.5.1-dev (master 107f233626)
- Operating System / Platform => Linux 64 bit (Javascript)
- Compiler => Emscripten
-->

- OpenCV => 4.5.1-dev (master 107f233626)
- Operating System / Platform => Linux 64 bit (Javascript)
- Compiler => Emscripten

##### Detailed description
I tried wrapping the tracking modules in JS based on the `aruco` [MR](https://github.com/opencv/opencv/pull/13571/files), and [examples](https://github.com/ganwenyao/opencv_js). 

Since both `video (main)` and `tracking (contrib)` modules have classes with same names (eg: CvFeatureParams ([main repo](https://github.com/opencv/opencv/blob/aab6362705e9afcd99dacb137a011b51061affcd/modules/video/include/opencv2/video/detail/tracking_feature.private.hpp#L34), [contrib](https://github.com/opencv/opencv_contrib/blob/master/modules/tracking/include/opencv2/tracking/feature.hpp#L140)), CvFeatureEvaluator ([main repo](https://github.com/opencv/opencv/blob/aab6362705e9afcd99dacb137a011b51061affcd/modules/video/include/opencv2/video/detail/tracking_feature.private.hpp#L51), [contrib](https://github.com/opencv/opencv_contrib/blob/master/modules/tracking/include/opencv2/tracking/feature.hpp#L160))) but inside `inline` namespaces, this leads to conflicts, thereby making the wrapping not very straightforward.

I have described what I did as a workaround on the OpenCV forum ( [link to post](https://forum.opencv.org/t/opencv-js-build-tracking-module-in-opencv-contrib-but-encounter-generate-error/608/3?u=imgprcsng) ) to get them to compile.
 
##### Steps to reproduce
- `git clone https://github.com/opencv/opencv && cd opencv && git clone https://github.com/opencv/opencv_contrib contrib`
- Add `js` to `contrib/modules/tracking/CMakeLists.txt`
```
diff --git a/modules/tracking/CMakeLists.txt b/modules/tracking/CMakeLists.txt
index c638fcf6..4bc60b08 100644
--- a/modules/tracking/CMakeLists.txt
+++ b/modules/tracking/CMakeLists.txt
@@ -19,6 +19,7 @@ ocv_define_module(tracking
       java
       python
       objc
+      js
 )
 
 ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow /wd4458)
```
- Compile to test if it works out of the box
```
docker run \
     --rm \
     -v $(pwd):/src \
     -u $(id -u):$(id -g) \
     emscripten/emsdk \
     emcmake python3 ./platforms/js/build_js.py build_wasm \
          --build_wasm \
          --cmake_option="-DOPENCV_EXTRA_MODULES_PATH=$(pwd)/contrib/modules" \
          --cmake_option="-DBUILD_LIST=core,imgproc,video,tracking,js"
```
Error is same as the one reported [here](https://forum.opencv.org/t/opencv-js-build-tracking-module-in-opencv-contrib-but-encounter-generate-error/608)

Any suggestions on how to proceed on fixing this?

##### Issue submission checklist

 - [x] I report the issue, it's not a question
   <!--
   OpenCV team works with forum.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with question without real issue statement will be
   closed.
   -->
 - [x] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://forum.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [x] I updated to latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only latest release for each branch.
   The ticket is closed, if the problem is not reproduced with modern version.
   -->
 - [x] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as archive to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->