js: backport PR18985
authorSteffen Urban <urbste@googlemail.com>
Fri, 18 Dec 2020 12:01:48 +0000 (13:01 +0100)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Fri, 18 Dec 2020 12:12:10 +0000 (12:12 +0000)
original commit: b82700ae4104a527534e66d3eb91f9835bc7957b

doc/js_tutorials/js_setup/js_setup/js_setup.markdown
modules/js/generator/embindgen.py
platforms/js/opencv_js.config.py

index 435f06fe026d3c2154cfec4350c843a44128081e..55fd40fb7e0c8e5076965e8485c841925cb458bd 100644 (file)
@@ -127,6 +127,13 @@ Building OpenCV.js from Source
     python ./platforms/js/build_js.py build_js --build_test
     @endcode
 
+-#  [optional] To enable OpenCV contrib modules append `--cmake_option="-DOPENCV_EXTRA_MODULES_PATH=/path/to/opencv_contrib/modules/"`
+
+    For example:
+    @code{.bash}
+    python ./platforms/js/build_js.py build_js --cmake_option="-DOPENCV_EXTRA_MODULES_PATH=opencv_contrib/modules"
+    @endcode
+
 Running OpenCV.js Tests
 ---------------------------------------
 
index 6e2bac71a1c25d26dff9b1ef91342bafd4a2f19e..7eddb11ba2513895d21d3740ba4c35e789e0beaa 100644 (file)
@@ -634,8 +634,10 @@ class JSWrapperGenerator(object):
                     ret_type = type_dict[ptr_type]
             for key in type_dict:
                 if key in ret_type:
-                    ret_type = ret_type.replace(key, type_dict[key])
-
+                    # Replace types. Instead of ret_type.replace we use regular
+                    # expression to exclude false matches.
+                    # See https://github.com/opencv/opencv/issues/15514
+                    ret_type = re.sub('(^|[^\w])' + key + '($|[^\w])', type_dict[key], ret_type)
             if variant.constret and ret_type.startswith('const') == False:
                 ret_type = 'const ' + ret_type
             if variant.refret and ret_type.endswith('&') == False:
index bcbdcfdf967b65dc527b229c4aba83a9d0360d77..749624be88237fb43a068e52a9fcd707cb9e538a 100644 (file)
@@ -47,6 +47,8 @@ features2d = {'Feature2D': ['detect', 'compute', 'detectAndCompute', 'descriptor
               'BFMatcher': ['isMaskSupported', 'create'],
               '': ['drawKeypoints', 'drawMatches', 'drawMatchesKnn']}
 
-calib3d = {'': ['findHomography', 'estimateAffine2D', 'Rodrigues']}
+calib3d = {'': ['findHomography', 'calibrateCameraExtended', 'drawFrameAxes', 'estimateAffine2D', \
+                'getDefaultNewCameraMatrix', 'initUndistortRectifyMap', 'Rodrigues', \
+                'solvePnP', 'solvePnPRansac', 'solvePnPRefineLM']}
 
-white_list = makeWhiteList([core, imgproc, objdetect, video, dnn, features2d, calib3d])
\ No newline at end of file
+white_list = makeWhiteList([core, imgproc, objdetect, video, dnn, features2d, calib3d])