-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.py
42 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
41
42
from picamera import PiCamera
from picamera.array import PiRGBArray
import os
import cv2
import time
import numpy as np
class Camera:
def __init__(self, image_d = 1):
"""
Initializing all the variables required for the PiCamera module.
Only importing up image here, then using rotation to save memory space.
"""
self.camera = PiCamera()
self.font = cv2.FONT_HERSHEY_SIMPLEX
self.rawCapture = None
self.camera.resolution = (640, 480)
self.camera.vflip = True
self.camera.framerate = 15
self.rawCapture = PiRGBArray(self.camera, size=(640, 480))
print("Picamera loaded")
time.sleep(1)
def imageCapture(self):
# Capturing an image
image = self.camera.capture(self.rawCapture,format='rgb', use_video_port=True)
frame = self.rawCapture.array
if frame is None:
print("no image here")
self.rawCapture.truncate(0)
return frame