2

我正在尝试运行 opencv 中包含的示例之一:find_obj.py。OpenCV 版本:2.4 操作系统:ArchLinx

函数有错误:

flann = cv2.flann_Index(desc2, flann_params)

错误是:

File "find_obj2.py", line 27, in match_flann
    flann = cv2.flann_Index(desc2, flann_params)
TypeError: <unknown> is not a numpy array

请问有人知道如何解决这个问题吗?

4

1 回答 1

5

找到解决方案:我在 find_obj.py 中替换了以下行:

surf = cv2.SURF(1000)
kp1, desc1 = surf.detect(img1, None, False)
kp2, desc2 = surf.detect(img2, None, False)
desc1.shape = (-1, surf.descriptorSize())
desc2.shape = (-1, surf.descriptorSize())

和那些:

surf_det = cv2.FeatureDetector_create("SURF")
surf_ext = cv2.DescriptorExtractor_create("SURF")
kp1 = surf_det.detect(img1)
kp2 = surf_det.detect(img2)
kp1, desc1 = surf_ext.compute(img1, kp1)
kp2, desc2 = surf_ext.compute(img2, kp2)

希望这可以帮助别人......:D

于 2012-05-26T14:51:28.557 回答