Public Lab Research note


Raspberry Pi Manual Camera Control

by MaggPi |

Read more: publiclab.org/n/16887


MaggPi was awarded the Basic Barnstar by xose for their work in this research note.


Summary: This note describes software that enables manual control of Raspberry Pi camera settings while displaying video output in near real time. Project video can be seen at: https://youtu.be/agDl9JWxJt0


Introduction: While automatic camera controls perform very well for many photographic applications, there may be times when manual control may be desired. This note describes software that permits the user to adjust and visualize the impact of manually selected settings in near real time. Potential Public Lab applications include infrared imaging, microscopy and spectroscopy.

Project description: Major elements of the system design (with key features) include:

-Raspberry Pi NoIR camera v2 with picamera interface. Picamera permits manual control for the following settings: red gain, blue gain, exposure compensation, frame rate, contrast, brightness, saturation, sharpness, exposure and image effects. These camera settings can be set while recordings or previews are in progress. Note that some camera settings such as ISO must be preset and cannot be updated while the camera is operation.
-Raspberry PI 3B+: The latest version with improved processing speeds.
-OpenCV - Computer Vision video processing software to display camera settings and images. A quad video format is used to show how different settings impact different portions of the image pipeline.

Slide1.JPG

Software Display:

The software generates two windows: a trackbar control window and a video image display split into four viewing areas. Trackbar/camera settings are displayed in the upper left quadrant and can be viewed while the user is selecting camera settings. The other video quad areas can display different aspects of computer vison processing as needed. For this project, the video shows the impact of different camera settings with R, B, and RGB image components.

Pictures below show the trackbar control window and video image display. Since OpenCV generated trackbars are limited to integer variables, the software scales trackbar values to match picamera range settings.

Complete list of settings:

Upper left - Displays camera settings with picamera range values: --Exposure Compensation(-25 to 25) --Blue gain(0 to 8) --Red Gain(0 to 8) --Frame Rate(1 to 60 frame per second) --Contrast(-100 to 100) --Brightness: (0 to 100) --Saturation(-100 to 100): --Sharpness(-100 to 100) --Exposure Modes: 'auto','off','night', 'nightpreview', 'backlight','spotlight', sports', 'snow', ‘beach','verylong','fixedfps','antishake','fireworks'. --Image Effects: ‘none','negative','solarize',colorswap','washedout', 'colorbalance', 'cartoon', 'sketch', 'denoise','emboss',‘oilpaint','hatch','gpen','pastel',' watercolor', 'film',’blur'.

Slide2.JPG

Other information displayed (no manual control) --ISO --Exposure Speed (sec) --Analog Gain --Digital Gain

Limitations: (read picamera manual for more info) 1) Some modes have precedence and override other settings. 2) Not all settings can be manually controlled. Some settings such as ISO need to be preset. 3) There is a one or two frame time lag between the setting and image displays. 4) I could never see any image difference by changing the ‘Sharpness’ setting. Not sure when it is useful.

Camera Control Video description: Video describes different scenes during setting adjustment: https://youtu.be/agDl9JWxJt0

In the first video scene, The camera configuration uses an image similar to another post (https://publiclab.org/notes/MaggPi/06-02-2018/raspberry-pi-camera-visible-and-noir-v2-picamera-effects-demos ) and is pictured below. Imaging objects include a resolution chart and Camera Trax Color Card for resolution comparison and color identification.

Slide3.JPG

In the second video scene, different spectroscopy applications are viewed to see how different gain settings impact the spectrum display. For comparison see: https://publiclab.org/notes/MaggPi/07-17-2018/high-dynamic-range-hdr-imaging-revisited

Final thoughts: While this example is designed for a Raspberry Pi camera, the software could be adapted for other cameras if an appropriate interface is provided.

Software code at: https://github.com/MargaretAN9/Peggy/blob/master/Pi%20Camera/picmaeramancontrol.py

Related posts: https://publiclab.org/notes/MaggPi/08-03-2018/ngb-ndvi-video-optimization-red-blue-manual-gain-control https://publiclab.org/questions/MaggPi/07-24-2018/ndvi-led-simulator

@warren, @icarito, @amirberAgain,


4 Comments

Very cool!!! 

Hi @icarito, would you be able to point maggpi at the instructions for generating a virtual-pi image for this setup?

On Wed, Aug 8, 2018, 10:42 PM \<notifications@publiclab.org> wrote:

Public Lab contributor MaggPi just posted a new research note entitled ' Raspberry Pi Manual Camera Control':

Read and respond to the post here: https://publiclab.org/notes/MaggPi/08-09-2018/raspberry-pi-manual-camera-control


Summary: This note describes software that enables manual control of Raspberry Pi camera settings while displaying video output in near real time. Project video can be seen at: https://youtu.be/agDl9JWxJt0

Introduction: While automatic camera controls perform very well for many photographic applications, there may be times when manual control may be desired. This note describes software that permits the user to adjust and visualize the impact of manually selected settings in near real time. Potential Public Lab applications include infrared imaging, microscopy and spectroscopy.

Project description: Major elements of the system design (with key features) include: -Raspberry Pi NoIR camera v2 with picamera interface. Picamera permits manual control for the following settings: red gain, blue gain, exposure compensation, frame rate, contrast, brightness, saturation, sharpness, exposure and image effects. These camera settings can be set while recordings or previews are in progress. Note that some camera settings such as ISO must be preset and cannot be updated while the camera is operation.
-Raspberry PI 3B+: The latest version with improved processing speeds.
-OpenCV - Computer Vision video processing software to display camera settings and images. A quad video format is used to show how different settings impact different portions of the image pipeline.

Slide1.JPG

Software Display :

The software generates two windows: a trackbar control window and a video image display split into four viewing areas. Trackbar/camera settings are displayed in the upper left quadrant and can be viewed while the user is selecting camera settings. The other video quad areas can display different aspects of computer vison processing as needed. For this project, the video shows the impact of different camera settings with R, B, and RGB image components.

Pictures below show the trackbar control window and video image display. Since OpenCV generated trackbars are limited to integer variables, the software scales trackbar values to match picamera range settings.

Complete list of settings:

Upper left - Displays camera settings with picamera range values: --Exposure Compensation(-25 to 25) --Blue gain(0 to 8) --Red Gain(0 to 8) --Frame Rate(1 to 60 frame per second) --Contrast(-100 to 100) --Brightness: (0 to 100) --Saturation(-100 to 100): --Sharpness(-100 to 100) --Exposure Modes: 'auto','off','night', 'nightpreview', 'backlight','spotlight', sports', 'snow', ‘beach','verylong','fixedfps','antishake','fireworks'. --Image Effects: ‘none','negative','solarize',colorswap','washedout', 'colorbalance', 'cartoon', 'sketch', 'denoise','emboss',‘oilpaint','hatch','gpen','pastel',' watercolor', 'film',’blur'.

Slide2.JPG

Other information displayed (no manual control) --ISO --Exposure Speed (sec) --Analog Gain --Digital Gain

Limitations: (read picamera manual for more info) 1) Some modes have precedence and override other settings. 2) Not all settings can be manually controlled. Some settings such as ISO need to be preset. 3) There is a one or two frame time lag between the setting and image displays. 4) I could never see any image difference by changing the ‘Sharpness’ setting. Not sure in what situations it is useful.

Camera Control Video description: Video describes different scenes during setting adjustment: https://youtu.be/agDl9JWxJt0

In the first video scene, The camera configuration uses an image similar to another post (https://publiclab.org/notes/MaggPi/06-02-2018/raspberry-pi-camera-visible-and-noir-v2-picamera-effects-demos ) and is pictured below. Imaging objects include a resolution chart and Camera Trax Color Card for resolution comparison and color identification.

Slide3.JPG

In the second video scene, different spectroscopy applications are viewed to see how different gain settings impact the spectrum display. For comparison see: https://publiclab.org/notes/MaggPi/07-17-2018/high-dynamic-range-hdr-imaging-revisited

Final thoughts: While this example is designed for a Raspberry Pi camera, the software could be adapted for other cameras if an appropriate interface is provided.

Software code at: https://github.com/MargaretAN9/Peggy/blob/master/Pi%20Camera/picmaeramancontrol.py

Related posts:https://publiclab.org/notes/MaggPi/08-03-2018/ngb-ndvi-video-optimization-red-blue-manual-gain-controlhttps://publiclab.org/questions/MaggPi/07-24-2018/ndvi-led-simulator

[@warren](/profile/warren), [@icarito](/profile/icarito), [@amirberAgain](/profile/amirberAgain),


You received this email because you are subscribed to some or all of the following tags: .

To change your preferences, please visit https://publiclab.org/subscriptions.

Report spam and abuse to: moderators@publiclab.org

Check out the blog at https://publiclab.org/blog | Love our work? Become a Public Lab Sustaining Member today at https://publiclab.org/donate

Is this a question? Click here to post it to the Questions page.


Hi @jywarren !

The documentation you are looking for is at here.

The actual build script is at https://github.com/publiclab/image-builder-rpi/

I made a first attempt with this PR!

Should be a start! Thanks for your work @MaggPi!


Awesome!!


@xose awards a barnstar to MaggPi for their awesome contribution!


You must be logged in to comment.

Public Lab is open for anyone and will always be free. By signing up you'll joined a diverse group of community researchers and tapped into a lot of grassroots expertise.

Sign up