如何在openCV 3中与python一起使用星检测器?
我试图在openCV 3中使用星光检测器,但它抛出了一个错误:如何在openCV 3中与python一起使用星检测器?,python,python-3.x,opencv,opencv3.0,Python,Python 3.x,Opencv,Opencv3.0,我试图在openCV 3中使用星光检测器,但它抛出了一个错误: import cv2 image = cv2.imread('grand_central_terminal.png') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) star = cv2.xfeatures2d.StarDetector_create() (kps, descs) = star.detectAndCompute(gray, None) print("# of key
import cv2
image = cv2.imread('grand_central_terminal.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
star = cv2.xfeatures2d.StarDetector_create()
(kps, descs) = star.detectAndCompute(gray, None)
print("# of keypoints: {}".format(len(kps))) # should be 459
它给出的错误是:
Traceback (most recent call last):
File "quiz.py", line 8, in <module>
(kps, descs) = star.detectAndCompute(gray, None)
cv2.error: /home/travis/miniconda/conda-bld/work/opencv-3.1.0/modules/features2d/src/feature2d.cpp:144: error: (-213) in function detectAndCompute
回溯(最近一次呼叫最后一次):
文件“quick.py”,第8行,在
(kps,descs)=星型检测和计算(灰色,无)
cv2.error:/home/travis/miniconda/conda bld/work/opencv-3.1.0/modules/features2d/src/feature2d.cpp:144:函数检测和计算中的错误:(-213)
图为:
使用Python3.5和anaconda在ubuntu 16.04LTS 64位上运行。-213您收到的错误代码表明星探测器没有实现
detectAndCompute
方法。这是因为恒星只是一个特征检测器,而不是一个组合检测器和描述符。可以通过调用detect
方法来修复代码:
kps = star.detect(gray)
我明白了,那么star.detectAndCompute应该如何工作呢?star.detectAndCompute不应该工作。这似乎是一个不幸的事故——这种方法根本不存在。
xfeature2d
模块中的某些东西既是检测器又是描述符(如ORB或SIFT),它们利用了detect和compute
。STAR只是一个特征检测器,但不会计算这些关键点的描述符。