一、OpenCV接口调用示意
介绍了OpenCV3中提取图像角点特征的函数:
1 # coding=utf-8
2 import cv23 import numpy asnp4
5
6 '''Harris算法角点特征提取'''
7
8 img = cv2.imread('chess_board.png')9 gray =cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)10 gray =np.float32(gray)11
12 # {标记点大小,敏感度(3~31,越小越敏感)}13 # OpenCV函数cv2.cornerHarris() 有四个参数 其作用分别为 :14 #img -Input image, it should be grayscale and float32 type.15 #blockSize - It is the size of neighbourhood considered forcorner detection16 #ksize -Aperture parameter of Sobel derivative used.17 #k - Harris detector free parameter in the equation,在0.04到0.05之间18 dst = cv2.cornerHarris(gray,2,23,0.04)19 img[dst>0.01 * dst.max()] = [0,0,255]20
21 cv2.imshow('corners',img)22 cv2.waitKey()23 cv2.destroyAllWindows()
dst = cv2.cornerHarris(gray,2,23,0.04)中第3个参数(23)调整对结果影响如下: