Python cv2.FastFeatureDetector_create() Examples

The following are 7 code examples of cv2.FastFeatureDetector_create(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cv2 , or try the search function .
Example #1
Source File: 04_fast_feature.py    From Practical-Computer-Vision with MIT License 8 votes vote down vote up
def compute_fast_det(filename, is_nms=True, thresh = 10):

    img = cv2.imread(filename)
    
    # Initiate FAST object with default values
    fast = cv2.FastFeatureDetector_create() #FastFeatureDetector()

    # find and draw the keypoints
    if not is_nms:
        fast.setNonmaxSuppression(0)

    fast.setThreshold(thresh)

    kp = fast.detect(img,None)
    cv2.drawKeypoints(img, kp, img, color=(255,0,0))
    
    return img 
Example #2
Source File: optical_flow.py    From self-driving with MIT License 5 votes vote down vote up
def __init__(self, videoSource, featurePtMask=None, verbosity=0):
    # cap the length of optical flow tracks
    self.maxTrackLength = 10

    # detect feature points in intervals of frames; adds robustness for
    # when feature points disappear.
    self.detectionInterval = 5

    # Params for Shi-Tomasi corner (feature point) detection
    self.featureParams = dict(
        maxCorners=500,
        qualityLevel=0.3,
        minDistance=7,
        blockSize=7
    )
    # Params for Lucas-Kanade optical flow
    self.lkParams = dict(
        winSize=(15, 15),
        maxLevel=2,
        criteria=(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 0.03)
    )
    # # Alternatively use a fast feature detector
    # self.fast = cv2.FastFeatureDetector_create(500)

    self.verbosity = verbosity

    (self.videoStream,
     self.width,
     self.height,
     self.featurePtMask) = self._initializeCamera(videoSource) 
Example #3
Source File: klt.py    From imips_open with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, target_n, nonmax_radius):
        self._scorer = cv2.FastFeatureDetector_create()
        self._target_n = target_n
        self._nonmax_radius = nonmax_radius 
Example #4
Source File: klt.py    From sips2_open with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, target_n, nonmax_radius):
        self._scorer = cv2.FastFeatureDetector_create()
        self._target_n = target_n
        self._nonmax_radius = nonmax_radius 
Example #5
Source File: visual_odometry.py    From Monocular-Visual-Inertial-Odometry with MIT License 5 votes vote down vote up
def __init__(self, cam):
		self.frame_stage = 0
		self.cam = cam
		self.new_frame = None
		self.last_frame = None
		self.cur_R = None
		self.cur_t = None
		self.px_ref = None
		self.px_cur = None
		self.focal = cam.fx
		self.pp = (cam.cx, cam.cy)
		#self.trueX, self.trueY, self.trueZ = 0, 0, 0
		self.detector = cv2.FastFeatureDetector_create(threshold=25, nonmaxSuppression=True)
		#with open('poses.txt') as f:
		#	self.annotations = f.readlines() 
Example #6
Source File: loaders.py    From hfnet with MIT License 5 votes vote down vote up
def fast_loader(image, name, **config):
    num_features = config.get('num_features', 0)
    do_nms = config.get('do_nms', False)
    nms_thresh = config.get('nms_thresh', 4)

    fast = cv2.FastFeatureDetector_create()
    kpts = fast.detect(image.astype(np.uint8), None)
    kpts, scores = keypoints_cv2np(kpts)
    if do_nms:
        keep = nms_fast(kpts, scores, image.shape[:2], nms_thresh)
        kpts, scores = kpts[keep], scores[keep]
    if num_features:
        keep_indices = np.argsort(scores)[::-1][:num_features]
        kpts, scores = [i[keep_indices] for i in [kpts, scores]]
    return {'keypoints': kpts, 'scores': scores} 
Example #7
Source File: 04_sift_features.py    From Practical-Computer-Vision with MIT License 4 votes vote down vote up
def compute_fast_det(img, is_nms=True, thresh = 10):
    gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

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

#     # find and draw the keypoints
    if not is_nms:
        fast.setNonmaxSuppression(0)

    fast.setThreshold(thresh)

    kp = fast.detect(img,None)
    cv2.drawKeypoints(img, kp, img, color=(255,0,0))
    
    

    sift = cv2.SIFT()
    kp = sift.detect(gray,None)

    img=cv2.drawKeypoints(gray,kp)

    plt.figure(figsize=(12, 8))
    plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
    plt.axis('off')
    plt.show()