jim-easterbrook / python-gphoto2

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

Time for capture and download increases over time #32

Closed scus1 closed 7 years ago

scus1 commented 7 years ago

I am using a Nikon D300 connected to a Raspberry Pi to capture JPGs and I am running into the following problem: The process to capture and download the images takes more and more time...

As you can see below, the problem begins with the second picture, so I doubt that it is caused by a shortage of RAM.

To reproduce:

import gphoto2 as gp
from time import perf_counter

camera  = gp.check_result(gp.gp_camera_new())
context = gp.gp_context_new()
gp.check_result(gp.gp_camera_init(camera, context))

print("Camera init completed")

i=0
while True:
  i+=1
  start = perf_counter()

  camera_file_path = gp.check_result(gp.gp_camera_capture(camera, gp.GP_CAPTURE_IMAGE, context))
  camera_file = gp.check_result(gp.gp_camera_file_get(camera, camera_file_path.folder, camera_file_path.name, gp.GP_FILE_TYPE_NORMAL, context))

  gp.gp_file_save(camera_file, "photo{0:03d}".format(i))
  gp.gp_camera_file_delete(camera, camera_file_path.folder, camera_file_path.name, context)

  del camera_file, camera_file_path

  timing = perf_counter() - start
  print("photo{0:03d} timing: {1:.3f}".format(i, timing))

The output:

Camera init completed
photo001 timing: 1.743
photo002 timing: 1.909
photo003 timing: 2.172
photo004 timing: 2.334
photo005 timing: 2.393
photo006 timing: 2.515
photo007 timing: 2.595
photo008 timing: 2.957
photo009 timing: 3.268
photo010 timing: 3.565
photo011 timing: 3.728
photo012 timing: 4.072
photo013 timing: 4.562
photo014 timing: 4.815
photo015 timing: 5.044
photo016 timing: 5.488
photo017 timing: 5.957
photo018 timing: 6.463
photo019 timing: 6.970
photo020 timing: 7.454
photo021 timing: 7.564
photo022 timing: 7.889
photo023 timing: 8.013

Best regards, scus1

scus1 commented 7 years ago

This is a libgphoto2 issue. I compiled 2.5.11 and now it works...

EDIT: The error occurred in version 2.5.4

jim-easterbrook commented 7 years ago

Apologies for not responding earlier - I've been on holiday. I'm glad you were able to solve the problem and especially glad that it's not a bug in the Python interface!