[Python] Why does the Harris corner detector can't detect finely corners of a chessboard?

Discussão em 'Python' iniciado por Stack, Janeiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use Harris method for corner detection on a chessboard but the result i'm getting is not good:

    [​IMG]

    In fact, I am facing the following problems:

    • All the corners are not detected (see image attached).
    • The dots that are marking the corners are not what I expected: I want these dots to be circular with one dot per detected corner.

    You can find my code below.

    import cv2 as cv
    import numpy as np

    file = chess.bmp
    img = cv.imread(file)
    img_gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
    img_gray = np.float32(img_gray)

    dst = cv.cornerHarris(img_gray, blockSize=2, ksize=3, k=0.02)

    dst = cv.dilate(dst, None)

    img[dst > 0.01 * dst.max()] = [0, 0, 255]

    cv.imshow("Corner detection", img)
    cv.waitKey()
    cv.destroyAllWindows()

    Continue reading...

Compartilhe esta Página