Facebook Twitter Instagram Pinterest YouTube
    Trending
    • Elecrow Meteor IPS Touchscreen with RGB LEDs
    • Pi Pico Pinout Display on the Command Line
    • How to Add a Raspberry Pi Pico Reset Button
    • Pi Pico Onboard LED
    • Pi Pico W Pinout and Power Pins
    • CrowPi L Raspberry Pi Laptop and Learning Platform
    • Pi Pico W Launched
    • Add Kodi to RetroPie Menu
    Facebook Twitter Instagram Pinterest YouTube RSS
    Raspberry Pi SpyRaspberry Pi Spy
    • Home
    • Categories
      • General
      • Hardware
      • Programming
      • Python
      • Software
      • Tutorials & Help
    • BerryClip
      • BerryClip Instructions
      • BerryClip Plus Instructions
      • Videos & Reviews
    • Buy
      • Buy Pi
      • Buy Pi Accessories
      • Buy Books
    • Tools
      • Ultimate Raspberry Pi Alexa Skill
      • Pi Power Estimator App
      • Pi-Lite 14×9 LED Matrix Sprite Editor
      • RPiREF Pin-out Reference App
      • Simple Ohm’s Law Calculator
      • Web Sites & Links
    • Tutorials & Help
        Featured
        November 9, 20200

        Raspberry Pi Temperature Monitoring

        Recent
        December 23, 2022

        How to Add a Raspberry Pi Pico Reset Button

        November 20, 2022

        Pi Pico Onboard LED

        May 6, 2022

        Add Kodi to RetroPie Menu

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Hardware»Camera Module»Testing Multiple Pi Camera Options With Python
      Pi Camera Options Test Results

      Testing Multiple Pi Camera Options With Python

      13
      By Matt on June 23, 2013 Camera Module, Python

      It’s easy taking photos using the Pi camera module using the excellent raspistill command line utility or the PiCamera Python library. I wanted to experiment with the different settings available for EX (Exposure) and AWB (Auto White Balance) and see how they performed in different environments.

      Pi Camera Options Test ResultsTrying different settings manually seemed like a lot of work so I decided to write some scripts that would take a sequence of photos using all available options. I could then quickly review the photos and see which ones looked best in a particular environment.

      The scripts could be used whenever I needed to quickly check if tweaking the options was worth considering.

      Option 1 : Python script using Raspistill

      Raspistill is the command line utility included with Raspbian that gives you an easy way to control the Pi camera. An example command which uses the EX and AWB options is shown below :

      raspistill -o myphoto.jpg -ex night -awb shade

      These ex and awb options can be set to the following values :

      -ex
      
      off,auto,night,nightpreview,backlight,spotlight,sports
      snow,beach,verylong,fixedfps,antishake,fireworks
      
      -awb
      
      off,auto,sun,cloud,shade,tungsten,fluorescent,
      incandescent,flash,horizon

      Here is a link to the script that uses raspistill to take the sequence of images : pi_camera_options1.py

      You can download directly to your Pi using :

      wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/camera/pi_camera_options1.py

      It can be run using :

      python pi_camera_options1.py

      or :

      python3 pi_camera_options1.py

      The total number of photos required to try out all of the combinations will be over 100. I didn’t want quite this number of photos so only a selection of options are defined in the “list_ex” and “list_awb” lists. You and add other values if required.

      Option 2 : Python script using PiCamera library

      Rather than use the command line you can also take photos using the excellent PiCamera Python library. Here is a link to the script that uses PiCamera to take the sequence of images : pi_camera_options2.py

      You can download directly to your Pi using :

      wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/camera/pi_camera_options2.py

      It can be run using :

      python pi_camera_options2.py

      or :

      python3 pi_camera_options2.py

      As with the raspistill script you can edit this example and add additional values to the “list_ex” and “list_awb” lists.

      PiCamera uses the older set of AWB values. This means it uses “sunlight” and “cloudy” while Raspistill uses “sun” and “cloudy”.

      The PiCamera version has the advantage that it embeds text in the photo so it is clear what settings were used to create it.

      Results

      The images created by either script will be saved in the same directory as the script so you may want to run them in a sub-directory to keep your test files together.

      My tests were run by taking photos out my study window. I used the free image utility XnView to create a “Contact Sheet” with a set of the photos :

      Pi Camera Options Test Results

      As you can see there is big difference between the images. In this case one of the better images is the Automatic setting (top left) but the clouds are slightly clearer where EX was “auto” and AWB was “horizon”. I suspect “horizon” is better for images where the top half of the scene is brighter than the lower half.

      Funnily enough the “cloud” setting (below left) didn’t do as good a job on the clouds compared to the “horizon” setting (below right).

      Camera Options Test - Cloud Camera Options Test - Horizon
      In this example the default settings were great. These scripts will prove more useful when you are dealing with a more challenging scene, perhaps with lower light levels, nature photography or stop motion animation.

      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous Article12000mAh Li-on Battery Power Bank Test
      Next Article Cheap Interchangeable Lenses For The Raspberry Pi Camera Module

      Related Posts

      Send Pushover Notification when MotionEyeOS Boots

      Create a Basic Python Web Server with Flask

      Monitoring Raspberry Pi GPIO with MotionEyeOS

      13 Comments

      1. Darren on June 23, 2013 8:16 pm

        Can see this being incredibly useful, thanks!

        Reply
      2. arun on June 24, 2013 5:25 am

        How to do this using c language?Please post me..

        Reply
        • Giskard on June 24, 2013 1:38 pm

          Learn Python. It’s easy 🙂
          If you know C language then learn Python is REALLY easy.

          Reply
      3. arun on June 29, 2013 6:26 am

        Hi Giskard,

        i want code in c language because it can be used in my camera application..please post me in c language…

        Reply
      4. Shyam on August 2, 2013 7:08 pm

        Amazing and useful!
        I am glad google brought me to your website. This is one of the most informative website on ‘practical’ implementation – no beat around the bush. Keep updating 😉

        @Arun: Don’t be lazy learn python. I am versed in C,C++, C#, Python is next in my list and already learnt much in just 2 days time.
        If you still want, google “python to c# converter”..

        Regards..

        Reply
      5. Darren on August 4, 2013 10:19 pm

        Hi this is a great blog! I have just purchased the PI and keen to learn Python! What is the best way for a novice to learn?

        Reply
      6. Ben on August 12, 2013 6:56 pm

        Hi, Thanks a lot for your Python script. I have been running it with the Pi Cam against the sun going down to view what setting fits best and tonight I’ll have it running with the Pi cam against the moon 😉

        One small thing I found a little confusing: unremarking the “other” awb and ex settings still left me with only 6 images. Might be clear to other people but if you unremark settings you have to remark the other settings because the script uses the last values for awb and ex which it reads from the script.

        Now, I have 130 images 😉

        Thanks a lot !!

        Reply
      7. Ben on August 12, 2013 7:09 pm

        One other suggestion: I am a big fan of the tool feh which I run on both Ubuntu and the Pi. After installing the latest version you can sort the images in a directory by making date. So no more worries about filenames and wrong sorting.

        I prefer to use it with this command line

        feh -d -F -Smtime

        this way it displays the filename in the topleft corner, show the images fullscreen and sorted by creation time / date. Browsing through all the images goes with arrow right (and left)

        Regards,
        Ben

        Reply
      8. Rick on December 8, 2013 5:34 am

        Thanks for the great script! I made a few changes based on the newest RaspiStill binary.
        https://github.com/ntalekt/RaspiStill_Camera_Options

        Reply
      9. Kevin H on December 16, 2013 11:41 pm

        Thanks for the script. It gives a good overlook of the settings and options. One thing you could add is making the photo contact sheet with the Python Imaging Library instead of XnView. This way, the script will be all in one. Maybe even add a text overlay to each image with the settings. Just a thought, but thanks for the post.

        Reply
      10. bill on July 25, 2014 9:48 am

        would it possible to put these pics in a grid with the various options being written above the columns and beside the rows. That way it would be easy to identify which pic was which…. on another note, i’m trying to figure out how to store the returned image from raspistill in a variable so i can quickly find the colour of one pixel you seem like the fellow that may be able to steer me in the right direction. Thanks for a clear and concise bit of coding it really helps beginners like myself….

        Reply
      11. Vishaal on April 29, 2015 8:21 am

        Hey,
        In the python script you’ve provided you have invoked the commands into the terminal right? Is it possible to implement exposure mode changes using only python. Also can these exposure modes be used while recording videos?
        For example:
        with picamera.PiCamera() as camera:
        camera.EXPOSURE_MODES=sports

        Reply
        • Matt on May 6, 2015 11:57 am

          When I wrote this article the Picamera python library didn’t exist so I used the command line utilities provide by the Raspberry Pi Foundation. Probably best to check the Picamera documentation as thay contains all library features with examples.

          Reply

      Leave A Reply Cancel Reply

      This site uses Akismet to reduce spam. Learn how your comment data is processed.

      Recent Posts
      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      December 23, 2022

      How to Add a Raspberry Pi Pico Reset Button

      November 20, 2022

      Pi Pico Onboard LED

      November 14, 2022

      Pi Pico W Pinout and Power Pins

      Categories
      • 1-wire
      • 3D Printing
      • Add-ons
      • BBC Micro:bit
      • BerryClip
      • Books
      • Camera Module
      • Cases
      • Events
      • General
      • Hardware
      • I2C
      • Infographics
      • Interfaces
      • Minecraft
      • Model A+
      • Model B+
      • News
      • Pi Models
      • Pi Pico
      • Pi Zero
      • Power
      • Programming
      • Python
      • Raspberry Pi OS
      • Raspbian
      • RetroGaming
      • Robotics
      • Sensors
      • Software
      • SPI
      • Tutorials & Help
      Tags
      Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter Kodi LCD LED Linux media Minecraft Model A motionEyeOS PCB photography photos Pi-Lite Pi Pico power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI SSH temperature ultrasonic video
      Raspberry PI Related
      • Adafruit Blog
      • Average Maker
      • Official RaspBerry Pi Site
      • Raspberry Pi Pod
      • RasPi.tv
      • RaspTut
      • Stuff About Code
      Tech Resources
      • MattsBits – Pi Resources
      • Microbit Spy
      • Technology Spy
      Archives
      About

      Unofficial site devoted to the Raspberry Pi credit card sized computer offering tutorials, guides, resources,scripts and downloads. We hope to help everyone get the most out of their Pi by providing clear, simple articles on configuring, programming and operating it.

      Popular Posts
      September 19, 2014

      Top 5 Reasons The Raspberry Pi Sucks

      July 27, 2012

      16×2 LCD Module Control Using Python

      October 20, 2013

      Analogue Sensors On The Raspberry Pi Using An MCP3008

      Recent Posts
      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      December 23, 2022

      How to Add a Raspberry Pi Pico Reset Button

      Facebook Twitter Instagram Pinterest YouTube RSS

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2022 - All Rights Reserved - Matt Hawkins

      mastodon.social@RPiSpy

      Type above and press Enter to search. Press Esc to cancel.