working feature extraction + knearest neighbour

This commit is contained in:
Jeena 2013-10-15 01:29:31 +02:00
parent 4b2bb43c62
commit 266ce7c5b0
139 changed files with 158 additions and 30 deletions

37
surf.py Normal file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env python
import cv2, sys
#Create object to read images from camera 0
#cam = cv2.VideoCapture(0)
#Initialize SURF object
surf = cv2.SURF(85)
#Set desired radius
rad = 2
#while True:
#Get image from webcam and convert to greyscale
#ret, img = cam.read()
fn = sys.argv[1]
gray = cv2.imread(fn, 0)
#gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#Detect keypoints and descriptors in greyscale image
keypoints, descriptors = surf.detect(gray)
#Draw a small red circle with the desired radius
#at the (x, y) location for each feature found
for kp in keypoints:
x = int(kp.pt[0])
y = int(kp.pt[1])
cv2.circle(img, (x, y), rad, (0, 0, 255))
#Display colour image with detected features
cv2.imshow("features", img)
#Sleep infinite loop for ~10ms
#Exit if user presses <Esc>
#if cv2.waitKey(10) == 27:
# break