gpt4 book ai didi

python - OpenCV Python 示例错误

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:04 25 4
gpt4 key购买 nike

我正在尝试运行 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

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

最佳答案

找到解决方案:我在 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

关于python - OpenCV Python 示例错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10764895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com