How to include cv.undistortPoints() when building opencv.js?

How to include cv.undistortPoints() when building opencv.js?
Is there any tutorial or document?

opencv.js uses a transpiler. there is a whitelist of functions within OpenCV that were manually verified to transpile successfully.

if undistortPoints isn’t in there already, you could add it and try the build.

here’s the whitelist:

my opencv. version is 4.5.4
my opencv_js.config.py is below;

# Classes and methods whitelist

core = {
    '': [
        'absdiff', 'add', 'addWeighted', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'cartToPolar',
        'compare', 'convertScaleAbs', 'copyMakeBorder', 'countNonZero', 'determinant', 'dft', 'divide', 'eigen',
        'exp', 'flip', 'getOptimalDFTSize','gemm', 'hconcat', 'inRange', 'invert', 'kmeans', 'log', 'magnitude',
        'max', 'mean', 'meanStdDev', 'merge', 'min', 'minMaxLoc', 'mixChannels', 'multiply', 'norm', 'normalize',
        'perspectiveTransform', 'polarToCart', 'pow', 'randn', 'randu', 'reduce', 'repeat', 'rotate', 'setIdentity', 'setRNGSeed',
        'solve', 'solvePoly', 'split', 'sqrt', 'subtract', 'trace', 'transform', 'transpose', 'vconcat',
        'setLogLevel', 'getLogLevel',
    ],
    'Algorithm': [],
}

imgproc = {
    '': [
        'Canny',
        'undistortPoints'
    ],
}





calib3d = {
    '': [
        'projectPoints',
        'undistortPoints',

        # cv::fisheye namespace
        'undistortPoints',
    ],
}

white_list = makeWhiteList([core, imgproc, calib3d])

# namespace_prefix_override['dnn'] = ''  # compatibility stuff (enabled by default)
# namespace_prefix_override['aruco'] = ''  # compatibility stuff (enabled by default)

after build

emcmake python ./opencv-4.5.4/platforms/js/build_js.py build_js

i can use cv.projectPoints /cv.Canny;
but cv. undistortPoints is undefined;

Where did I go wrong?

my opencv. version is 4.5.4
my opencv_js.config.py is below;

# Classes and methods whitelist

core = {
    '': [
        'absdiff', 'add', 'addWeighted', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'cartToPolar',
        'compare', 'convertScaleAbs', 'copyMakeBorder', 'countNonZero', 'determinant', 'dft', 'divide', 'eigen',
        'exp', 'flip', 'getOptimalDFTSize','gemm', 'hconcat', 'inRange', 'invert', 'kmeans', 'log', 'magnitude',
        'max', 'mean', 'meanStdDev', 'merge', 'min', 'minMaxLoc', 'mixChannels', 'multiply', 'norm', 'normalize',
        'perspectiveTransform', 'polarToCart', 'pow', 'randn', 'randu', 'reduce', 'repeat', 'rotate', 'setIdentity', 'setRNGSeed',
        'solve', 'solvePoly', 'split', 'sqrt', 'subtract', 'trace', 'transform', 'transpose', 'vconcat',
        'setLogLevel', 'getLogLevel',
    ],
    'Algorithm': [],
}

imgproc = {
    '': [
        'Canny',
        'undistortPoints'
    ],
}





calib3d = {
    '': [
        'projectPoints',
        'undistortPoints',

        # cv::fisheye namespace
        'undistortPoints',
    ],
}

white_list = makeWhiteList([core, imgproc, calib3d])

# namespace_prefix_override['dnn'] = ''  # compatibility stuff (enabled by default)
# namespace_prefix_override['aruco'] = ''  # compatibility stuff (enabled by default)

after build

emcmake python ./opencv-4.5.4/platforms/js/build_js.py build_js

i can use cv.projectPoints /cv.Canny;
but cv. undistortPoints is undefined;

Where did I go wrong?

you have undistortPoints once in imgproc and twice in calib3d. why? it seems to me that the code expects it once in total.

Sorry, I forgot to delete two undistortpoints, I found that undistortpoints in the 4.5.4 version in the CALIB3D package, but I contain undistortpoints in the configuration, still can’t use this function。Will you use when you pack some methods that are not included in OpenCV_JS.Config.py?