-
Notifications
You must be signed in to change notification settings - Fork 0
/
edge.py
48 lines (35 loc) · 948 Bytes
/
edge.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import cv2
import numpy as np
'''
def slider():
from Tkinter import *
master = Tk()
minval = Scale(master, from_=0, to=255)
minval.pack()
maxval = Scale(master, from_=0, to=255, orient=HORIZONTAL)
maxval.pack()
mainloop()
import threading
t = threading.Thread(target=slider)
t.start()
'''
def nothing(x):
pass
cap = cv2.VideoCapture(0)
cv2.namedWindow('image')
cv2.createTrackbar('Min Edge','image',100,255,nothing)
cv2.createTrackbar('Max Edge','image',200,255,nothing)
while(1):
# Take each frame
minval = cv2.getTrackbarPos('Min Edge','image')
#
maxval = cv2.getTrackbarPos('Max Edge','image')
_, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# adaptive threshold might be good here
edges = cv2.Canny(gray,minval,maxval)
cv2.imshow('image',cv2.pyrDown(edges))
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()