jim-easterbrook / python-gphoto2

Python interface to libgphoto2
GNU Lesser General Public License v3.0
374 stars 59 forks source link

Any way to do continuous or burst captures? #182

Open andrewyguo opened 4 days ago

andrewyguo commented 4 days ago

I'm aware that there is an existing issue for this: https://github.com/jim-easterbrook/python-gphoto2/issues/123

However, I checked the related issue in the gphoto repo as well but the mentioned solution did not work for me. Currently, I have a loop where:

for i in range(10):
    start = time.time()
    error = gp.gp_camera_trigger_capture(camera)

    while True:
        event_type, event_data = camera.wait_for_event(3000)

        if event_type == gp.GP_EVENT_FILE_ADDED:
            break

    print("Total time taken:", time.time() - start)

I am noticing that it takes around 1.2 seconds for each capture. However, my Sony A7M4 camera is set to Hi+ continuous shooting mode. When I physically hold down the shutter button, it gets 6 FPS or more.

I also tried to check for event_type==gp.GP_EVENT_CAPTURE_COMPLETE and it takes around the same time per shot. Is there a way to take advantage of my camera's continuous shooting mode to take faster images?

jim-easterbrook commented 4 days ago

Waiting for GP_EVENT_FILE_ADDED before triggering the next exposure will almost certainly deliver less than full speed. I don't know what (if any) event tells you that the camera is ready for the next exposure, it's probably very camera dependent. Try calling camera.trigger_capture() several times before waiting for any events. (You may need to empty the event queue by calling camera.wait_for_event(0) repeatedly until it returns GP_EVENT_TIMEOUT between camera.trigger_capture() calls.)

However, I don't have a Sony camera, didn't write libgphoto2, and don't use it for capturing, so this question is better directed at the libgphoto2 mailing list.