jim-easterbrook / python-gphoto2

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

How to capture image quicker #63

Closed gachiemchiep closed 5 years ago

gachiemchiep commented 5 years ago

Hello @jim-easterbrook

Thank you for your great work.

Do you know how to decrease the time which cost for capturing image ?

Currently my Nikon D5600 capture one image which has size 4000x3000 (h, w) in around 1.1 seconds. Is there any approach that help me reduce the capturing time in around 0.5 seconds.

logger.info("Capture")
file_path = gp.check_result(gp.gp_camera_capture(camera, gp.GP_CAPTURE_IMAGE))

logger.info("Capture 1")
camera_file = gp.check_result(gp.gp_camera_file_get(
    camera, file_path.folder, file_path.name, gp.GP_FILE_TYPE_NORMAL))

logger.info("Capture 2")
file_data = gp.check_result(gp.gp_file_get_data_and_size(camera_file))

logger.info("Convert")
img_pil = Image.open(io.BytesIO(file_data))
img = np.asarray(img_pil)
cv2.imwrite("{}.png".format(idx), img)
imgs.append(img)
[1537258708.4] [INFO] [    grab] START Grab
[1537258708.4] [INFO] [    grab] Capture
[1537258709.51] [INFO] [    grab] Capture 1
[1537258709.51] [INFO] [    grab] Capture 2
[1537258709.51] [INFO] [    grab] Convert
[1537258710.15] [INFO] [    grab] END Grab

Thank you for your kindness

jim-easterbrook commented 5 years ago

How does this compare with using the gphoto2 cli program? If it's similar, then the problem is in libgphoto2, not the Python interface.

gachiemchiep commented 5 years ago

Hello @jim-easterbrook

Using python wrapper and gphoto2 cli result in the same processing time. Is there any approach that i could use to shorten processing time ?

python log

[1537330979.35] [INFO] [    grab] START Grab
[1537330979.42] [INFO] [nikon_capture] Capture
[1537330980.55] [INFO] [nikon_capture] Capture 1
[1537330980.56] [INFO] [nikon_capture] Capture 2
[1537330980.56] [INFO] [nikon_capture] Convert
[1537330980.74] [INFO] [nikon_capture] write frame_00_0 into redis
[1537330980.87] [INFO] [    grab] END Grab

gphoto2 cli log libgphoto2.log

jim-easterbrook commented 5 years ago

Slow capture is obviously a problem with libgphoto2 itself, not with the Python interface. I don't know much about how libgphoto2 works. As explained in the README, questions about gphoto2 should be asked on the gphoto2 mailing list, not reported as a python-gphoto2 issue.

gachiemchiep commented 5 years ago

@jim-easterbrook

Thank you sir. I will go there for further information