gpt4 book ai didi

python - 使用 digicamcontrol 使用 Python 控制尼康相机?

转载 作者:行者123 更新时间:2023-12-04 02:06:03 28 4
gpt4 key购买 nike

有没有人在 Windows 上成功地做到这一点?我正在尝试命令 DSLR 相机在 Windows 机器上通过 USB 使用 Python 拍照。或者您有更好的解决方案吗(我无法切换到 Linux)。

最佳答案

顺便说一下,这里有一个可行的解决方案,使用 Python 3.5(通过 Anaconda 安装)。

ISO 和快门的参数是硬连线的,但如果您需要它,这应该可以帮助您。

import sys
import os
import subprocess
import datetime

def func_TakeNikonPicture(input_filename):
camera_command = 'C:\Program Files (x86)\digiCamControl\CameraControlCmd.exe'
camera_command_details = '/filename ./' + input_filename + ' /capture /iso 500 /shutter 1/30 /aperture 1.8'
print('camera details = ',camera_command_details)
full_command=camera_command + ' ' + camera_command_details
p = subprocess.Popen(full_command, stdout=subprocess.PIPE, universal_newlines=True, shell=False)
(output, err) = p.communicate()

#This makes the wait possible
p_status = p.wait(1)
# print(p.stdout.readline())

#This will give you the output of the command being executed
print('Command output: ' + str(output))
print('Command err: ' + str(err))

print('done')


if(len(sys.argv) < 2):
rawimagename = 'test.jpg'
else:
# sys.argv[0] is the program name, sys.argv[1] is the first file, etc.
# need to shift this over
files = sys.argv[1:len(sys.argv)]
# Read the image
rawimagename = files[0]
if(os.path.isfile(rawimagename) is True):
print("File exists...not overwriting.")
sys.exit()

# Store date/time for file uniqueness
current_dt=datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
print("Current date time = " + current_dt)
rawimagename=current_dt + '_' + rawimagename

print('Name of raw image will be: ', rawimagename)

# take picture
func_TakeNikonPicture(rawimagename)

关于python - 使用 digicamcontrol 使用 Python 控制尼康相机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43358257/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com