I want to build an animal counter based on pi zero w, pi cam, python and opencv.
I read some tutorials (especially from https://www.pyimagesearch.com) how to setup all that stuff and in principle it works.
(e.g. the test_video.py from https://www.pyimagesearch.com/2016/08/29/common-errors-using-the-raspberry-pi-camera-module/ is running)
For the part of counting i found a partially (and thats the problem) working project on github: https://github.com/narayananramu/opencv-people-counter.
This contains of two different scripts. The counter.py which counts people on a recorded video file works great.
I get this error when I run the raspberry.py on a live feed from raspi cam:
pi@raspizero:~/opencv-people-counter $ python raspberry.py [INFO] starting background model... Traceback (most recent call last): File "raspberry.py", line 27, in <module> for f in camera.capture_continuous(rawCapture, format="bgr",use_video_port=True): File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 1702, in capture_continuous if not encoder.wait(self.CAPTURE_TIMEOUT): File "/usr/lib/python2.7/dist-packages/picamera/encoders.py", line 395, in wait self.stop() File "/usr/lib/python2.7/dist-packages/picamera/encoders.py", line 419, in stop self._close_output() File "/usr/lib/python2.7/dist-packages/picamera/encoders.py", line 349, in _close_output mo.close_stream(output, opened) File "/usr/lib/python2.7/dist-packages/picamera/mmalobj.py", line 371, in close_stream stream.flush() File "/usr/lib/python2.7/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/python2.7/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
What am i doing wrong?
(I didn't touch the code from github)