如何在带有Python的openCV 3中使用STAR检测器? [英] How to use STAR detector in openCV 3 with python?

查看:356
本文介绍了如何在带有Python的openCV 3中使用STAR检测器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在openCV 3中使用STAR检测器,并且抛出错误:

I'm trying to use the STAR detector in openCV 3, and it's throwing an error:

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

这是图片:

在python 3.5和anaconda的64位ubuntu 16.04LTS上运行.

Running on ubuntu 16.04LTS 64-bit with python 3.5 and anaconda.

推荐答案

您收到的错误代码-213表示STAR检测器未实现detectAndCompute方法.这是因为STAR只是一个特征检测器,而不是组合检测器和描述符.您可以通过调用detect方法来修复您的代码:

The error code -213 you are receiving indicates that the detectAndCompute method is not implemented for the STAR detector. That is because STAR is only a feature detector, not a combination detector and descriptor. Your code can be fixed by calling the detect method instead:

kps = star.detect(gray)

这篇关于如何在带有Python的openCV 3中使用STAR检测器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