Python Opencv Feature Detector Causes Segmentation Fault
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,
Solution 1:
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.
Solution 2:
I'm pretty sure cv2.FeatureDetector_create()
is really only in the C++ interface. You want to do something like this:
import numpy as np
import cv2
img = cv2.imread(img_path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
surf = cv2.SURF()
mask = np.uint8(np.ones(gray.shape))
surf_points = surf.detect(gray, mask)
Post a Comment for "Python Opencv Feature Detector Causes Segmentation Fault"