1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How best to capture a long exposure image on PiCamera2

Discussão em 'Python' iniciado por Stack, Setembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to use a PiCamera to analyse the intensity of a light source. I have written some very simple code to image it. The light source is not very bright but I don't want any problems from saturation. I am using a Raspberry Pi 4B with a PiCamera 3. What is the best approach? Would a video and sum up the intensity across all frames be a better approach or is there some simple way that I am missing. With my current code, the intensity is barely changing on changing the intended exposure time.

    from picamera2 import Picamera2, Preview
    import time
    import numpy as np

    imageFile = "test.png"
    exposureTime = 5

    camera = Picamera2()
    cameraConfig = camera.create_still_configuration(main={"size": (720,560)}, lores={"size":(640,480)},display="lores")
    camera.configure(cameraConfig)
    camera.shutter_speed = exposureTime*1000
    camera.framerate=(1.0/exposureTime)
    camera.sensor_mode=3
    camera.analogue_gain=6.0
    camera.digital_gain = 1.0
    camera.exposure_mode = 'off'
    time.sleep(1)

    camera.start_preview(Preview.QTGL)
    camera.start()
    time.sleep(exposureTime)
    camera.capture_file(imageFile)
    arrayOfPixels = camera.capture_array()

    camera.stop()
    camera.close()

    print(np.sum(arrayOfPixels))


    I was hoping that varying the exposure time would affect the intensity recorded (e.g. double exposure equals double the signal (ish)). I also tried changing the exposure time through camera.set_controls to no avail. I would like the highest sensitivity and the option to set long exposures (10s should be possible I believe).

    Continue reading...

Compartilhe esta Página