4

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)

  • in Python3.6 errors out with [WinError 10054] An existing connection was forcibly closed by the remote host
  • in Python3.8 errors out with cv2.error: Unknown C++ exception from OpenCV code

Note:

  • In Python 3.6, running in the terminal, or running in the debugger, simply exits the script with no error. Only when stopping at 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
  • In Python 3.8, running in terminal or the debugger gives the error cv2.error: Unknown C++ exception from OpenCV code

Environment: Windows 10, Python 3.6, VSCode

Does anyone have a clue?

1
  • 2
    When I use ORB, I initiate it with cv2.ORB_create() Commented May 14, 2021 at 1:38

1 Answer 1

5

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.