PiVideoStream with multiple cameras
Opened this issue · 1 comments
Hi,
My set-up includes two PiCameras and a RaspBerry-Pi CM3. I can open two PiVideoStream objects and start my streaming session. I read the frames from both of them till I get the following exceptions:
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1718, in capture_continuous
'Timed out waiting for capture to end')
picamera.exc.PiCameraRuntimeError: Timed out waiting for capture to end
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/dist-packages/imutils/video/pivideostream.py", line 32, in update
for f in self.stream:
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1725, in capture_continuous
encoder.close()
File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 433, in close
self.stop()
File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 421, in stop
self._close_output()
File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 350, in _close_output
mo.close_stream(output, opened)
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 371, in close_stream
stream.flush()
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 640x480
I’ve isolated the moment when the read operation I perform fails (meaning that for k times I try to read but I don't get new frames from one of the picameras) and consequently re-initialized the interested camera (just the one that leads to the exceptions and not both of them), but, still, this isn’t enough. I’ve also added a “self.rawCapture.seek(0)” after the “truncate” in the “update(self)” method of “PiVideoStream” but this doesn’t solve my problem.
Thanks for your help!
Hey @Gianlu95 -- I haven't tried using the PiVideoStream
with multiple RPi camera modules. I would instead recommend installing the V4L2 drivers which will enable you to access the RPi camera modules via the src
attribute in VideoStream
:
camA = VideoStream(src=0).start()
camA = VideoStream(src=1).start()
That should resolve your issue.