Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1225

Python • picamera2 capture_array('raw') returns uint8 array

$
0
0
Hi together,

I try to get raw bayer data from the camera module 3.

I am experimenting with some code derived from the raw.py example (https://github.com/raspberrypi/picamera ... les/raw.py).

To my surprise, the call

Code:

 picam2.capture_array("raw") 
returns a ndarray with dtype uint8. I expect the data to be uint16.
It seems that the upper 4 bit of each pixel is truncated.

I wonder, what to do, to get the data with the full color depth of 12 bit?.

Here is the code I am using:

Code:

import timefrom picamera2 import Picamera2, Previewpicam2 = Picamera2()#picam2.start_preview(Preview.QTGL)config = picam2.create_still_configuration()print(config)print()picam2.configure(config)picam2.start()time.sleep(2)raw = picam2.capture_array("raw")print(picam2.stream_configuration("raw"))print()print(raw.dtype)
It creates in the following output:

Code:

{'use_case': 'still', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'sYCC'>, 'buffer_count': 1, 'queue': True, 'main': {'format': 'BGR888', 'size': (4056, 3040)}, 'lores': None, 'raw': {'format': 'SRGGB12_CSI2P', 'size': (4056, 3040)}, 'controls': {'NoiseReductionMode': <NoiseReductionModeEnum.HighQuality: 2>, 'FrameDurationLimits': (100, 1000000000)}, 'sensor': {}, 'display': None, 'encode': None}{'format': 'BGGR16_PISP_COMP1', 'size': (4056, 3040), 'stride': 4096, 'framesize': 12451840}uint8
As you see, the stream configuration format is described as 'BGGR16_PISP_COMP1', however, the dtype of the returned numpy array is uint8.


Best regards,

Jochen

Statistics: Posted by jo_br — Fri Jan 05, 2024 11:18 pm



Viewing all articles
Browse latest Browse all 1225

Trending Articles