kyamagu / mexopencv

Collection and a development kit of matlab mex functions for OpenCV library
http://kyamagu.github.io/mexopencv
Other
661 stars 319 forks source link

When matlab file execute sample file #428

Closed krishnakumarrs closed 5 years ago

krishnakumarrs commented 5 years ago

i tried to run findhomography.m file from sample i get this error message No appropriate method, property, or field 'defaultNorm' for class 'cv.FeatureDetector'.

please help.

thanks

amroamroamro commented 5 years ago

I'm not sure which findhomography.m sample you're referring to?

krishnakumarrs commented 5 years ago

this file https://github.com/kyamagu/mexopencv/blob/master/samples/feature_homography_demo.m

krishnakumarrs commented 5 years ago

shows error on this line 'NormType',detector.defaultNorm()); line number 89

amroamroamro commented 5 years ago

Did you make any changes to the sample by any chance? cv.FeatureDetector class is not explicitly used in that demo.

Anyway note how the detector object was created from one of the classes cv.SURF, cv.SIFT, cv.ORB, cv.AKAZE, etc, which are both feature detectors and descriptor extractors at the same time.

In other words:

obj = cv.SURF();
[kpts,descs] = obj.detectAndCompute(img);

is equivalent to:

detector = cv.FeatureDetector('SURF');
extractor = cv.DescriptorExtractor('SURF');
kpts = detector.detect(img);
descs = extractor.compute(img, kpts);

This also applies to defaultNorm as well, which is really a method of descriptor extractors, not feature detectors (it tells you what distance function is appropriate for doing matching on the computed descriptors).

I should point out that SIFT and SURF are part of the contrib modules, so they are only available if you built mexopencv with opencv_contrib support.

krishnakumarrs commented 5 years ago

I have used opencv_contrib but when i looked into the detector class there is no name defaultNorm. And also even if i use cv.imread or cv.SIFT it gives me error. Is there anything i need to do. thanks for reply.

amroamroamro commented 5 years ago

As I explained in my previous comment, defaultNorm is a method of DescriptorExtractor not FeatureDetector. If you want to modify the sample as you did, you need to create two objects one for each of those classes (detector and extractor).

If you revert your changes, the demo should work as is: http://amroamroamro.github.io/mexopencv/opencv/feature_homography_demo.html

krishnakumarrs commented 5 years ago

Thanks