opencvcorner-detection

How to detect only corners that has four quadrants


Opencv or any other image processing libs usually provide Harris corner detector, and it detects both corners types shown below:

enter image description here enter image description here

What would be the best way to only detect the first corner that has 4 quadrants and avoid the second type?


Solution

  • Is this useless?

    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