-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.py
40 lines (29 loc) · 1.02 KB
/
camera.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
from cv2 import cv2 as cv
#Reescalating function works with wathever
def rescaleFrame(frame, scale=0.75):
width = int(frame.shape[1] * scale)
height = int(frame.shape[0] * scale)
dimensions = (width,height)
return cv.resize(frame, dimensions, interpolation=cv.INTER_AREA)
#life video
def changeRes(width, height):
capture.set(3,width)
capture.set(4,height)
#Reading Videos
capture = cv.VideoCapture(0)
while True:
isTrue, frame = capture.read()
cv.putText(frame, 'Hello World', (0,400), cv.FONT_HERSHEY_TRIPLEX, 1.0, (255,255,255), thickness=1)
frameResized = rescaleFrame(frame, scale=0.5)
cv.imshow('Video',frame)
cv.imshow('VideoResized',frameResized)
#Let's find the contour
gray = cv.cvtColor(frame,cv.COLOR_BGR2GRAY)
blurred = cv.GaussianBlur(gray, (3,3), cv.BORDER_DEFAULT)
cv.imshow('blurred', blurred)
canny = cv.Canny(blurred, 50, 150)
cv.imshow('canny', canny)
if cv.waitKey(20) & 0xFF==ord('d'):
break
capture.release()
cv.destroyAllWindows()