Automate sun acquisition

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
julien.t
Posts: 28
Joined: Mon Jan 15, 2024 9:05 pm

Automate sun acquisition

#1

Post by julien.t »

Hi,

I'm trying to automate my sun acquisition and began to write a script.

The steps would be the following :

After having done a first focus and a feature tracking calibration, when I run the script, I want to :

1. Refocus
2. start an acquisition of n frames
3. stop the feature tracking
4. close the flip flat cover. As I have some performance issues (see viewtopic.php?t=9479 ) this would be done by calling an external script)
5. adjust the flat exposure (approx. 30x the acquisition exposure) ideally retrieve the histogram value to adjust more precisely the flat exposure.
6. start an acquisition of m frames (flats)
7. open the flip flat cover
8. reset the exposure time
9. resume the feature tracking.


To be sure I'm heading in the right direction and I don't try to do impossible things. I would like to know if all these operations are possible.
I managed to do :
- steps 1, 2, 4, 6, 7 and 8.
- Partially the 5, I'm able to set an exposure value, but I don't know if it would be possible to get histogram data.
- For steps 3 and 9 I didn't find any information in the documentation, I don't know if it is even possible.

Regards,

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

Re: Automate sun acquisition

#2

Post by admin »

Hi,

stopping and resuming feature tracking will require you to use SharpCap 4.2 beta - there is a new SharpCap.FeatureTracking API that will let you do what you need for those two items.

To be honest, for the autoexposure, it might be best not to try to implement it yourself - you would need to hook the 'framecaptured' event to get notified of each image coming from the camera, call 'CalculateHistogram' on the frame to get the histogram data, interpret the histogram, adjust exposure/gain, wait a few frames for changes to take effect and repeat until happy with the exposure - it's a significant amount of effort - I know, having written code like that for the various auto exposure features in SharpCap...

SharpCap already has code that will do it's best to autoexpose for flat frames, but I don't think you can currently access it from scripting - if I make that available from scripting and/or the sequencer then that would probably be best.

Hope this helps, let me know what you think about the autoexposure part.

cheers,

Robin
julien.t
Posts: 28
Joined: Mon Jan 15, 2024 9:05 pm

Re: Automate sun acquisition

#3

Post by julien.t »

admin wrote: Wed Jul 08, 2026 1:40 pm stopping and resuming feature tracking will require you to use SharpCap 4.2 beta - there is a new SharpCap.FeatureTracking API that will let you do what you need for those two items.
Perfect
admin wrote: Wed Jul 08, 2026 1:40 pm SharpCap already has code that will do it's best to autoexpose for flat frames, but I don't think you can currently access it from scripting - if I make that available from scripting and/or the sequencer then that would probably be best.
That's exactly what I'm looking for. Making it available from scripting would be great.

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

Re: Automate sun acquisition

#4

Post by admin »

Hi,

I was looking into adding access to the flat frame autoexposure to scripting or the sequencer and realised that it was already there - there is a 'flat frame auto set exposure/gain' step in the sequencer that can be used. Since you are mainly working from scripting, you will need to launch the sequencer step from your script using SharpCap.Sequencer.RunSequence('sequence code')

cheers,

Robin
julien.t
Posts: 28
Joined: Mon Jan 15, 2024 9:05 pm

Re: Automate sun acquisition

#5

Post by julien.t »

Hi,

Sorry for the late reply. For some reason, I didn’t receive the notification.

OK, I will try with the sequencer
julien.t
Posts: 28
Joined: Mon Jan 15, 2024 9:05 pm

Re: Automate sun acquisition

#6

Post by julien.t »

Hi,

I tried and it works. Thanks

Regards,

Julien
Post Reply