Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

SharpCap Pro Scripting?


SiriusDoggy

Recommended Posts

Does anybody here know how to use IronPython scripting that is used in SharpCap Pro?

I'm looking for help writing a very simple script....at least I think it should be.  But I'm completely dumb when it comes to this language and am having no luck on my own.

Here's what I wish to do for the upcoming Mercury Solar Transit with my Lunt 80mm Ha scope. I want to make a timelapse video from a series of stacked .ser files. I want to shoot 1000 frames once every 30 seconds that is exposed for the surface. exposure time TBD.

Then, I want to shoot another 1000 frames exposed for the edge prominence details. I would like to place these two files in two different directories on separate harddrives. And of course have this script repeat itself for the entire duration of the transit. Renaming and/or numbering the files would be a bonus.

I've posted the same request on the SharpCap forum and received limited help from the admin because I think he assumes I understand the scripting language which I do not. I understand it enough to edit exposure times and directory locations but the whole language is just very confusing to me.  Any help would be greatly appreciated. 

 

Link to comment
Share on other sites

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'E:\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)

This assumes you have created the folders already and will throw an error message if they do not exist.

Default SharpCap settings were used in relation to file naming so all files will be named as per your preferred setting put in the UI beforehand.

You can use notepad to edit the file to put in your own drive locations and settings for exposure, frame count and sleep time before next run.

Copy the contents of the script above and paste into the pad of the scripting tool in SharpCap, put your required settings in then save to to your hard drive, when needed from the min UI select "scripting - run script" and navigate to the saved file and the script will immediately start. From the scripting console click on the stop script button on the pad at the bottom to finish.

Edited by purgitoria
  • Like 1
Link to comment
Share on other sites

Wow man! Thanks so much. I'm at work now but excited to give it a try when I get home this evening. I understand what you are saying about the destinations but I know how to change that part of the script. I'm anxious to try it!  

I'll report back later and let you know if everything flows ok.

Thanks so much for the assistance!  I didn't realize it would take that much code to do this.

Link to comment
Share on other sites

It is actually not that much code as a lot of the settings come from within the GUI already such as gain, output format etc. It is really only the settings that will be changing or that cannot be set from the GUI that need to be added along with the time delay.

I have noticed however that for some reason there is a bug that does not always allow the script to be stopped from the console if you select "run script" so it may be better to open it in the pad and then run it so you should always have the option to stop the running script but even then there is some bug that can leave SharpCap stuck in a "finishing capture" mode. It seems this can be negated by clicking "stop capture" on the GUI until you see previewing again and then stopping the script.

I also made a minor edit to the code in relation to how the save location is referenced as there was a possibility it could have thrown an error depending on the filename as the path separator "\" is also an escape character in Python it seems and if followed by specific letters can give it unintended functions.

 

Edited by purgitoria
Link to comment
Share on other sites

So I finally had a chance to run the script. And I'm running into a new problem. I believe the script is set to record single frame images and what I need the script to do is record short video clips in the .ser format. It seems to be trying to record a single frame in the .ser format so it is attempting to record, but how do I change it so that it records for a single 10 second or 1000 frame video clip at an exposure of 20 milliseconds? Maybe I'm not understanding something. I did manage to change the file folder location in the script.

 

Thanks again.

Link to comment
Share on other sites

I have fully tested the script and can get it to output in any format and have samples in both .avi and .ser. When using this script the output is not explicitly set within the script as there is no need to do so and it makes it more versatile for anyone else who wants to use it for outputting to their own preferred format. You must ensure that in the GUI you explicitly set the file type before running the script in the "Capture Format and Area" section of the menu for the camera, just uncheck the auto button and select your preferred output from the drop down menu, by defaut when opening a camera the file type will be set to "auto" and ".png" i think or whatever the last output type was that you selected.

The frame count setting in the script shows the number of frames that it should be capturing and when running the script you will see in the bottom of the GUI the current actions, this should show a frame count and will tell you how many frames it is capturing and when it is previewing only. What makes you think it is capturing only one frame? If it is because you are getting .jpg or .png files then it is due to the above mentioned setting.

Link to comment
Share on other sites

Yes,  I understand about setting the file format in the GUI. I have it set to .ser and it is recording a .ser file. When I open it in SerPlayer it shows a single frame.

I only had time last night for a quick check as I needed to get to bed for an early work start again. I've got a few days coming up starting tomorrow so I'll have time to do some more troubleshooting. I'll post a screen capture of what's happening if the problem continues. 

Thanks again! 

Link to comment
Share on other sites

