Python: OpenCV: SURF

30 10 2012

20121030

OS: Ubuntu 12.10

find feature descriptor by SURF
follow from http://opencv.willowgarage.com/documentation/python/feature_detection.html and
http://achuwilson.wordpress.com/2011/08/05/object-detection-using-surf-in-opencv-part-1/

code

#
# feature descriptor by SURF
# enu
#

import cv
im = cv.LoadImageM(“cappucinno2.jpg”, cv.CV_LOAD_IMAGE_GRAYSCALE)
#(keypoints, descriptors) = cv.ExtractSURF(im, None, cv.CreateMemStorage(), (0, 30000, 3, 1))
(keypoints, descriptors) = cv.ExtractSURF(im, None, cv.CreateMemStorage(), (0,10000,3, 1))
print len(keypoints), len(descriptors)

for ((x, y), laplacian, size, dir, hessian) in keypoints:
print “x=%d y=%d laplaian=%d size=%d dir=%f hessian=%f” % (x, y, laplacian, size, dir, hessian)
#cv.Circle(im,(int(x),int(y)), 20, cv.Scalar(0,255,0))

img = cv.LoadImageM(“cappucinno2.jpg”,cv.CV_LOAD_IMAGE_COLOR)
for i in keypoints:
x,y = int(i[0][0]),int(i[0][1])
size = i[2]
cv.Circle(img,(x,y), size, cv.Scalar(0,255,0))

cv.NamedWindow(‘1.2 Image’, cv.CV_WINDOW_AUTOSIZE)
cv.ShowImage(‘1.2 Image’, img)
cv.WaitKey(0)

Image


Actions

Information

One response

31 10 2012
enumap

ตอนนี้มี openCV บน window 64bit แล้วนะ
ได้ผลเหมือนกันเลย เขียนเหมือนกันด้วย
ต่างกันที่ อ้างอิงที่อยู่ของไฟล์ภาพ

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: