ORB 演示代码位于https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_feature2d/py_orb/py_orb.html https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_feature2d/py_orb/py_orb.html
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('simple.jpg',0)
# Initiate STAR detector
orb = cv2.ORB()
# find the keypoints with ORB
kp = orb.detect(img,None)
# compute the descriptors with ORB
kp, des = orb.compute(img, kp)
# draw only keypoints location,not size and orientation
img2 = cv2.drawKeypoints(img,kp,color=(0,255,0), flags=0)
plt.imshow(img2),plt.show()
at kp = orb.detect(img,None)
- 在Python3.6中出现错误
[WinError 10054] An existing connection was forcibly closed by the remote host
- 在Python3.8中出现错误
cv2.error: Unknown C++ exception from OpenCV code
Note:
- 在 Python 3.6 中,在终端中运行或在调试器中运行,只需退出脚本而不会出现错误。仅当停在
kp = orb.detect(img,None)
在调试器中并在调试器中运行该行是否出现错误[WinError 10054] An existing connection was forcibly closed by the remote host
- 在Python 3.8中,在终端或调试器中运行会出现错误
cv2.error: Unknown C++ exception from OpenCV code
环境:Windows 10、Python 3.6、VSCode
有人有线索吗?
该教程已经过时了。
更新后的版本现在位于 OpenCV 网站本身中:https://docs.opencv.org/master/d1/d89/tutorial_py_orb.html https://docs.opencv.org/master/d1/d89/tutorial_py_orb.html
正如评论中提到的,其中指出应该进行初始化orb = cv.ORB_create()
:
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
img = cv.imread('simple.jpg',0)
# Initiate ORB detector
orb = cv.ORB_create()
# find the keypoints with ORB
kp = orb.detect(img,None)
# compute the descriptors with ORB
kp, des = orb.compute(img, kp)
# draw only keypoints location,not size and orientation
img2 = cv.drawKeypoints(img, kp, None, color=(0,255,0), flags=0)
plt.imshow(img2), plt.show()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)