Как обнаружить только те углы, которые имеют четыре квадранта - PullRequest
0 голосов
/ 03 апреля 2019

Opencv или любые другие библиотеки обработки изображений обычно предоставляют детектор углов Harris, и он обнаруживает оба типа углов, показанных ниже:

enter image description here enter image description here

Каков наилучший способ обнаружить только первый угол с четырьмя квадрантами и избежать второго типа?

1 Ответ

0 голосов
/ 03 апреля 2019

Это бесполезно?

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

...