openCV 图像基本操作(三)——图像特征提取(角点检测 harris)
代码如下所示:
import cv2
import numpy as np
img = cv2.imread('test_1.jpg')
print ('img.shape:',img.shape)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# gray = np.float32(gray)
dst = cv2.cornerHarris(gray, 2, 3, 0.04) # 执行焦点检测
print ('dst.shape:',dst.shape)
print ('dst',dst)
img[dst>0.01*dst.max()]=[0,0,255]
cv2.imshow('dst',img)
cv2.imwrite("dst.png",img)
cv2.waitKey(0)
cv2.destroyAllWindows()