Exemple #1
0
 def _get_feature(self, img, feature_type=0):
     '''
     Get features from give image.\n
     img: np.array\n
     feature_type: int, 0:ORB, 1:SIFT, 2:FAST+ORB descriptor\n
     return: keypoints, descriptor
     '''
     img = self._gaussian_filter(img)
     if feature_type == 0:
         # ORB
         orb = cv.ORB_create()
         kp, des = orb.detectAndCompute(img, None)
         return kp, des
     elif feature_type == 1:
         # SIFT
         sift = cv.xfeatures2d.SIFT_create()
         kp, des = sift.detectAndCompute(img, None)
         return kp, des
     elif feature_type == 2:
         # FAST corners + SIFT descriptors
         fast = cv.FastFeatureDetector_create()
         sift = cv.xfeatures2d.SIFT_create()
         kp = fast.detect(img)
         kp, des = sift.compute(img, kp)
         return kp, des
     else:
         print('Wrong feature type code!')
         return None
Exemple #2
0
def fast_corner_detect(image):
    gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
    gray = cv.GaussianBlur(gray, (9, 9), 25)  # sigma
    fast = cv.FastFeatureDetector_create()
    kp = fast.detect(gray, None)
    image = cv.drawKeypoints(image, kp, None, color=(255, 0, 0))
    cv.imshow('image for fast', image)
def fast_detection(image):
    fast = cv2.FastFeatureDetector_create()
    kp = fast.detect(image, None)
    fast.setNonmaxSuppression(0)
    image_with_keypoints = cv2.drawKeypoints(image,
                                             kp,
                                             None,
                                             color=(255, 0, 0))
    return image_with_keypoints
Exemple #4
0
 def FAST(self):
     img = cv2.imread(os.path.join(root, '..', 'static', 'photos', session['org_img']))
     gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
     fast = cv2.FastFeatureDetector_create(threshold=25)
     # find and draw the keypoints
     kp = fast.detect(gray, None)
     gray = cv2.drawKeypoints(gray, kp, None, color=(255, 0, 0))
     filename = str(randint(1000000000, 9999999999)) + session['org_img']
     cv2.imwrite(os.path.join(root, '..', 'static', 'photos', filename), gray)
     session['corner_img'] = filename
Exemple #5
0
import numpy as np
from cv2 import cv2

img = cv2.imread('resource/block_test.png', 0)

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

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

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

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

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

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

cv2.imshow('fast', img2)
cv2.imshow('fast nonmaxSuppression', img3)
Exemple #6
0
print("[INFO] computing Precision!")
correct_matches = int(
    input("Please enter the number of correct matches:        "))
incorrect_matches = 10 - correct_matches

coresponding_matches = len(matches[:10])

thePrecision[0, 1] = correct_matches / (correct_matches + incorrect_matches)
print("[INFO] BRISK was done...!")

# BRIEF ################################################################
print("[INFO] Starting BRIEF!")

# Making a instance of class FAST for feature detecting
FAST = cv2.FastFeatureDetector_create()
FAST.setThreshold(80)

print("[INFO] stage 1: extracting features!")
kp1 = FAST.detect(img1, None)
kp2 = FAST.detect(img2, None)

# showing keypoints in images
img11 = cv2.drawKeypoints(img1,
                          kp1,
                          None,
                          flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
img22 = cv2.drawKeypoints(img2,
                          kp2,
                          None,
                          flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
Exemple #7
0
    return matrix


#Calibration parameters for algorithm
STEPSIZE = 4
FPS_MULT = 1  #For very high FPS videos
SCALE = 1
FRAME_SIZE = (800, 600)
CMAT = ReadCameraMat(CMAT_GOPRO)

FPS = 30

if __name__ == '__main__':
    cap = cv2.VideoCapture(vid_path4)  #Change video path for different video
    fast = cv2.FastFeatureDetector_create(threshold=60,
                                          nonmaxSuppression=True,
                                          type=1)  #Feature Detector
    frame_counter = 1
    trajectory_map = np.zeros((800, 800, 3), dtype=np.uint8)
    featureList = ft.FeatureList([])  #List of actively Tracked Features
    roadFeatureList = ft.FeatureList([])

    # Initializations
    print(CMAT)
    update_flag = True
    camera_tf = np.eye(3)
    trans_f = [0, 0, 0]
    trans_f1 = trans_f
    trans_f_prev = trans_f
    trans = np.array([[0], [0], [0]])