-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpicamera-yuv-array.py
37 lines (32 loc) · 1008 Bytes
/
picamera-yuv-array.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
# capture only luminescence
import time
import picamera
import picamera.array
import numpy as np
with picamera.PiCamera() as camera:
camera.resolution = (100, 100)
time.sleep(2)
y_data = np.empty((112, 128), dtype=np.uint8)
try:
camera.capture(y_data, 'yuv')
except IOError:
pass
y_data = y_data[:100, :100]
# y_data now contains the Y-plane only
print(f"luminance array{y_data}")
print(f"luminance array sum {np.sum(y_data)}")
np.savetxt('y_data-luminance.csv', y_data, delimiter=',')
# capture whole yuv
# import time
# import picamera
# import picamera.array
# with picamera.PiCamera() as camera:
# with picamera.array.PiYUVArray(camera) as stream:
# camera.resolution = (100, 100)
# camera.start_preview()
# time.sleep(2)
# camera.capture(stream, 'yuv')
# # Show size of YUV data
# print(stream.array.shape)
# # Show size of RGB converted data
# print(stream.rgb_array.shape)