Black images in the bright sun with raspberry pi cam

450 views
Skip to first unread message

roman keller

unread,
Mar 13, 2016, 6:42:50 AM3/13/16
to UKHAS
dear everybody

we recently had our second solar balloon flight to the stratosphere. unfortunately the camera again did't work as planed and tested. we used the following code and got all black photos and videos during the eight hours flight - and sometimes also during the filling up/pre flight preparations. is there a possibility that the camera switches to a different mode when exposed to bright sunlight and snow?

here is an overview of the disaster:
https://drive.google.com/file/d/0B0iLw9bRs9SGVEV0bVdVQ0dQWVE/view?usp=sharing

any suggestions or similar experiencey (help highly appreciated)?

greetings from grey zurich

--------------------------------------------------------

import picamera
import time
from datetime import datetime

count = 0
while count < 999:
with picamera.PiCamera() as camera:
camera.resolution = (2592, 1944)
time.sleep(1)
camera.start_preview()
filename = '//DATA/blue_%s_auto.jpg'%datetime.now().strftime('%Y-%m-%d-%H%M%S')
camera.capture(filename)

camera.resolution = (2592, 1944)
camera.shutter_speed = 1000
camera.exposure_mode = 'off'
camera.iso = 100
camera.awb_mode = 'sunlight'
filename = '//DATA/blue_%s_fixed.jpg'%datetime.now().strftime('%Y-%m-%d-%H%M%S')
camera.capture(filename)

camera.resolution = (1920, 1080)
camera.framerate = 25
camera.sharpness = 0
camera.contrast = -10
camera.saturation = 0
camera.ISO = 100
camera.video_stabilization = False
camera.exposure_compensation = 0
camera.exposure_mode = 'off'
time.sleep(1)
camera.start_preview()
camera.awb_mode = 'off'
camera.awb_gains = (1.45, 1.45)
camera.image_effects = 'none'
camera.color_effects = None
camera.rotation = 180
camera.hflip = False
camera.vflip = False
camera.shutter_speed = 1000
filename = '//DATA/blue_%s.h264'%datetime.now().strftime('%Y-%m-%d-%H%M%S')
camera.start_recording(filename, bitrate=25000000)
camera.wait_recording(627)
camera.stop_recording()
count = count + 1

mclane

unread,
Mar 14, 2016, 4:40:26 PM3/14/16
to UKHAS
Hello Roman,

I have been running the PiCam on a stratospheric ballon without any problems. However, I have used the command line program raspistill and called it from within a c program using the C library function "system()"like this:

char still[] = "raspistill -rot 180 -w 512 -h 288 -ex auto - mm matrix -o /home/pi/pics/im0000.jpg";

system(still);

You can find an example of an SSDV image as received during the chase in the attachment - a few SSDV packages were disturbed.

The second example shows a 5 MPixel photo from the same flight captured in the same way but stored on the sd card. During that flight (PYSY9) we collected some 250 pictures like this plus 150 video clips of 2 min each using the raspivid command - we have never experienced the problems which you show. Maybe your issue is

camera.exposure_mode = 'off'

See documentation of picamera here:

Exposure mode 'off' is special: this disables the camera’s automatic gain control, fixing the values of digital_gain and analog_gain. Please note that these properties are not directly settable, and default to low values when the camera is first initialized. Therefore it is important to let them settle on higher values before disabling automatic gain control otherwise all frames captured will appear black.

http://picamera.readthedocs.org/en/release-1.10/api_camera.html

Therefore try

camera.exposure_mode = 'auto'

I do not know Python very well; but I think you can also call command-line routines in Python (as I assume that your code is Python).

Best regards,

Uli
2014-06-07-08-17-16-PYSY-08.jpeg
HD0038.jpg

roman keller

unread,
Mar 15, 2016, 4:46:57 AM3/15/16
to UKHAS
dear uli

thank you very much for your support. We were choosing the raspi cam to get the possibility of setting manual exposure or at least fixed exposure during each take (we're seeking to use the footage for a video installation and dislike the constant exposure correction we had with the gopro).

unfortunately we still can't reproduce the error of last week. but we got to know that the camera needs more time to find "good" gains.

our recent sketch for the code is:

from time import sleep
from datetime import datetime
from picamera import PiCamera

while True:
with PiCamera() as camera:
camera.resolution = (2592, 1944)
camera.framerate = 25
# The camera's upside down
camera.rotation = 180
# Wait to let the auto-exposure figure out good settings
sleep(3)
# Just in case the wait above isn't enough, wait until the gains are
# sensible
while camera.analog_gain < 1 or camera.digital_gain < 1:
sleep(0.1)
camera.awb_mode = 'off'
camera.awb_gains = (1.5, 1.3)

camera.capture('/DATA/blue_auto_%s.jpg' % datetime.now().strftime('%Y-%m-%d-%H%M%S'))

camera.exposure_mode = 'off'
# Make sure the gains are sensible and bail if they're not
if camera.analog_gain < 1 or camera.digital_gain < 1:
raise RuntimeError('low gains')
# Changed AWB/ISO/etc. here if you want
camera.iso = 100
camera.shutter_speed = 750

camera.capture('/DATA/blue_fixed_%s.jpg' % datetime.now().strftime('%Y-%m-%d-%H%M%S'))

# Set resolution and framerate
camera.resolution = (1280, 720)
camera.framerate = 25
# The camera's upside down
camera.rotation = 180
# Wait to let the auto-exposure figure out good settings
sleep(3)
# Just in case the wait above isn't enough, wait until the gains are
# sensible
while camera.analog_gain < 1 or camera.digital_gain < 1:
sleep(0.1)
camera.awb_mode = 'off'
camera.awb_gains = (1.5, 1.3)

camera.start_recording(
'/DATA/blue_auto_%s.h264' % datetime.now().strftime('%Y-%m-%d-%H%M%S'),
quality=22, bitrate=2000000)
camera.wait_recording(323)
camera.stop_recording()

# Lock the gains
camera.exposure_mode = 'off'
# Make sure the gains are sensible and bail if they're not
if camera.analog_gain < 1 or camera.digital_gain < 1:
raise RuntimeError('low gains')
sleep(0.1)
camera.iso = 100
camera.shutter_speed = 750

camera.start_recording(
'/DATA/blue_fixed_%s.h264' % datetime.now().strftime('%Y-%m-%d-%H%M%S'),
quality=22, bitrate=2400000)
camera.wait_recording(323)
camera.stop_recording()
Reply all
Reply to author
Forward
0 new messages