python cv2 FastFeatureDetector

asked 2015-05-26 02:37:31 -0600

izzusan gravatar image

hi, I tried the simple find corner script but i have some error

AttributeError: 'module' object has no attribute 'FastFeatureDetector'

this is my script:

import numpy as np import cv2 import glob import json from matplotlib import pyplot as plt

class UndistortedImg:

data = "";

def __init__(self):
    with open('config.json') as data_file:    
        self.data = json.load(data_file);

def StartUndistortedImg(self, img):

    img = cv2.imread(img,0)

    # Initiate FAST object with default values
    fast = cv2.FastFeatureDetector()
    #fast = cv2.FeatureDetector_create('FAST')

    # find and draw the keypoints
    kp = fast.detect(img,None)
    img2 = cv2.drawKeypoints(img, kp, color=(255,0,0))

    # Print all default params
    print "Threshold: ", fast.getInt('threshold')
    print "nonmaxSuppression: ", fast.getBool('nonmaxSuppression')
    print "neighborhood: ", fast.getInt('type')
    print "Total Keypoints with nonmaxSuppression: ", len(kp)

    cv2.imwrite('fast_true.png',img2)

    # Disable nonmaxSuppression
    fast.setBool('nonmaxSuppression',0)
    kp = fast.detect(img,None)

    print "Total Keypoints without nonmaxSuppression: ", len(kp)

    img3 = cv2.drawKeypoints(img, kp, color=(255,0,0))

    cv2.imwrite('result/fast_false.png',img3)

which is the error?

the library work fine becouse i tried the script for Undistorted Img and work fine...

thank you--

edit retag flag offensive close merge delete

Comments

2

which opencv version is it ?

for 3.0, try: detector = cv2.FastFeatureDetector_create()

berak gravatar imageberak ( 2015-05-26 02:41:49 -0600 )edit