Execute a focus assistant tool from script

Discussions on extending SharpCap using the built in Python scripting functionality
mdborland
Posts: 4
Joined: Sat Oct 01, 2022 4:48 pm

Re: Execute a focus assistant tool from script

#11

Post by mdborland »

Robin,

Unfortunately,I really need to run autofocus from a python script. I don't see a way to implement my data collection in the sequencer.

Hope you can find a solution.

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

Re: Execute a focus assistant tool from script

#12

Post by admin »

Hi Michael,

the workaround for now until I fix it would be to use the script to run a one line sequence

Code: Select all

SharpCap.Sequencer.RunSequenceFile('path\to\one\line\sequencefile.scs')
I will try to fix it for direct access from scripting in the next update.

cheers,

Robin
mdborland
Posts: 4
Joined: Sat Oct 01, 2022 4:48 pm

Re: Execute a focus assistant tool from script

#13

Post by mdborland »

Robin,

The workaround solves the problem.

Thanks.

--Michael
graems
Posts: 9
Joined: Sat May 27, 2023 7:33 am

Re: Execute a focus assistant tool from script

#14

Post by graems »

I am using scripting to automate my telescope/focuser/camera for occultation recording through the night. I use temperature compensated focusing to keep focus in the right ballpark through the night. I also like to run SharpCap.RunRefocus before each occultation to be more precise. But there are cases where the RunRefocus might fail (clouds) and the focus window stays open. At high frame rates this can cause an extra 20% loading on my processor which I would like to avoid during camera recording.

Is there a method available to close the focus window from scripting or sequencing commands or pause its functioning?

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

Re: Execute a focus assistant tool from script

#15

Post by admin »

Hi Graem,

yes, you can close the focus tool from scripting with something like

Code: Select all

SharpCap.Transforms.SelectedTransform = None
It is important not to do that until the refocus attempt has completed though - if you do it while it is still in progress then it will probably cancel/fail the refocus. The default behaviour of the tool remaining open on a failed refocus is deliberate, but aimed at interactive use - in the case of a failure, viewing the focus graph to see what might have happened is probably informative.

cheers,

Robin
graems
Posts: 9
Joined: Sat May 27, 2023 7:33 am

Re: Execute a focus assistant tool from script

#16

Post by graems »

Thanks Robin - that works great (from my limited testing as it is currently snowing).

Using the following commands:
SharpCap.SafeGetAsyncResult(SharpCap.RunRefocus())
SharpCap.Transforms.SelectedTransform = None

Graem
Post Reply