因为当下的计划是熟悉语言和库,而图像特征提取脱离理论就很没意思了,并且很可能事倍功半,所以计算机视觉特征提取这部分跳过,直接开始和深度学习结合较为紧密的目标检测&识别部分。
本节介绍了OpenCV3中提取图像角点特征的函数:
1 # coding=utf-8 2 import cv2 3 import numpy as np 4 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 for corner detection 16 #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)调整对结果影响如下:
取值为3时:
取值为23时:
时间: 2024-09-30 21:57:54