import cv filename = "burke94.jpg" # replace w/ your filename grayImage = cv.LoadImage(filename, 2) eigImage = cv.CreateImage(cv.GetSize(grayImage), cv.IPL_DEPTH_32F, 1) tempImage = cv.CreateImage(cv.GetSize(grayImage), cv.IPL_DEPTH_32F, 1) cornerMem = [] cornerCount = 300 qualityLevel = 0.1 minDistance = 5 cornerMem = cv.GoodFeaturesToTrack(grayImage, eigImage, tempImage, cornerCount, qualityLevel, minDistance, None, 3, False) print len(cornerMem), " corners found" print cornerMem for point in cornerMem: center = int(point[0]), int(point[1]) cv.Circle(colorImage, (center), 2, (0,255,255)) cv.SaveImage("savedcolor.jpg",colorImage)
Open Source, Embedded Systems, Computer Vision, Computational Photography, Self-Improvement
Tuesday, October 12, 2010
Good Features to Track using OpenCV and Python
Labels:
corner detection,
Good features to track,
Harris,
opencv,
python
Subscribe to:
Post Comments (Atom)
Unfortunately, the codes does not compile. colorImage is not defined.
ReplyDeleteOh dear, I just realized that. GFtT works on grayscale image converted from the original color image. The pointer colorImage should point to a copy of the original image. If the statement colorImage = cv.LoadImage(filename, ??) is inserted as Line 2 it should work but I'm not working with OpenCV at the moment to find the exact value for the second paramete.
ReplyDeleteThanks for the code. It works if you add this:
ReplyDeleteimport cv
filename = "lenna.png" # replace w/ your filename
colorImage = cv.LoadImage(filename, cv.CV_LOAD_IMAGE_COLOR) #additional line
grayImage = cv.LoadImage(filename, cv.CV_LOAD_IMAGE_GRAYSCALE) #optional, I just change it slightly to match up the top part
eigImage = cv.CreateImage(cv.GetSize(grayImage), cv.IPL_DEPTH_32F, 1)
tempImage = cv.CreateImage(cv.GetSize(grayImage), cv.IPL_DEPTH_32F, 1)