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

Camera board • Error reshaping array?

$
0
0
I have code that is based off: https://github.com/raspberrypi/picamera ... _server.py

I am getting this error:

Code:

Exception in thread Thread-4 (output_thread):Traceback (most recent call last):  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner    self.run()  File "/usr/lib/python3.11/threading.py", line 975, in run    self._target(*self._args, **self._kwargs)  File "/usr/lib/python3/dist-packages/picamera2/encoders/multi_encoder.py", line 46, in output_thread    buffer, timestamp_us = task.result()                           ^^^^^^^^^^^^^  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result    return self.__get_result()           ^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result    raise self._exception  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run    result = self.fn(*self.args, **self.kwargs)             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/picamera2/encoders/multi_encoder.py", line 57, in do_encode    buffer = self.encode_func(request, stream)             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/picamera2/encoders/jpeg_encoder.py", line 47, in encode_func    array = request.make_array(name)            ^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/picamera2/request.py", line 161, in make_array    return self.picam2.helpers.make_array(self.make_buffer(name), self.config[name])           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3/dist-packages/picamera2/request.py", line 205, in make_array    image = array.reshape((h, w, 4))            ^^^^^^^^^^^^^^^^^^^^^^^^ValueError: cannot reshape array of size 1228800 into shape (540,960,4)
1228800 would I guess align with the 12.28MP of the camera array and the 540,960 would align with the configuration of my preview stream:

Code:

previewStreamConfiguration = camera.create_video_configuration(main={"size": (960, 540)}, colour_space = ColorSpace.Sycc())
I also note that the example uses the JpegEncoder, shouldn't it use the MJpegEncoder?

Statistics: Posted by eat-sleep-code — Sun Feb 11, 2024 8:39 pm — Replies 0 — Views 28



Viewing all articles
Browse latest Browse all 4547

Trending Articles