如何仅检测具有四个象限的角

时间:2019-04-02 21:11:14

标签: opencv corner-detection

Opencv或任何其他图像处理库通常提供哈里斯拐角检测器,它可以检测到以下所示的两个拐角类型:

enter image description here enter image description here

仅检测具有四个象限的第一个角并避免第二个象限的最佳方法是什么?

1 个答案:

答案 0 :(得分:0)

这没用吗?

checkrer.png

enter image description here

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

enter image description here