justadudewhohacks/opencv4nodejs

TypeError: SIFTDetector is not a constructor

Opened this issue · 3 comments

When i use SIFTDetector like:
const bf = new cv.BFMatcher(cv.NORM_L1, false);
const detector = new cv.SIFTDetector();
const matchFunc = (desc1, desc2) => bf.knnMatch(desc1, desc2,2);
const bfMatchIMG = matchFeatures({img1, img2, detector, matchFunc});

TypeError occurs:
TypeError: cv.SIFTDetector is not a constructor

Both of SIFTDetector and ORBDetector are defined in ./node_modules/opencv4nodejs/lib/typings/xxx.d.ts but only ORBDetector works fine.what wrong with it?

opencv4nodejs version: 5.6.0

Are you sure contrib modules were included during installation ? Algorithms such as SIFT and SURF are inside contrib modules.

Are you sure contrib modules were included during installation ? Algorithms such as SIFT and SURF are inside contrib modules.

I had a similar problem.I have checked CV. D and found that functions such as "ORBDETECTOR" and "SIFTDETECTOR" have not been exposed. Could you please tell me how to deal with them?

image

aiham commented

Thanks @lemoun

I found SIFTDetector is defined in the xfeatures2d module: https://github.com/justadudewhohacks/opencv4nodejs/blob/master/cc/xfeatures2d/SIFTDetector.h

So I added xfeatures2d to my auto build flags when installing (different to the main features2d module):

export OPENCV4NODEJS_AUTOBUILD_FLAGS=-DBUILD_LIST=core,imgproc,imgcodecs,videoio,highgui,video,calib3d,features2d,objdetect,dnn,ml,flann,photo,stitching,gapi,xfeatures2d