Can Scripting do this?

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
GregMcKay
Posts: 10
Joined: Wed Sep 06, 2017 6:43 pm

Can Scripting do this?

Post by GregMcKay » Wed Oct 16, 2019 2:55 am

I have no clue how to code using Python but I'm looking to do something that "seems" kinda simple with programming.
For the upcoming Mercury Transit, I'll be capturing the transit with my Solar Ha scope. What I'd like to do is create a timelapse of the transit and if there are any Ha imagers here you know that to get the solar edge prominences and surface detail you have to record two different exposures, one for the surface and another for the edge that blows out the surface detail.
I'd like to know if it's possible with scripting to set it up to record .ser files something like 10 sec at one exposure for the surface and place that file in one folder then maybe 30 seconds later, 10 seconds at a longer exposure for the edge prominences and place that file in a different folder. And make this loop for the entire time of the transit.
Is this possible? Anyone care to give me a hand? I'll share credit on the results if everything works on Nov.11th. :D

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

Re: Can Scripting do this?

Post by admin » Wed Oct 16, 2019 7:18 pm

Hi,

Yes, this should all be achievable. You can certainly adjust the exposure by for example code like

Code: Select all

SharpCap.SelectedCamera.Controls.Exposure.ExposureMs = 100
That will set the exposure to 100 ms.

Setting up and running a capture can be implemented with code like this

Code: Select all

from SharpCap.UI import CaptureLimitType
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.TimeLimited
from System import TimeSpan
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitTime = TimeSpan.FromSeconds(10)
SharpCap.TargetName = "surface"
SharpCap.SelectedCamera.PrepareToCapture()
SharpCap.SelectedCamera.RunCapture()
You can then run a second capture changing the target name to prominences which will ensure that your capture files are separated. You can also set the capture output format scripting if you want or you can have that preset to the correct format. Once you have the step set up to run single capture then you can duplicate the code to run the pair that you are describing and then put the whole lot in the loop to repeat it many times.

Hope this helps, Robin

GregMcKay
Posts: 10
Joined: Wed Sep 06, 2017 6:43 pm

Re: Can Scripting do this?

Post by GregMcKay » Sun Oct 20, 2019 5:53 pm

Thanks Robin,

Hopefully you've given me enough info that I can figure out the rest on my own. I'll let you know.

GregMcKay
Posts: 10
Joined: Wed Sep 06, 2017 6:43 pm

Re: Can Scripting do this?

Post by GregMcKay » Sun Oct 20, 2019 9:19 pm

I guess there's a lot more to it than this. No clue where to go with this.
Thanks for the help though.
Are there any videos that show scripts being written? The help file I believe assumes people understand how to write code. For someone like myself that is clueless, a video usually helps.

Purgitoria
Posts: 1
Joined: Sat Oct 26, 2019 4:53 pm

Re: Can Scripting do this?

Post by Purgitoria » Sat Oct 26, 2019 5:00 pm

This should create 2 separate folders in whatever location you have selected within the code as your save location (CaptureFolder). One will have a dated folder with a sub folder called Surface with a 20ms exposure setting and the other the same with a sub folder called Prominance with a 60ms exposure setting. The script will capture 1000 frames on each setting and take a 30 second pause before restarting the sequence all over again and each new clip will be simply named with the time stamp for when it was taken. The best way to use this would be to open up scripting and copy/paste it into the pad at the bottom and then save the script to a location of your choice, then when you want to use it select scripting from the main menu, click run script and select the file you saved. The only thing i will mention is that you will find that it locks out the scripting function for anything else as it is then stuck on a permanent loop and you would need to just close SharpCap to get the script to stop. I am sure someone else might be able to write a more elegant solution than this quick and dirty version but i have never worked with Python before so my knowledge is a little thin but i did enjoy the challenge of figuring it out and hope you find the script useful.

If you want to change the exposure or the number of frames then just edit the values for the Exposure.Value and CaptureLimitCount as required in a text editor such as notepad and resave the file.

Code: Select all

import time

while True:
#capture surface detail
  import clr
  clr.AddReference("SharpCap")
  from SharpCap.UI import CaptureLimitType
  SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.FrameLimited
  SharpCap.SelectedCamera.CaptureConfig.CaptureLimitCount =1000
  SharpCap.SelectedCamera.Controls.Exposure.Value = 20
  SharpCap.Settings.CaptureFolder = r'E:\Mercury Transit 2019'
  SharpCap.TargetName = "Surface"

#start the capture
  SharpCap.SelectedCamera.PrepareToCapture()
  SharpCap.SelectedCamera.RunCapture()
  while True:
    if not SharpCap.SelectedCamera.Capturing :
      break
    time.sleep(0.5)

#capture prominance detail
  import clr
  clr.AddReference("SharpCap")
  from SharpCap.UI import CaptureLimitType
  SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.FrameLimited
  SharpCap.SelectedCamera.CaptureConfig.CaptureLimitCount = 1000
  SharpCap.SelectedCamera.Controls.Exposure.Value = 60
  SharpCap.Settings.CaptureFolder = r'I:\Mercury Transit 2019'
  SharpCap.TargetName = "Prominance"

#start the capture
  SharpCap.SelectedCamera.PrepareToCapture()
  SharpCap.SelectedCamera.RunCapture()
  while True:
    if not SharpCap.SelectedCamera.Capturing :
      break
    time.sleep(0.5)

#wait 30 seconds before next run
  time.sleep(30)
EDIT: I should point out that the specific way that files are saved and named is completely dependent on how you set it up in the SharpCap settings under the filenames tab, for this example i was using the default settings. The save folders listed in the code need to be created before running the script.

joeastro
Posts: 9
Joined: Thu Feb 13, 2020 7:09 am

Re: Can Scripting do this?

Post by joeastro » Thu Feb 20, 2020 10:11 pm

hi
scritping PY something dont do write!@!

SharpCap.SelectedCamera.Controls.Exposure.Value = 20

this is one of them.. on the gui buttons to the right of quick picks list is [] check box auto
the auto will try and make your image brightness exposurelength long enough..so you can get an image.

but when you run the Exposure.value =20 seconds

it might be taken as 20 ms

but after the script runs AUTO is check boxed.. and if you run your script again
with out unchecking the auto...check box.. it wil fail to load the 20 seconds say..

its bug probably

joe

Post Reply