gphoto2 icon indicating copy to clipboard operation
gphoto2 copied to clipboard

Convert from shell commands to command line interface

Open oyvindmjakobsen opened this issue 2 years ago • 1 comments

Being new to gphoto2, i would like to ask for guidelines or hints to move from a functioning set of commands in gphoto2 shell, to one gphoto2 command to be run through the command line interface (CLI). The task itself relates to focus stacking of Canon EOS 90D: Acquire an initial image based on autofocus, then acquire a given number of additional images with different focus. The task is to be automated by a bash script which will be triggered upon user request or will be set to be run at a given frequency. The bash script will also include code for the operation of different equipment, such as lights, etc (outside the scope of this post). After crawling different discussions on these pages, and some trial and error, I have successfully identified a strategy using the shell (see below).

So, the question: Given the functioning shell strategy (see below), how can I implement this in one or several gphoto2 commands, to be run using the command line interface?

Current strategy (with my interpretation of the commands as comments): First make sure camera does not disconnect: gphoto2 --set-config capture=on Then start shell, and command the camera from there: gphoto2 --shell The following commands are written inside shell: set-config viewfinder=1 # Go to live mode set-config eoszoomposition=2075,1375 #Set focus point set-config autofocusdrive=1 #Do autofocus (at the given focus point) set-config-index eosremoterelease=5 #Press Shutter button set-config-index eosremoterelease=4 #Release Shutter button set-config-index manualfocusdrive=5 #Drive the focus motor: Move focus two steps farther away set-config-index eosremoterelease=5 #Press Shutter button set-config-index eosremoterelease=4 #Release Shutter button

...and then the three last lines can be repeated as much as you'd like, depending on the focus range you need to cover. Then images can be downloaded and deleted on the internal memory card (not covered by the above code). And finally, the images can be processed for focus stacking.

oyvindmjakobsen avatar Mar 24 '22 14:03 oyvindmjakobsen

So, to follow up, in case this can help anyone else struggling with the same question: I managed to pack the above shell code into one gphoto2 command, to be entered at gphoto2 CLI, simply by stacking them after eachother, and adding a wait-event-and-download (triggered by the event ObjectRemoved) in between each press and release of the shutter botton. The following code captures two images, at different focus:

gphoto2 --set-config viewfinder=1 --set-config eoszoomposition=2075,1375 --set-config autofocusdrive=1 --set-config-index eosremoterelease=5 --wait-event-and-download=ObjectRemoved --set-config-index eosremoterelease=4 --set-config-index manualfocusdrive=5 --set-config-index eosremoterelease=5 --wait-event-and-download=ObjectRemoved --set-config-index eosremoterelease=4

And obviously, multiple focusdrives and captures can be added simply by extending the command. I verified the possibility to capture 10 images, all with different focus. And then used these for focus stacking through Canon Digital Photo Professional 4. I verified this functionality with 3 different Canon lenses, 18-135, 50 and 100mm.

I am, however, still wondering if this is anywhere near best practice. For example, if I try to end the command with "--set-config viewfinder=0" (in an attempt to return from live mode), i get an -110: 'I/O in progress' error.

Therefore, any tips or suggestions are still very welcome. Including how to initialize and wrap up this command in the best way (i.e. make sure the camera goes back to an OK idling mode, waiting for the next gphoto2 command).

oyvindmjakobsen avatar Mar 25 '22 09:03 oyvindmjakobsen