0

我正在尝试为尼康 D7200 设置自动对焦区域

我检索了配置对象并在其中看到了以下条目:

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

我不太确定要传递哪些参数gp_camera_set_single_config()

根据我需要传入 的代码库gp_camera_set_single_config, ($self, name, widget, context)

为了将自动对焦的中心更改为像素 100x100 (WIDTH x HEIGHT),我尝试了以下命令,但没有真正到达任何地方。不知道是否有人碰巧知道如何传递这个参数?

import gphoto2 as gp

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

# Method 1
gp.gp_camera_set_single_config(camera, 'changefarea', '100x100')

# Method 2
gp.gp_camera_set_single_config(camera, '--changefarea', '100x100')

# Method 3
gp.gp_camera_set_single_config(camera, 'changefarea', {
          "idx": "6,6,0,0",
          "ro": 0,
          "name": "changeafarea",
          "label": "Set Nikon Autofocus area",
          "type": 2,
          "typestr": "GP_WIDGET_TEXT",
          "value": "100x100"
 })

# Method 4
gp.gp_camera_set_single_config(camera, '--changefarea', {
          "idx": "6,6,0,0",
          "ro": 0,
          "name": "changeafarea",
          "label": "Set Nikon Autofocus area",
          "type": 2,
          "typestr": "GP_WIDGET_TEXT",
          "value": "100x100"
 })

更新 #1:
为了设置配置,您必须首先使用gp.gp_camera_get_single_config(camera, 'changefarea'). 仍然不确定要传递哪些参数。

4

1 回答 1

0

这是最终对我有用的东西,不确定要传递哪些值,当我发现时会更新:

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)
于 2022-01-31T18:23:52.487 回答