using OpenCV with python for descriptor extraction

来源:互联网 发布:java 输出helloworld 编辑:程序博客网 时间:2024/05/01 05:18

转自http://stackoverflow.com/questions/10799625/does-anyone-have-any-examples-of-using-opencv-with-python-for-descriptor-extract

Here's an example of some code I've written for extracting SURF features using Python 2.7 and OpenCV 2.4.

im2 = cv2.imread(imgPath)im = cv2.cvtColor(im2, cv2.COLOR_BGR2GRAY)surfDetector = cv2.FeatureDetector_create("SURF")surfDescriptorExtractor = cv2.DescriptorExtractor_create("SURF")keypoints = surfDetector.detect(im)(keypoints, descriptors) = surfDescriptorExtractor.compute(im,keypoints)

This works and returns a set of descriptors. Unfortunately since cv2.SURF() doesn't work in 2.4, you have to go through this tedious process.