0

When I use PiCamera, I have capture stills or video. They describe that there is a difference between the two. I find stills are slower when capturing continuously. Video is a faster frame rate.

When I use VideoCapture in OpenCV, it seems to capture at the similar rate of continuous stills. I have an example python script to show my findings. I tested 5 seconds of capture on a Sony IMX219 at a resolution of 1920X1080:

  • PiCamera Video: 146 frames at 28.81fps fileSize: 75KB
  • PiCamera Stills: 8 frames at 1.78fps fileSize: 12.3 MB
  • OpenCV VideoCapture: 14 frames at 3.12fps fileSize: 670KB

In all three cases, I tried to optimize by not writing to disk and just capture in memory to rule out disk I/O.

Is there another setting in OpenCV that I should be using like it appears that PiCamera is doing?

@MarkSetchell, Setting the CAP_PROP_FPS seems to have no effect.

@MarkSetchell, Running opencv first doesn't make a difference. I noticed this on a system that didn't even have picamera installed. Example script has been updated though.

@MarkSetchell, cv2.getBuildInformation()

@MarkSetchell, If I enable file creation the picamera stills are larger than opencv. I listed the file sizes above

Does this mean bcm2835_v4l2 is loaded but not being used? lsmod | grep

Module                  Size  Used by
bcm2835_v4l2           45056  0
cm2835_v4l2            45056  0
v4l2_mem2mem           24576  1 bcm2835_codec
bcm2835_mmal_vchiq     32768  2 bcm2835_codec,bcm2835_v4l2
v4l2_common            16384  1 bcm2835_v4l2
videobuf2_vmalloc      16384  1 bcm2835_v4l2
videobuf2_v4l2         24576  3 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem
videobuf2_common       45056  4 bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
videodev              200704  6 bcm2835_codec,v4l2_common,videobuf2_common,bcm2835_v4l2,v4l2_mem2mem,videobuf    2_v4l2 media                  36864  3 bcm2835_codec,videodev,v4l2_mem2mem
joels
  • 7,249
  • 11
  • 53
  • 94
  • Line 65 needs removing - you shouldn't be setting the framerate in the middle of your acquisition! Also, your indentation is up the spout. – Mark Setchell Jan 10 '20 at 19:55
  • Try running the OpenCV capture first, in case running Raspicam stills has set something that OpenCV doesn't clear. – Mark Setchell Jan 11 '20 at 20:36
  • Try printing output of `cv2.getBuildInformation()`. – Mark Setchell Jan 11 '20 at 21:28
  • Check this too... https://stackoverflow.com/a/44240568/2836621 – Mark Setchell Jan 11 '20 at 21:35
  • I can't see what's going wrong, though I note the first 2 are just getting JPEGs which are probably 200kB whereas OpenCV is grabbing 6MB of high quality image per frame. – Mark Setchell Jan 11 '20 at 22:53
  • No, I was referring to the volume of data that OpenCV reads from the camera. If you read a 2000x1000 pixel image with 3 bytes per pixel into an OpenCV Numpy array you will have received 6MB from the camera. If you read a 2000x1000 pixel MJPEG-compressed image from the camera that's probably under 200kB, i.e. 30x less. – Mark Setchell Jan 12 '20 at 00:36

0 Answers0