Skip to content

Commit 8d241a8

Browse files
authored
Add files via upload
1 parent fb3f354 commit 8d241a8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Day11(edgedetection).py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import cv2
2+
3+
def canny_edge_detection(image):
4+
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
5+
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
6+
edges = cv2.Canny(blurred, 50, 150)
7+
return edges
8+
9+
cap = cv2.VideoCapture(0)
10+
11+
while True:
12+
ret, frame = cap.read()
13+
if not ret:
14+
break
15+
16+
edges = canny_edge_detection(frame)
17+
18+
cv2.imshow('Original', frame)
19+
cv2.imshow('Edges', edges)
20+
21+
if cv2.waitKey(1) & 0xFF == ord('q'):
22+
break
23+
24+
cap.release()
25+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)