Python script

Post Reply
jucat8
Posts: 1
Joined: Thu Jan 21, 2016 1:39 pm

Python script

Post by jucat8 » Thu Jan 21, 2016 2:09 pm

Hello,

I need to write a script in Python on Windows 10 to capture 10 photos from a Nikon D3300. I use digicamcontrolcmd with this code :

Function capture :
def f_capture(i):
try :
photo = "C:\test\"+str(i)+".jpg"

cmd = "CameraControlCmd.exe /filename " + photo + " /capturenoaf"
subprocess.call(cmd.split(), bufsize=8192, stdin=None, stdout=None, stderr=None, shell=False)

In main :
while i <= 10:
f_capture(i)
i = i + 1

It does work for 2, 3, sometimes 4 photos, but suddenly stop working. I hear the camera taking the picture, but my script doesn't transfer it on my computer. When I press CTRL+C, I get this message :
New Camera is connected ! Driver :D3300
Photo transfer begin.
Transfer started :C:\test\4.JPG
Transfer done :C:\test\4.JPG
Photo transfer done.

New Camera is connected ! Driver :D3300
Traceback (most recent call last):
File "C:\Python27\lib\subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 1007, in wait
_subprocess.INFINITE)

It looks like for some reasons, my script wait indefinitely for I don’t know what.
I try to find something on the web.
I first had a look on this page https://docs.python.org/2/library/subprocess.html, and thought there was a problem of buffer, so I added bufsize=4096 in my script : not working.
I also find this page http://stackoverflow.com/questions/2033 ... ll-true-in and changed the COMPSEC variable : not working.

I use windows 10, Python 3.4, DigicamControl 2.0.0 and Nikon D3300
If you have any suggestions…

Python script

Advertisment
 

Post Reply