The following code generates a green image in raspberry pi with picamera.

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

I don't know why it doesn't work.

  • What do you expect the output should be? Mar 2, 2018 at 9:21
  • You've set a shutter_speed of 6 seconds - and a framerate of 1 per second (though, at 6 second shutter speed, you'd need a framerate of 0.1, wouldn't you?) and you're calling the captured image dark.jpg ... such a long exposure would not be dark ... try a faster shutter speed if you want something that is dark Mar 2, 2018 at 9:26
  • Thanks. I tried faster framerates and got correct images. But still if the shutter speed is slow, why does it outputs a green colour image rather than a white one?
    – VP Lex
    Mar 2, 2018 at 10:32
  • I just realised why you'd do what you're doing ... low level light images ... so, when it's dark :p - why green? perhaps the camera is, like the human eye, more sensitive to green, so, such a long exposure is enough to register green light, but no other - I take it you are taking pictures in the dark? Mar 2, 2018 at 10:45

1 Answer 1


The reason you're getting a "green" exposure is that the AWB (auto-white balance) algorithm hasn't seen enough frames to calculate a "good" white balance. Have a look at the capturing in low light recipe in the docs, which also uses a long exposure time. Note that there's a 30 second delay in the code before the capture line:

from picamera import PiCamera
from time import sleep
from fractions import Fraction

# Force sensor mode 3 (the long exposure mode), set
# the framerate to 1/6fps, the shutter speed to 6s,
# and ISO to 800 (for maximum gain)
camera = PiCamera(
    resolution=(1280, 720),
    framerate=Fraction(1, 6),
camera.shutter_speed = 6000000
camera.iso = 800
# Give the camera a good long time to set gains and
# measure AWB (you may wish to use fixed AWB instead)
camera.exposure_mode = 'off'
# Finally, capture an image with a 6s exposure. Due
# to mode switching on the still port, this will take
# longer than 6 seconds

This is intentional as it allows the AWB loop (which runs in the camera firmware in the background) several frames with which to calculate the white balance. If you skip this you need to be prepared to specify the white balance manually or you'll just wind up with green (because the red and blue gains are zero).

The capturing consistent images recipe has more information on calculating and specify the white balance manually. I'd also recommend having a read of the camera hardware chapter for a better overview of all the stuff that happens in the background with the camera firmware.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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