I have run the script several times capturing in both .avi and .ser and used the SER player V1.7.2 to play back the .ser files and VLC player the .avi files and both work just fine on my computer. My setup has a DMK41AU02.AS camera on the desk as this is what i use for developing and testing of my own all sky camera software. The following is the output from the automatically generated settings file that SharpCap spits out with every video clip. I am getting clips 2 seconds and 6 seconds long with my test sequence (i am using 100 as a frame count to save time and drive space while testing), if you are using the 1000 frame count then you should get 20 and 60 second video clips. I imagine running at 1000 frame count you will be eating up huge amounts of HDD space (no wonder you wanted to write to 2 separate HDD's), at my resolution that is 1.14Gb per clip for the prominence data.

[DMx 41AU02.AS]
Output Format=SER file (*.ser)
Colour Space=MONO8
Resolution=1280x960
Frame Rate Limit=120 fps
Gain=260(Auto)
Exposure=0.0996(Auto)
Timestamp Frames=Off
Brightness=5
Banding Threshold=35
Banding Suppression=0
Apply Flat=None
Subtract Dark=None
#Black Point
Display Black Point=0
#MidTone Point
Display MidTone Point=0.5
#White Point
Display White Point=1
TimeStamp=2019-10-30T16:18:28.1640653Z
SharpCapVersion=3.2.6121.0

 

Perhaps also use SER Player to check the .ser file details, you should see something similar to this:

Filename: E:\Mercury Transit 2019\2019-10-30\Surface\17_34_11.ser

Filesize: 1228808178 bytes

 

Header Details:

* FileId: LUCAM-RECORDER

* LuID: 4660

* ColorID: 0 (MONO)

* LittleEndian: 0

* ImageWidth: 1280

* ImageHeight: 960

* PixelDepth: 8

* FrameCount: 1000

* Observer: Observer

* Instrument: DMx 41AU02.AS

* Telescope: telescope

* DateTime: 30/10/2019 17:34:11.123999 (0x8d75d5f6011573b)

* DateTime_UTC: 30/10/2019 16:34:11.123999 (0x8d75d56fe4cef3b)

 

Timestamps:

* Timestamps are all in order

* Min timestamp: 30/10/2019 16:34:11.216004 UT

* Max timestamp: 30/10/2019 16:37:01.349735 UT

* Min to Max timestamp difference: 2 min 50.1337 s

* Average frames per second: 5.87185

Link to comment
Share on other sites

I have finally had a chance to test again with a little more rest on my brain. I'm still running into errors but this time around it actually recorded the .ser files correctly. But it's still giving me an error after just 1.5 passes through the script. Rather then try to explain it, I just made a screencast of the actual capture and issue.  SharpCap Pro script error

Link to comment
Share on other sites

Fooling around with the script a little more I may have found the issue or at least a work-around. On line 20 and line 38 I changed the  time.sleep(0.5) to (1) and it is now running ok. At least in my short 10 minute test it did not error out.

Link to comment
Share on other sites

I am just curious on your setting of the exposure. I see you using .02 and wondered if that was intentional and if you were aware that exposure time in script is already quoted in milliseconds si there is no need to put a decimal value here. You could also be right in the sleep time as this script was tested with another camera brand and it could be that the ZWO takes longer to download the frames or may use some kind of buffer onboard the camera so until the buffer is cleared the camera is still busy dealing with the first capture and due to the script requiring the camera to not be capturing to process the next capture it throws the error, actual computer hardware may also cause issue if you are using a slower or older machine it may take a little longer to process the file and release the camera control. I can see at the bottom of the window that you are using 3 frames in the camera memory which looks like it is buffering to some extent possibly because your camera is higher resolution than what I am using and this would certainly explain the error you see as it would only happen when trying to capture the second “prominence” exposure. 

Link to comment
Share on other sites

Thanks! I'll keep tweaking the exposure times and sleep times once my new SSD drives arrive and I can do some true testing on the scope. I was not aware of the millisecond timing you mentioned. I think we're in good shape now so thanks again for your assistance with the script. I'll of course be posting the results around here after the event.

Link to comment
Share on other sites

  • 2 weeks later...

Well, the Mercury transit was a huge success here thanks to the script help I received here from Purgitoria. Thank you so much! If you ever make it out to Las Vegas, reach out and I'll buy you a beer.

I'm still working on the full animation but I've included a couple stills and a link to a very short animation test that I made of 3rd and 4th contact. Here in Las Vegas, the transit was already in mid progress so we missed 1st and 2nd contact. The planet was almost halfway through the transit at sunrise. I started imaging as soon as the sun rose above my neighbor's house at 6:50am but it honestly didn't get steady enough to animate until around 8am. So I have 2 hours worth of images to process and edit. I've figured out a few automation tricks to speed up the process.

This first shot is from around 8am.

spacer.png

This shot was at 9:58am, just 4 minutes from 3rd contact.spacer.png

The animation of 3rd and 4th contact. I haven't composited the edge prominence portion just yet.

spacer.png

 

 

  • Like 1
Link to comment
Share on other sites

Those are some great images 👍 Glad you liked the script and it worked out well for you and cant wait to see the final full animation, i am sure the processing and stitching is rather tedious but will be worth the effort when you are done. Wish i had been at home with the scope myself instead of working overseas, the last transit i managed to see was a short glimpse of the Venus transit back in 2012 in the only 1 minute gap in the cloud all day just before the sun dipped behind the mountains.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.