No capture with a script in python

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
michastro
Posts: 19
Joined: Wed Jan 22, 2020 12:10 pm

No capture with a script in python

#1

Post by michastro »

Hello,
I have a script wich seems to work fine except thatr nothing is captured!!
Here is my script:

Code: Select all

from time import sleep
from System import TimeSpan
from SharpCap.UI import CaptureLimitType
delay =30
SharpCap.SelectedCamera = SharpCap.Cameras[0]
SharpCap.SelectedCamera.Controls.FindByName("Timestamp Frames").Value = "On"
SharpCap.SelectedCamera.Controls.FindByName("Capture Area").Value = "480x480"
SharpCap.SelectedCamera.Controls.FindByName("Exposure").Value=1
SharpCap.SelectedCamera.Controls.FindByName("High Speed Mode").Value="On"
SharpCap.SelectedCamera.Controls.FindByName("Binning").Value="2"
SharpCap.SelectedCamera.Controls.FindByName("Colour Space").Value="MONO16"
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.TimeLimited
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitTime = TimeSpan.FromSeconds(delay)
SharpCap.SelectedCamera.PrepareToCapture()
SharpCap.SelectedCamera.RunCapture()
sleep(delay+5)
SharpCap.SelectedCamera = None
SharpCap.ExitApplication()
The number of frames captured in the bottom of page stays at 0!
I have forgotten something, but I don't know what.
Thanks for your help.
Michel
User avatar
admin
Site Admin
Posts: 13347
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: No capture with a script in python

#2

Post by admin »

Hi Michel,

what version of SharpCap are you using and what camera? I tried this out in the latest 4.1 (using the 'high speed' test camera and an Altair camera) and both worked.

I simplified the script down to

Code: Select all

from time import sleep
from System import TimeSpan
from SharpCap.UI import CaptureLimitType
delay =30
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.TimeLimited
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitTime = TimeSpan.FromSeconds(delay)
SharpCap.SelectedCamera.PrepareToCapture()
SharpCap.SelectedCamera.RunCapture()
sleep(delay+5)
SharpCap.SelectedCamera = None
which just works on the current camera with the currently selected settings.

One thing that might be possible is that the change of certain controls may need a delay after it happens to allow the camera to restart in the new mode - resolution, bit depth, binning are among the controls that could require this.

cheers,

Robin
michastro
Posts: 19
Joined: Wed Jan 22, 2020 12:10 pm

Re: No capture with a script in python

#3

Post by michastro »

Thanks as usally for your help Robin,
In fact after a lot of different tests, the cameras was working in Ascom mode, but not in native SharpCap mode, I had to shut down the camera AND the PC (to shut down USB) to unlock the camear, and now the script is working!
Michel
User avatar
admin
Site Admin
Posts: 13347
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: No capture with a script in python

#4

Post by admin »

Hi,

good to hear you got it working - what camera was it by the way? Just wondering if I have a bug in the direct support somewhere?

cheers,

Robin
michastro
Posts: 19
Joined: Wed Jan 22, 2020 12:10 pm

Re: No capture with a script in python

#5

Post by michastro »

A ZWO 6200
User avatar
admin
Site Admin
Posts: 13347
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: No capture with a script in python

#6

Post by admin »

Hi,

normally the ZWO cameras are pretty well behaved - I wonder if it got confused by being accessed both directly and via ASCOM in one session?

Let's hope it stays well behaved in future!

cheers,

Robin
Post Reply