Ask Your Question
0

How to use BOWImgDescriptorExtractor in python - openCV ?

asked 2015-10-01 23:54:51 -0600

Akanksha gravatar image

Hi,

I am a beginner to openCV and am trying to use python-openCV. I have version 2.4.10. In this I am trying to use the BOWImgDescriptorExtractor as follows :

extractor = cv2.BOWImgDescriptorExtractor(cv2.SURF(), cv2.BFMatcher(cv2.NORM_L2))

and am getting the following error :

extractor = cv2.BOWImgDescriptorExtractor(cv2.SURF(), cv2.BFMatcher(cv2.NORM_L2)) TypeError: Expected cv::DescriptorExtractor for argument 'dextractor'

Not sure how to resolve this since the namespace convention is not used in python.

edit retag flag offensive close merge delete

Comments

can you try:

detect = cv2.FeatureDetector_create("SURF")

and pass that to the BOWImgDescriptorExtractor ?

berak gravatar imageberak ( 2015-10-02 01:36:19 -0600 )edit

I tried this but I still get the same error .

Akanksha gravatar imageAkanksha ( 2015-10-02 02:40:01 -0600 )edit

shame, i only got ocv3 here, can't really test your situation

berak gravatar imageberak ( 2015-10-02 02:41:57 -0600 )edit

can you check, what cv2.SURF() or cv2.FeatureDetector_create("SURF") return ?

(did you build the cv2.pyd ? maybe your weird distro ripped it out again)

berak gravatar imageberak ( 2015-10-02 06:30:42 -0600 )edit

The value returned by these is of the following type - <type 'cv2.SURF'> and <type 'cv2.FeatureDetector'>. I did not build the cv2.pyd but used the one already provided. I was facing issues building and using opencv3.0 in windows in python so I switched to 2.4.10 because it does not separate SIFT and SURF into opencv_contrib that require building. I even used the pre-built binaries provided at http://www.lfd.uci.edu/~gohlke/python... (2.4.12) and it gave the same error as above.

Akanksha gravatar imageAkanksha ( 2015-10-03 02:56:48 -0600 )edit

Thank you for your inputs Berak.I tried and searched on google a fair bit to figure out the issue here but could not resolve it. So, I complied opencv3.0 and switched to it. opencv3.0 for python seems to work without any issues :)

Akanksha gravatar imageAkanksha ( 2015-10-03 23:44:04 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-11-15 00:12:49 -0600

briansrls gravatar image

updated 2015-11-15 00:13:16 -0600

I know this is a bit late, but this should solve the issue for me.

sift2 = cv2.DescriptorExtractor_create("SIFT")
bowDiction = cv2.BOWImgDescriptorExtractor(sift2, cv2.BFMatcher(cv2.NORM_L2))

I believe the problem is that sift is not only a descriptor extractor, but also a feature finder. So, sending this function only cv2.SURF() or cv2.SIFT() will not be the appropriate type. Send it the descriptor extractor portion of your favorite feature detector (replacing SIFT with SURF etc should work fine)

NOTE: This is using opencv 2.4.11

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-10-01 23:54:51 -0600

Seen: 2,606 times

Last updated: Nov 15 '15