-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera_test.py
More file actions
34 lines (28 loc) · 766 Bytes
/
Copy pathcamera_test.py
File metadata and controls
34 lines (28 loc) · 766 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
# this imports the camera
from picamera import PiCamera
import numpy as np
import cv2
from time import sleep
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
#initialize
camera = PiCamera()
def testCamera():
print("Camera test")
camera.start_preview()
sleep(5)
#we capture to openCV compatible format
#you might want to increase resolution
camera.resolution = (750, 750)
camera.framerate = 24
sleep(2)
image = np.empty((750, 750, 3), dtype=np.uint8)
camera.capture(image, 'bgr')
cv2.imwrite('out.png', image)
camera.stop_preview()
print("saved image to out.png")
if __name__ == '__main__':
testCamera()
# img = mpimg.imread('out.png')
# imgplot = plt.imshow(img)
# plt.show()