Python - gphoto2: how to capture image Canon 5D Mark IV

1.3k views Asked by At

I am using gphoto2 to capture photos from camera

So far, I can capture photo successfully using command line

command = ["sudo","gphoto2","--set-config","manualfocusdrive=6","--set-config","capturetarget=1","--capture-image"]
call(command)

However, I am failed to capture photo using python code (from example)

Error:

> WARNING: gphoto2: (gp_port_usb_close [libusb.c:325]) Invalid
> parameters: 'port && port->pl->dh' is NULL/FALSE. Capturing image
> Camera file path: //capt0000.jpg ('Copying image to',
> '/tmp/capt0000.jpg') Error: no "view" rule for type "image/jpeg"
> passed its test case
>        (for more information, add "--debug=1" on the command line) /usr/bin/xdg-open: 771: /usr/bin/xdg-open: www-browser: not found
> /usr/bin/xdg-open: 771: /usr/bin/xdg-open: links2: not found
> /usr/bin/xdg-open: 771: /usr/bin/xdg-open: elinks: not found
> /usr/bin/xdg-open: 771: /usr/bin/xdg-open: links: not found
> /usr/bin/xdg-open: 771: /usr/bin/xdg-open: lynx: not found
> /usr/bin/xdg-open: 771: /usr/bin/xdg-open: w3m: not found xdg-open: no
> method available for opening '/tmp/capt0000.jpg' WARNING: gphoto2:
> (ptp_usb_getresp [usb.c:482]) PTP_OC 0x911c receiving resp failed: PTP
> Device Busy (0x2019) WARNING: gphoto2:
> (camera_unprepare_canon_eos_capture [config.c:557])
> 'ptp_canon_eos_resetuilock (params)' failed: PTP Device Busy (0x2019)
> WARNING: gphoto2: (gp_port_usb_close [libusb.c:325]) Invalid
> parameters: 'port && port->pl->dh' is NULL/FALSE.

Any suggestion is appreciated. I am quite new with this gphoto2.

1

There are 1 answers

1
Jim Easterbrook On

The script is failing because 'xdg-open' can't find a photo viewer. You should have a captured photo in '/tmp/capt0000.jpg'.

The warning messages are typical libgphoto2 verbosity and can be ignored.