aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/personal/edgedetect
blob: 34d26c8a3a1405f637204010026483117b529106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/env python3

import sys
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt
from skimage.io import imread, imshow
from skimage.color import rgb2gray
from skimage.feature import match_template, peak_local_max
from skimage import transform

def detect():
  #img = cv.imread(cv.samples.findFile(sys.argv[1]))
  #if img is None:
  #  sys.exit("Could not read the image.")
  #_,img = cv.threshold(img, 128, 255, cv.THRESH_BINARY)

  image= cv.imread(sys.argv[1])
  gray= cv.cvtColor(image, cv.COLOR_BGR2GRAY)
  gray= np.float32(gray)
  harris_corners= cv.cornerHarris(gray, 3, 3, 0.05)
  kernel= np.ones((7,7), np.uint8)
  harris_corners= cv.dilate(harris_corners, kernel, iterations= 2)
  image[harris_corners > 0.025 * harris_corners.max()]= [255,127,127]
  cv.imshow('Harris Corners', image)
  cv.waitKey(0)
  cv.destroyAllWindows()
  

if __name__ == "__main__":
  detect()