import numpy as np import cv2 from matplotlib import pyplot as plt img = cv2.imread('Hallway_3.jpg', cv2.IMREAD_COLOR) grayscale_img = None grayscale_img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) # #### ORB #### # Initiate STAR detector orb = cv2.ORB_create() # find the keypoints with ORB kp = orb.detect(img,None) # compute the descriptors with ORB kp, des = orb.compute(img, kp) # draw only keypoints location,not size and orientation orb_img = None orb_img = cv2.drawKeypoints(img,kp,orb_img,color=(255,0,0), flags=0) # #### Harris Corner #### gray = np.float32(grayscale_img) dst = cv2.cornerHarris(gray,2,3,0.04) #result is dilated for marking the corners, not important dst = cv2.dilate(dst,None) # Threshold for an optimal value, it may vary depending on the image. hc_img = img.copy() hc_img[dst>0.005*dst.max()]=[255,0,0] # #### Hough Lines using Canny Edge #### E = cv2.Canny(grayscale_img, 50, 200, 3) lines = cv2.HoughLinesP(E,rho = 1,theta = 1*np.pi/180,threshold = 80,minLineLength = 30,maxLineGap = 10) N = lines.shape[0] hough_img = img.copy() for i in range(N): x1 = lines[i][0][0] y1 = lines[i][0][1] x2 = lines[i][0][2] y2 = lines[i][0][3] cv2.line(hough_img,(x1,y1),(x2,y2),(255,0,0),3)