Skip to content

Instantly share code, notes, and snippets.

@PallawiSinghal
Created March 12, 2019 07:31
Show Gist options
  • Save PallawiSinghal/98fc5dbbfd6a355190eb77cc224542f2 to your computer and use it in GitHub Desktop.
Save PallawiSinghal/98fc5dbbfd6a355190eb77cc224542f2 to your computer and use it in GitHub Desktop.
import cv2
import numpy as np
filename = '/dog_clip.png'
img = cv2.imread(filename)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0.04)
#result is dilated for marking the corners, not important
dst = cv2.dilate(dst,None)
# Threshold for an optimal value, it may vary depending on the image.
img[dst>0.0001*dst.max()]=[0,0,255]
cv2.imshow('dst',img)
cv2.imwrite("corner.png",img)
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment