我在玩OpenCV中的cornerHarris函数。我不明白什么呢ksize,并k在功能上的意思。文档中提到ksize了存在Aperture parameter of Sobel derivative used和k存在,Harris detector free parameter in the equation但我不确定它的真正含义是什么?
有人可以帮我理解吗?
我试图检测立方体中的角,结果是:
使用我在文档中使用的简单代码:
import cv2
import numpy as np
filename = "cube.jpg"
img = cv2.imread("./images/{}".format(filename))
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv2.cornerHarris(gray,12,3,0.04)
dst = cv2.dilate(dst,None)
# Threshold for an optimal value, it may vary depending on the image.
img[dst>0.01*dst.max()]=[0,0,255]
cv2.imshow('dst',img)
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
我尝试进行调整,K但不了解它的作用,尽管我意识到将其增加到超过限制会导致检测到零角。
我一直在阅读有关cornerHarrisOpenCV 的内容。我通读了文档,但我不确定这个函数返回什么。
在阅读示例时,有一条语句写为:
dst = cv2.cornerHarris(gray,2,3,0.04)
img[dst>0.01*dst.max()]=[0,0,255]
Run Code Online (Sandbox Code Playgroud)
我只是无法理解上面的第二个语句,可能是因为我不明白,cornerHarris实际上返回的是什么。
我确实感觉到应用了某种阈值,但我无法解释。