New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black image when exposure mode set to "off" #182

Closed
snoygues opened this Issue Nov 29, 2014 · 8 comments

Comments

Projects
None yet
4 participants
@snoygues

snoygues commented Nov 29, 2014

Hi use following "capture_continuous" command with 'yuv' format.

In that case, which of following parameters are active and how they change the result :

  • iso,
  • awb_mode,
    • exposure_mode,
    • exposure-compensation,
    • awb_gain,
    • analog_gain,
    • brightness,
    • contrast,
    • digital_gain,
    • saturation,
    • sharpness.
      I try many combinations, but it seems I get always same result...

Actually, I just need to fix all aquisition parameters, but I didn't succeded
For example, I spcecify:
self.__Camera.iso = 800
self.__Camera.awb_mode = 'off'
self.__Camera.exposure_compensation = 0
self.__Camera.awb_gains = 1, 1
I though it should fix everything, but I can see that analog gain and digital gain change with light quantity.

@waveform80

This comment has been minimized.

Owner

waveform80 commented Nov 30, 2014

As far as I know it's impossible to fix the analog and digital gains on the camera. I'd guess that ISO is meant to fix them to some degree, but I'm not sure what that actually entails in practice (the details of that are down in the firmware).

Setting exposure_mode to off should fix the exposure speed to whatever setting shutter_speed has but I don't think it affects the gains. Setting awb_mode to off and awb_gains to some values should fix the white balance though. Exposure compensation is a fixed value which doesn't change with the scene so there's no need to set that one.

@snoygues

This comment has been minimized.

snoygues commented Dec 1, 2014

I did some tests. No way to fix analog and/or digital gain via ISO, awb_mode and awb_gain.

Moreover, if I fix exposure_mode to off, then it doesn't work at all (black image). Maybe it's linked to my other parameters (continuous mode and "yuv" format. For information, in that case, Digital_Gain is at 0. Is it a bug or a non correct parameter combination ?

@waveform80

This comment has been minimized.

Owner

waveform80 commented Dec 5, 2014

I think this is related to #171. Specifically you need to set framerate and shutter_speed then leave a little delay (like a second or two) before setting exposure mode to off. I'm not sure exactly why this is but I suspect it's something to do with the gains not being set correctly in the firmware otherwise (when the display is black under these circumstances analog gain seems fine, but digital has dropped to 0 - this may have something do with setting framerate having to reset the camera).

In other words, this will cause the black frame behaviour:

import time
import picamera

with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.start_preview()
    camera.awb_mode = 'off'
    camera.awb_gains = (1.8, 1.5)
    camera.exposure_mode = 'off'
    camera.framerate = 24
    camera.shutter_speed = 30000
    time.sleep(20)

But this script won't:

import time
import picamera

with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.framerate = 24
    time.sleep(1)
    camera.start_preview()
    camera.awb_mode = 'off'
    camera.awb_gains = (1.8, 1.5)
    camera.shutter_speed = 30000
    camera.exposure_mode = 'off'
    time.sleep(20)

I should add a warning to the exposure_mode docs about this, but that's about all I can do for now.

@waveform80 waveform80 added this to the 1.9 milestone Dec 5, 2014

@waveform80 waveform80 added the question label Dec 5, 2014

@waveform80 waveform80 self-assigned this Dec 5, 2014

@waveform80 waveform80 changed the title from "YUV" Mode and other acquisition parameters to Black image when exposure mode set to "off" Dec 5, 2014

@snoygues

This comment has been minimized.

snoygues commented Dec 11, 2014

Hello,

First of all, thank you for your support. I really appreciate.

I work a bit following your suggestion. That doesn't work perfectly, but there are some improvement :

  • first of all, I realyse, that i didn't put in my script the "camera.start_preview()" command. After adding it, then both digital and analog gain remains constant whatever the light level on sensir. That's already a very good point for my project.
  • then I also tried to add pause (time.sleep( 1 )) as you suggest. But, nothing change and ISO parameters remains without effect. I tried to put pause in different position, but without success.

So, my situation is that I can continue my project developpement like that, even if that's not optimal.

Regards,
Sébastien

----- Mail original -----
De: "Dave Jones" notifications@github.com
À: "waveform80/picamera" picamera@noreply.github.com
Cc: "snoygues" snoygues@free.fr
Envoyé: Vendredi 5 Décembre 2014 03:47:13
Objet: Re: [picamera] "YUV" Mode and other acquisition parameters (#182)

I think this is related to #171 . Specifically you need to set framerate and shutter_speed then leave a little delay (like a second or two) before setting exposure mode to off. I'm not sure exactly why this is but I suspect it's something to do with the gains not being set correctly in the firmware otherwise (when the display is black under these circumstances analog gain seems fine, but digital has dropped to 0 - this may have something do with setting framerate having to reset the camera).

In other words, this will cause the black frame behaviour:
import time import picamera with picamera.PiCamera() as camera:
camera.resolution = ( 640 , 480 )
camera.start_preview()
camera.awb_mode = ' off ' camera.awb_gains = ( 1.8 , 1.5 )
camera.exposure_mode = ' off ' camera.framerate = 24 camera.shutter_speed = 30000 time.sleep( 20 )

But this script won't:
import time import picamera with picamera.PiCamera() as camera:
camera.resolution = ( 640 , 480 )
camera.framerate = 24
time.sleep( 1 )
camera.start_preview()
camera.awb_mode = ' off ' camera.awb_gains = ( 1.8 , 1.5 )
camera.shutter_speed = 30000 camera.exposure_mode = ' off ' time.sleep( 20 )

I should add a warning to the exposure_mode docs about this, but that's about all I can do for now.


Reply to this email directly or view it on GitHub .

waveform80 added a commit that referenced this issue Jan 1, 2015

@waveform80 waveform80 closed this Jan 1, 2015

@namorrellek

This comment has been minimized.

namorrellek commented Mar 13, 2016

dear everybody

we recently had our second solar balloon flight to the stratosphere. unfortunately the camera did't work as planed and tested for the second time. we used the following code and got all black photos and videos during the eight hours flight - and sometimes also black files 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 experience? any 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

@waveform80

This comment has been minimized.

Owner

waveform80 commented Mar 13, 2016

Answered comment above in #266 (please don't double post - I get notifications about everything both comments and new issues)

@namorrellek

This comment has been minimized.

namorrellek commented Mar 13, 2016

sorry. i was confused after posting as his page says "closed" in the top left part. won't happen again!

@geerlingguy

This comment has been minimized.

geerlingguy commented Mar 21, 2017

I was having the exact same issue; added a sleep(1) right after setting exposure_mode to off, and it seems to fix the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment