Reputation: 1483
ORB Demo code at 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)
[WinError 10054] An existing connection was forcibly closed by the remote host
cv2.error: Unknown C++ exception from OpenCV code
Note:
kp = orb.detect(img,None)
in the debugger and running that line in the debugger does the error appear [WinError 10054] An existing connection was forcibly closed by the remote host
cv2.error: Unknown C++ exception from OpenCV code
Environment: Windows 10, Python 3.6, VSCode
Does anyone have a clue?
Upvotes: 4
Views: 16004
Reputation: 1483
That tutorial is outdated.
The updated version is now in OpenCV site itself: https://docs.opencv.org/master/d1/d89/tutorial_py_orb.html
which, as mentioned in comments, states that initialization should be done with 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()
Upvotes: 5