gphoto / gphoto2

The gphoto2 commandline tool for accessing and controlling digital cameras.
GNU General Public License v2.0
717 stars 116 forks source link

[QUESTION] How to mimic autofocus functionality on camera #484

Open mexicantexan opened 2 years ago

mexicantexan commented 2 years ago

Describe the bug Not a bug, just a question. On my Nikon D7200, I have the ability to tap the touch screen on the back or move a cursor to autofocus on a specific point. In the config dictionary I get back from the camera I saw this entry:

{
          "idx": "6,6,0,0",
          "ro": 0,
          "name": "changeafarea",
          "label": "Set Nikon Autofocus area",
          "type": 2,
          "typestr": "GP_WIDGET_TEXT",
          "value": "0x0"
 }

Is this where I would make the adjustment to get the desired functionality? I've adjusted it with various inputs, but haven't seen any changes and am slightly lost at this point.

Name the camera Nikon D7200

libgphoto2 and gphoto2 version gphoto2 2.5.23

To Reproduce Current code in python

import gphoto2 as gp

camera = gp.check_result(gp.gp_camera_new())
context = None
gp.check_result(gp.gp_camera_init(camera, self.context))

config_name =  "changeafarea"
value = "100x100"  # in my code I have it linked up to PyQt5 window where I am clicking around the live-view and the pixel value of where I clicked is being passed back and formatted into this string format

while True:
          # wait for config widget
          config_widget = gp.gp_camera_get_single_config(self.camera, config_name)
          if config_widget[1] is not None:
              break
config_widget = config_widget[1]
config_set_response = gp.gp_widget_set_value(config_widget, value)
print('set response:', gp.gp_widget_get_value(config_widget))
gp.gp_camera_set_single_config(camera, config_name, config_widget)
mexicantexan commented 2 years ago

I guess manually setting the focus, in general, would be helpful. I can't seem to find any differences in the configuration library when I manually adjust the manual focus myself :/

roguh commented 4 months ago

Hey, I found this for operating a Nikon: https://mvmn.wordpress.com/2017/01/01/dslr-focus-control-with-gphoto2/

You've got to set it to liveview in shell mode before it can do any focusing operations.

This is an example of shell mode with redirection so you don't need to type into the gphoto shell as often: gphoto2 --shell --debug --debug-loglevel debug <<< capture-image