-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcam.py
37 lines (27 loc) · 895 Bytes
/
cam.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
"""
cam.py
------
Alex Robbins, Andrew Hart
Intro to AI Section 1
Final Project (Maze Solver)
This file defines the VideoCamera object used to capture images from the webcam
and use them in our other code.
"""
import cv2
import PIL.Image
class VideoCamera(object):
def __init__(self):
#If no external cam: 0 will be webcam
#If external cam connected: 0 will be external cam and 1 will be webcam
self.video = cv2.VideoCapture(0)
#Will set resolution to highest it cam be (assuming it cant be higher than 10,000x10,000)
self.video.set(3,10000) #Set width
self.video.set(4,10000) #Set height
def __del__(self):
self.video.release()
def get_frame(self):
success, image = self.video.read()
imageRGB = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
pilImage = PIL.Image.fromarray(imageRGB)
#pilImage to be displayed, and image to be manipulated
return pilImage, image