1

The red LED on my Pi Camera is not turning off. Does this mean the camera is still on even after the camera.stop_preview() command is executed?

def setup_camera():
    camera = picamera.PiCamera()
    camera.resolution = (700,780)
    camera.preview_fullscreen = False
    camera.preview_window = (0, 0, 700, 780)
    camera.start_preview()
    time.sleep(5)
    camera.stop_preview()
    return;

setup_camera()
  • Can you actually restart the function and take a preview again? I had this issue where the camera would hang up while turning off, the LED would stay on but the camera would not respond to any commands after that until the rpi was rebooted. – Jeff Meden Jul 29 '16 at 21:03
  • Why are you using return at the end of the function?. And what are you returning? – Tes3awy Jul 29 '16 at 22:25
  • I want to take a picture right after the preview ends. This way, I can see the picture i am taking similar to how real cell phone cameras. – Eugene Tian Jul 29 '16 at 22:27
  • 2
    Use camera.close() to shut down the camera; the reason the camera's still running is that it's perfectly possible to capture images or video without the preview running. – Dave Jones Jul 30 '16 at 9:14
0

From https://picamera.readthedocs.io/en/release-1.12/recipes1.html

3.16. Controlling the LED

In certain circumstances, you may find the camera module’s red LED a hindrance. For example, in the case of automated close-up wild-life photography, the LED may scare off animals. It can also cause unwanted reflected red glare with close-up subjects.

One trivial way to deal with this is simply to place some opaque covering on the LED (e.g. blue-tack or electricians tape). Another method is to use the disable_camera_led option in the boot configuration.

However, provided you have the RPi.GPIO package installed, and provided your Python process is running with sufficient privileges (typically this means running as root with sudo python), you can also control the LED via the led attribute:

import picamera

camera = picamera.PiCamera()
# Turn the camera's LED off
camera.led = False
# Take a picture while the LED remains off
camera.capture('foo.jpg')

Warning

Be aware when you first use the LED property it will set the GPIO library to Broadcom (BCM) mode with GPIO.setmode(GPIO.BCM) and disable warnings with GPIO.setwarnings(False). The LED cannot be controlled when the library is in BOARD mode.

Also, Try this:

 def setup_camera():
        camera = picamera.PiCamera()
        camera.resolution = (700,780)
        camera.preview_fullscreen = False
        camera.preview_window = (0, 0, 700, 780)
        camera.start_preview()
        time.sleep(5)
        camera.stop_preview()
        camera.close()
        return;
    setup_camera()

update:

from https://picamera.readthedocs.io/en/release-0.3/api.html :

When you are finished with the camera, you should ensure you call the close() method to release the camera resources (failure to do this leads to GPU memory leaks):

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.