Skip to content

Instantly share code, notes, and snippets.

@antony-jr
Created August 23, 2020 06:32
Show Gist options
  • Save antony-jr/f6744e7cf0dca05ab178734a77c197ec to your computer and use it in GitHub Desktop.
Save antony-jr/f6744e7cf0dca05ab178734a77c197ec to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
try:
import numpy as np
import cv2
except:
print("Please install opencv-python and numpy via pip")
sys.exit(0)
if len(sys.argv) == 1:
print("Usage: {} [PATH TO INPUT IMAGE FILE]".format(sys.argv[0]))
sys.exit(0)
# Read the image from disk to memory
img = cv2.imread(sys.argv[1], 0)
# Canny Edge detect
edges = cv2.Canny(img,100,200)
cv2.imshow('Edge Detected Image', edges)
# Code to exit when Esc key is pressed.
while True:
key = cv2.waitKey(3000) # Pause program loop for 3 seconds
if key == 27:
cv2.destroyAllWindows()
break;
sys.exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment