-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreads.py
More file actions
38 lines (29 loc) · 837 Bytes
/
Threads.py
File metadata and controls
38 lines (29 loc) · 837 Bytes
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
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 19 19:12:38 2019
@author: Albert Lin
"""
"""
the thread that captures images from the camera
get the most recent one with read()
"""
import cv2
from threading import Thread
class CameraThread(Thread):
sourceID = 1
exposure_ID = 15
#brightness_ID = 10 #unsure if ID is right, and change in brightness not needed anyways
#brightness = -100
exposure = -10000
frame = None
cap = cv2.VideoCapture(sourceID)
cap.set(exposure_ID, exposure)
def run(self):
while self.cap.isOpened():
self.cap.grab()
print('camera is closed')
def read(self):
if self.cap.isOpened():
have_frame, self.frame = self.cap.read()
return have_frame, self.frame
return False, self.frame