-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraController.py
More file actions
32 lines (25 loc) · 845 Bytes
/
Copy pathCameraController.py
File metadata and controls
32 lines (25 loc) · 845 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
import cv2
import numpy as np
import time
from picamera.array import PiRGBArray
from picamera import PiCamera
# Class for interfacing with the camera
class CameraController:
# Initializes camera interface
def __init__(self):
self.camera = PiCamera()
self.raw_capture = PiRGBArray(self.camera)
time.sleep(0.1)
# Returns the most recent image from the camera
def get_image(self):
# check camera connection and then store the current frame
self.camera.capture(self.raw_capture, format="bgr")
image = self.raw_capture.array
self.raw_capture.truncate(0)
# display the image on screen and wait for a keypress
return image
if __name__ == "__main__":
camera = CameraController()
camera.get_image()
time.sleep(1)
camera.get_image()