Two weeks ago I undertook a performance evaluation of the two primary methods of capturing images on the Raspberry PiCamera v2. Here I wish to outline the parameters and summarize the results. The target device was the RPI0W.

Evaluation Setup

Our desired outcome was to determine image capture and save times vs. image file sizes. Along the way we learned a few other things about using the Picamera. Our investigation necessitated a 5-dimensional test matrix:

  • Dim 0: Capture software (Raspistill vs. Picamera 1.13)
  • Dim 1: Sensor Mode
  • Dim 2: Resolution
  • Dim 3: Encoding (PNG vs JPG)
  • Dim 4: Downsampling to lower JPG qualities via Python Image Library (Pillow)

For our resolution list we covered standard resolutions in 4:3 and 16:9 aspect ratios from 640×480 to 3280×2464. We used this handy reference chart from wikipedia as a guide for selecting resolutions to investigate.

The resolution list was cross-referenced to the Picamera sensor mode list. Each mode has a maximum resolution at a given field of view with a certain aspect ratio. The information about Picamera sensor modes is found on the Picamera 1.13 documentation website. We set up the follwoing mode resolution matrix:

  • Mode 1: 640×480, 768×576, 800×600, 960×720, 1024×768, 1152×864, 1224×918, 1280×960, 1400×1050, 1440×1080, 1920×1080
  • Mode 2: 640×480, 768×576, 800×600, 960×720, 1024×768, 1152×864, 1224×918, 1280×960, 1400×1050, 1440×1080, 1920×1080, 1600×1200, 2048×1536, 3280×2464
  • Mode 3: skipped, identical to Mode 2
  • Mode 4: 640×480, 768×576, 800×600, 960×720, 1024×768, 1152×864, 1224×918, 1280×960, 1400×1050, 1440×1080, 1600×1200, 1640×1232
  • Mode 5: 640×480, 768×576, 800×600, 960×720, 1024×768, 1152×864, 1224×918, 1640×922
  • Mode 6: 640×480, 768×576, 800×600, 960×720, 1280×720
  • Mode 7: 640×480

Each of these images were taken with both Raspistill and Picamera v1.13 in PNG and JPG encoding. After the images were taken they were down sampled by Pillow to JPG qualities 90 to 10 in increments of 10. For the sake of comparison we also down sampled JPG images directly within Raspistill and Picamera. We evaluated about 1,000 images.

The camera was placed in an enclosed environment with a stable mount, stable lighting, and a static object for the picture. Shutter speed and exposure modes were also held static to prevent automatic exposures from arbitrarily changing processing times and image sizes.

Our script was written in Python. Of course Picamera v1.13 can be installed via PIP. A BASH command was set up and executed with the Python OS library.

Results

Raspistill vs Picamera

For all modes, resolutions, and both image encodings, Picamera v1.13 captured images in less time. For JPG images, the capture time was about 4-5 seconds less than Raspistill. For PNG images, the capture time was about 1-2 seconds less.

In most cases Raspistill file size was less than Picamera v1.13. For larger images in JPG encoding, this amounted to about 300 Kb. For smaller images the difference was much less.

Sensor Mode and Resolution

Changing the sensor mode from maximum field of view (Mode 2) while holding the resolution static shows a decrease in both capture time and file size as the field of view is decreased (Mode 2 to 4 to 5 to 6 to 1 to 7)–see modes page. This amounts to about 0.25 second difference in time and a 5 to 10 Kb difference in file size for a 640×480 image.

Holding the mode static, while decreasing resolution from the native resolution also results in lower capture times and file sizes. While this result may seem intuitive, we wished to confirm because how the camera software handles non-native resolutions is not clear.

In the process of executing our tests we learned that each mode can accept any arbitrary resolution at lower than the maximum specified for the mode–the lower the resolution the better capture time and smaller file size. We also noted that changing the resolution did not change the vertical aspect in the field of view, only the horizontal aspect was changed.

Encoding

Another expected result is that JPG images had much faster capture times and lower file sizes for all resolutions. Nothing interesting here.

Image Quality

We compared JPG image quality outputs directly from the capture software to that produced by Pillow. The capture software quality 10 was visually much better than Pillow quality 10 and produced a much bigger file size. The quality settings for both outputs were non-linear. Differences in file sizes at the bottom of the scale were much smaller than at the top of the scale. The Pillow software seemed to use a more aggressive quality down sampling algorithm; however, it did add anywhere from 0.5 to 2.5 seconds of processing time depending upon image resolution.