harris
# -*- coding: utf-8 -*-
import sysimport cv2
import numpy as np# 加载图像
input_file = 'box.png'#sys.argv[1]
img = cv2.imread(input_file)
cv2.imshow('Input image', img)img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img_gray = np.float32(img_gray)# Harris 角点检测
img_harris = cv2.cornerHarris(img_gray, 7, 5, 0.04)# 放大图像
img_harris = cv2.dilate(img_harris, None)# 显示棱角
img[img_harris > 0.01 * img_harris.max()] = [0, 0, 0]cv2.imshow('Harris Corners', img)
cv2.waitKey()
标签:gray,显示,棱角,img,imshow,cv2,harris,240725,file
From: https://blog.51cto.com/u_15862653/11888521