Python opencv特征检测器导致分段错误 [英] Python opencv feature detector causes segmentation fault

查看:327
本文介绍了Python opencv特征检测器导致分段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python 2.7和opencv 2.4.2版。我遇到了分段错误的问题。
以下是我尝试的代码:

I'm using Python 2.7 and opencv version 2.4.2. I'm having trouble with a segmentation fault. Here is the code I try:

import cv2
img = cv2.imread(img_path)
img2 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
detector = cv2.FeatureDetector_create("SURF") # or "SIFT"
kp  = detector.detect(img2)

最后一行导致分段错误,我不明白为什么。我知道至少有另一篇关于这个主题的帖子,即:有没有人有任何使用OpenCV和python进行描述符提取的例子?
但它似乎无法解决我的问题。

the last line causes a segmentation fault and I don't understand why. I realize there is at least another post on the subject, namely : Does anyone have any examples of using OpenCV with python for descriptor extraction? but it doesn't seem to solve my problem.

任何帮助将不胜感激!谢谢!

Any help will be much appreciated! Thanks!

推荐答案

我正在使用Ubuntu 12.04,其中包括OpenCV 2.3.1。我想要一个更新版本的OpenCV,所以我找到了一个带有OpenCV 2.4.5反向端口的PPA。当我尝试使用I cv2.FeatureDetector_create(SURF) cv2.FeatureDetector_create(SIFT)时,我就像你一样遇到了分段错误。我意识到这两种方法都是非自由的,并且发现我的OpenCV安装缺少 libopencv-nonfree2.4 包。我切换到包含它的另一个PPA,这似乎解决了这个问题。

I'm using Ubuntu 12.04, which includes OpenCV 2.3.1. I wanted a newer version of OpenCV, so I found a PPA with an OpenCV 2.4.5 backport. When I tried to use I cv2.FeatureDetector_create("SURF") and cv2.FeatureDetector_create("SIFT"), I encountered the segmentation fault just as you did. I realized that both of these methods are nonfree, and observed that my OpenCV install was missing the libopencv-nonfree2.4 package. I switched to another PPA that includes it and this seems to have solved the problem.

这篇关于Python opencv特征检测器导致分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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