Insert timestamp with a python script

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

Insert timestamp with a python script

#1

Post by michastro »

Hello,
I would like to know if it's possible to force the timestamp in the picture with a python script? My goal is to use NINA software to manage rmy remote observatory in Chile, to point the correct field ..etc and then launch automaticly Sharpcap with a pytrhon scrip to take a sequence. I make video of occultation by asteroids, and Sharpcap is perfect, but to "prepare" the field I use Nina, and also sometime with my work and lag between France and Chile, I can't be on my computer during the occultation. With all these things made automaticly, it will be perfect.
Thanks for your help
Michel
User avatar
admin
Site Admin
Posts: 13523
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Insert timestamp with a python script

#2

Post by admin »

Hi Michel,

yes, if you are looking to add the timestamp overlay into the top left of each frame then you can turn that on via scripting. Once the camera is open, run this line

Code: Select all

SharpCap.SelectedCamera.Controls.FindByName("Timestamp Frames").Value = "On"
Hope this helps,

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

Re: Insert timestamp with a python script

#3

Post by michastro »

OK, wonderfull. Where can I have the list of the command for FindByName? My SharpCap version is in french, can I use french command??
Thanks
Michel
User avatar
admin
Site Admin
Posts: 13523
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Insert timestamp with a python script

#4

Post by admin »

Hi Michel,

easiest through the python scripting

Code: Select all

for x in SharpCap.SelectedCamera.Controls:
 	print (x.Name)
You can also print the DisplayName of the control, which I think will give the French translation.

cheers,

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

Re: Insert timestamp with a python script

#5

Post by michastro »

Whaouh, exactly what I want to do buit for instance it doesn't work.
I have a script:
SharpCap.SelectedCamera = SharpCap.Cameras[0]
SharpCap.SelectedCamera.Controls.FindByName("Images d'horodatage").Value = "On"
SharpCap.SelectedCamera.Controls.FindByName("Zone de capture").Value = "480x480"
SharpCap.SelectedCamera.Controls.FindByName("Exposition").Value=0.5
SharpCap.SelectedCamera.Controls.FindByName("Mode haute vitesse").Value="Off"
SharpCap.SelectedCamera.Controls.FindByName("Espace colorimétrique").Value="MONO16"
SharpCap.SelectedCamera.PrepareToCapture()
SharpCap.SelectedCamera.RunCapture()

and I have a .bat file with:
"C:\Program Files\SharpCap 4.0 (64 bit)\SharpCap.exe" /runscript "C:\Users\PC T520 CHILI\Documents\Sharpcap\Occultation.py"
SharpCap start that's all, the camera is not connected and I have of course no exposure!! If I launch the script inside SharpCap, it's working.
A last thing, I don't know how to program the total time of exposure, for an occultation it's about 120s to be sure to get it.
Thanks
Michel
User avatar
admin
Site Admin
Posts: 13523
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Insert timestamp with a python script

#6

Post by admin »

Hi Michel,

looks like the startup script running from the command line is broken - I will fix it in the next SharpCap 4.1 beta.

To set up a 120s capture, you do

Code: Select all

from SharpCap.UI import CaptureLimitType
from System import TimeSpan
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.TimeLimited
SharpCap.SelectedCamera.CaptureConfig.CaptureLimitTime = TimeSpan.FromSeconds(120)
That sort of thing is actually easier using the sequencer rather than scripting - you can set up a sequence and run it from scripting if you want

Code: Select all

SharpCap.Sequencer.RunSequenceFile("path to saved sequence.scs")
cheers,

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

Re: Insert timestamp with a python script

#7

Post by michastro »

Ok thank you Robin, I am waiting for the next beta. A last thing, as after the occultation I will return to NINA, I need to disconnect the camera in the script, I am not sure how to do that. For your information I have made several positive occultations with Sharpcap and it's a real pleasure.
Best Regards
Michel
michastro
Posts: 19
Joined: Wed Jan 22, 2020 12:10 pm

Re: Insert timestamp with a python script

#8

Post by michastro »

Hi again,
I have download too the 3.2 version, and simplified my .bat file:
cd "C:\Program Files\SharpCap 3.2 (64 bit)"
SharpCap.exe /runscript C:\Occultation.py

but the problem is still there, I have tried also with version 4.0:
cd "C:\Program Files\SharpCap 4.0 (64 bit)"
SharpCap.exe /runscript C:\Occultation.py

But it seems in fact that the script is not launched !!
Michel
User avatar
admin
Site Admin
Posts: 13523
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Insert timestamp with a python script

#9

Post by admin »

Hi Michel,

yes, it looks like the bug has been there a long time. The command line parameter is correctly processed and the file is added to a list of files to be run at startup. However, the actual code cannot be started until a few other things have been set up, and by then the list of files has been reset to only those in the 'Startup scripts' settings :(

New version of 4.1 will be available next Monday with the fix in it (which I have tested and it is working).

cheers,

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

Re: Insert timestamp with a python script

#10

Post by michastro »

A last question, before to give again the control to NINA, I need to disconnect the camera. How can I do that?
Thanks
Michel
Post Reply