赞
踩
图像特征就是指有意义的图像区域,具有独特性,易于识别性,比如角点、斑点以及高密度区
Harris点
API
import cv2 as cv
import numpy as np
# 读取文件
img = cv.imread(r'C:\Users\Administrator\Desktop\hello.jpg')
# 灰度化
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# Harris角点检测
dst = cv.cornerHarris(gray,blockSize=2, ksize=3, k=0.04)
img[dst > 0.01*dst.max()] = [0, 0, 255]
cv.imshow('harris', img)
cv.waitKey(0)
goodFeaturesToTrack(img,maxCorners,…)
import cv2 as cv
import numpy as np
# 读取文件
img = cv.imread(r'C:\Users\Administrator\Desktop\hello.jpg')
# 灰度化
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# Harris角点检测
# dst = cv.cornerHarris(gray,blockSize=2, ksize=3, k=0.04)
# shi-Tomasi角点检测
corners = cv.goodFeaturesToTrack(gray, maxCorners=1000, qualityLevel=0.01, minDistance=10)
# img[dst > 0.01*dst.max()] = [0, 0, 255]
corners= np.int0(corners)
print(corners)
for i in corners:
x, y = i.ravel()
cv.circle(img, (x, y), 3, (0, 255, 0),-1)
cv.imshow('harris', img)
cv.waitKey(0)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。