Hi i'm trying to capture a low res image during recording with the PiCamera module. However it crashes on the camera.capture line giving the following error
File "/usr/lib/python3/dist-packages/picamera/array.py", line 238, in flush self.array = bytes_to_rgb(self.getvalue(), self.size or self.camera.resolution) File "/usr/lib/python3/dist-packages/picamera/array.py", line 127, in bytes_to_rgb 'Incorrect buffer length for resolution %dx%d' % (width, height)) picamera.exc.PiCameraValueError: Incorrect buffer length for resolution 1280x726
This is my code so far:
from picamera import PiCamera
from picamera.array import PiRGBArray
import numpy as np
import time
camera = PiCamera()
resolution = (128,80)
camera.resolution = (1280, 726)
camera.start_preview()
time.sleep(2)
RGBArray = PiRGBArray(camera)
camera.capture(RGBArray, format='rgb',splitter_port=0,resize=resolution)
print("i crash on the line above")
If i set the camera resolution to camera.resolution = (128,80) and remove the "resize" parameter from camera.capture() it works fine but i want to record in a higher resolution. I can't seem to find the solution anywhere on this.
SOLVED PiRGBArray(camera) needs to be changed to PiRGBArray(camera,size=128,80)
PiRGBArray(camera) needs to be changed to PiRGBArray(camera,size=128,80)