TypeError: cv.findNonZero is not a function

Hello, with latest 4.6.0 version of opencv.js i have the following error when using findNonZero function:

let src = cv.imread('canvasInput');
let dst = new cv.Mat();
cv.threshold(src, dst, 177, 200, cv.THRESH_BINARY);
let nonzero = new cv.Mat();
cv.findNonZero(dst, nonzero);

I get :

TypeError: cv.findNonZero is not a function

To reproduce, copy paste the example code to the “Try It” section in OpenCV: Image Thresholding

The findNonZero function is present in the api documentation, so i suppose it should be available in the js release, am i missing something?

the js wrappers do not cover the full opencv functionality, you can only use functions from the “whitelist” here:

as you can see, it has countNonZeros() but not findNonZeros()

if you’re able to build opencv.js locally, try to add it to the list, rebuild, and see, what happens

1 Like