我正在尝试运行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
请有人知道如何解决这个问题吗?
答案 0 :(得分: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