-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdgeDete.py
38 lines (28 loc) · 855 Bytes
/
EdgeDete.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
# Python program for Edge detection
# using OpenCV libraries
# using Sobel edge detection
# and laplacian method
import cv2
import numpy as np
# Capture livestream video content from camera 0
cap = cv2.VideoCapture(0)
while True:
# Take each frame
ret, frame = cap.read()
# Convert to HSV for simpler calculations
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
# Calcution of Sobelx
sobelx = cv2.Sobel(frame, cv2.CV_64F, 1, 0, ksize=5)
# Calculation of Sobely
sobely = cv2.Sobel(frame, cv2.CV_64F, 0, 1, ksize=5)
# Calculation of Laplacian
laplacian = cv2.Laplacian(frame, cv2.CV_64F)
cv2.imshow('sobelx', sobelx)
cv2.imshow('sobely', sobely)
cv2.imshow('laplacian', laplacian)
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()
# release the frame
cap.release()