-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera_skeleton.py
36 lines (30 loc) · 973 Bytes
/
camera_skeleton.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
import cv2
import os
import numpy as np
from image_processor import process_image
from processor_properties import ProcessorProperties
import time
class Camera:
def __init__(self):
self.cap = cv2.VideoCapture(0)
def snapshot(self):
ret, frame = self.cap.read()
return frame
if __name__ == '__main__':
camera = Camera()
while True:
frame = camera.snapshot()
props = ProcessorProperties()
# props.brightness_factor.update(1.5)
# props.contrast_factor.update(1.5)
# props.scaling_factor.update(3.0)
frame = process_image(frame, props)
cv2.imshow('image', frame)
k = cv2.waitKey(1) & 0xFF
if k == ord('q'):
break
elif k == ord('s'):
timestr = time.strftime("%Y%m%d-%H%M%S")
image_path = os.path.join("testimgs", "%s.jpg" % timestr)
cv2.imwrite(image_path, frame)
print "save %s" % image_path