操作可以找到一张图片中突出点的,比如周围都是黑色像素的一个白色像素将被找到
import cv2.cv as cv
#load image
filename = "../Video/cat.jpg"
image = cv.LoadImage(filename)
#create one window
win_name = "test"
cv.NamedWindow(win_name)
win2_name = "test2"
cv.NamedWindow(win2_name)
cv.ShowImage(win2_name, image)
#set created image
size = cv.GetSize(image)#(100, 100)
depth = 8
channels = 1
#grey operate
grey = cv.CreateImage(size, depth, channels)#create one 100x100 single channels image
cv.CvtColor(image, grey, cv.CV_BGR2GRAY)
#create the wanted images
eig = cv.CreateImage(cv.GetSize(grey), 32, 1)
temp = cv.CreateImage(cv.GetSize(grey), 32, 1)
#the default parameters
qualityLevel = 0.01
min_Distance = 10
#search the good points
features = cv.GoodFeaturesToTrack(grey, eig, temp, 100, qualityLevel, min_Distance, None, 3, 0, 0.04)
for (x,y) in features:
#print ("Good feature a:", x ,',' , y)
cv.Circle(image, (int(x), int(y)), 2, (255,0,0), -1, 8, 0)
cv.ShowImage(win_name, image)
cv.WaitKey()
cv.DestroyAllWindows()
处理结果