4

I want to capture in low-light and have NoIR picamera. I change the exposure_mode to off and set shutter_speed and iso.

import picamera

with picamera.PiCamera() as camera:
        camera.resolution = (1280,960)
        camera.exposure_mode = 'off'
        camera.framerate =1
        camera.shutter_speed = 6000000
        camera.iso = 1600
        camera.capture('dark.jpg')

The image I get is a decent one. I can see everything.

Now I do the same shutter_speed, framerate, iso, resolution settings to record a .h264 video. The video that I get is a black screen nothing else. Why is the video black but the image clear? Should I try the raspivid commands to record video?

Also what is the relationship between framerate and shutter_speed? I need fairly hight framerate about 30 fps thus 1/30th a second is the maximum shutter_speed possible ? Or can I increase shutter_speed ? How can I achieve good recording while having a large framerate at low light?

5

The first thing to understand is what setting exposure_mode actually does. When this is set to 'off' it fixes the camera's analog and digital gains to their current values (which can be queried with analog_gain and digital_gain respectively). When the camera is first initialized, the analog gain is typically zero. Unless you give it time to stabilize at a higher value (with a delay of some sort), you'll just be fixing the gain at zero (hence the black frames). So the first thing I'd suggest doing is inserting a delay after initializing the camera but before setting exposure_mode to 'off'.

Secondly, you are correct that shutter speed is limited by framerate. In other words, if you have a framerate of 30fps, shutter speed will be clamped at a maximum of 1/30s (or 33333µs). You cannot increase shutter speed beyond that without reducing the framerate.

Note that if you reduce the framerate you will need to increase any delay introduced to allow exposure mode to stabilize. For example, at 30fps a delay of two seconds will give the auto-exposure algorithm 60 frames worth of data to determine a decent gain. But at 1fps, it'll only have 2 frames (usually not enough to determine a decent gain). The slower the framerate, the longer the delay that needs to be used to allow decent gains.

Unfortunately the camera firmware provides no means (that I'm currently aware of), of explicitly specifying the analog and digital gains - the best you can do is let them settle then fix them. I should mention that I think 800 is the maximum ISO you can set manually (the camera will shoot at ISO 1600 under certain circumstances but I vaguely recall exposure mode has to be 'night' for the firmware to allow it).

| improve this answer | |
  • For inserting a delay can I use time.sleep(10) ?. Why should it be done before I set exposure_mode as off? I do this still camera.digital_gain is 0 – Coderaemon May 20 '15 at 8:27
  • For the photo that is coming fine I printed digital_gain and analog_gain values, They are Fraction(0, 1), Fraction(1, 1) respectively. So even when digital_gain is 0 still the image is coming fine? What is happening? – Coderaemon May 20 '15 at 8:48
  • time.sleep(10) is fine for introducing a delay. The reason it needs to be done before setting exposure_mode to off is that during the delay, the AGC algorithm will be adjusting the gains to match the scene. As soon as you set exposure_mode to off you disable AGC and fix the gains at their value at that moment. If that is does before they reach suitable values you get a black picture. – Dave Jones May 20 '15 at 12:23
  • The fact digital_gain can be zero is interesting - I've not seen that before (not that I've played with it much). I do know analog_gain is applied first, and it's the gain applied to the sensor. If analog_gain is zero you always get a black picture. In my brief plays with gain, digital_gain always sat at 1; I assumed this meant it was getting sufficient gain from the analog side of things and it would only bump digital_gain when analog_gain hit 8 (the limit), but I never managed to get it to that point. – Dave Jones May 20 '15 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.