如何仅检测具有四个象限的角
How to detect only corners that has four quadrants
Opencv 或任何其他图像处理库通常提供 Harris 角点检测器,它检测如下所示的两种角点类型:
仅检测具有 4 个象限的第一个角并避免第二种类型的最佳方法是什么?
这个没用吗?
checkrer.png
import cv2
import numpy as np
filename = 'checker.png'
img = cv2.imread(filename)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
## Harris corner detector
gray_f = np.float32(gray)
dst = cv2.cornerHarris(gray_f,2,3,0.04)
dst = cv2.dilate(dst,None)
corner = dst>0.01*dst.max()
# Image for confirmation
# corner_img = img.copy()
# corner_img[corner] = [0,0,255]
# cv2.imwrite("corner.png", corner_img)
## low brightness area
ksize = (20, 20)
blue = cv2.blur(gray, ksize)
low = blue<150
# Image for confirmation
# low_img = img.copy()
# low_img[low] = [0,0,255]
# cv2.imwrite("low.png", low_img)
## cross point
cross_point = corner * low
# Image for confirmation
cross_img = img.copy()
cross_img[cross_point] = [0,0,255]
cv2.imwrite("cross.png", cross_img)
cross.png
Opencv 或任何其他图像处理库通常提供 Harris 角点检测器,它检测如下所示的两种角点类型:
仅检测具有 4 个象限的第一个角并避免第二种类型的最佳方法是什么?
这个没用吗?
checkrer.png
import cv2
import numpy as np
filename = 'checker.png'
img = cv2.imread(filename)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
## Harris corner detector
gray_f = np.float32(gray)
dst = cv2.cornerHarris(gray_f,2,3,0.04)
dst = cv2.dilate(dst,None)
corner = dst>0.01*dst.max()
# Image for confirmation
# corner_img = img.copy()
# corner_img[corner] = [0,0,255]
# cv2.imwrite("corner.png", corner_img)
## low brightness area
ksize = (20, 20)
blue = cv2.blur(gray, ksize)
low = blue<150
# Image for confirmation
# low_img = img.copy()
# low_img[low] = [0,0,255]
# cv2.imwrite("low.png", low_img)
## cross point
cross_point = corner * low
# Image for confirmation
cross_img = img.copy()
cross_img[cross_point] = [0,0,255]
cv2.imwrite("cross.png", cross_img)
cross.png