Skip to content

Instantly share code, notes, and snippets.

@pknowledge
Created October 1, 2019 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pknowledge/b5cb86c8becef44fb3136ccb03a766d8 to your computer and use it in GitHub Desktop.
Save pknowledge/b5cb86c8becef44fb3136ccb03a766d8 to your computer and use it in GitHub Desktop.
Harris Corner Detector in OpenCV
import numpy as np
import cv2 as cv
img = cv.imread('chessboard_img.png')
cv.imshow('img', img)
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv.cornerHarris(gray, 2, 3, 0.04)
dst = cv.dilate(dst, None)
img[dst > 0.01 * dst.max()] = [0, 0, 255]
cv.imshow('dst', img)
if cv.waitKey(0) & 0xff == 27:
cv.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment