Skip Advanced Capture

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
Posts: 15
Joined: Wed Mar 08, 2017 9:46 am

Skip Advanced Capture

Post by pgn » Sun Apr 16, 2017 8:06 am

I have a script that uses SharpCap.SelectedCamera.CaptureSingleFrameTo to capture pictures. Unfortunately I need the picture to be taken from the time that line runs, however I appears the Advanced Capture feature of the software causes the frame to be captured (at least partly) from stored data.

EG If I want a 5 second exposure and issue the capture command the picture could be captured immediately using the last 5 seconds and not the 5 seconds after the command was issued (or it might use the next 5 seconds if a picture has just completed - a little too unpredictable for what I need).

I have looked at the SharpCap.Initialize command (which refers to skipAdvancedCaptureProvider) but, if that is what I need, I need more info as to how to use it. Otherwise - what do I do?

Any insight would be gratefully appreciated.

[running on a beta versions - 2.10.3695
(Also commands copied without copy and paste so forgive any transcription errors)

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

Re: Skip Advanced Capture

Post by admin » Sun Apr 16, 2017 9:19 am


I'm afraid that the 'skip advanced capture' option isn't what you're looking for - that initialize call is designed to be called only once by the SharpCap application when setting up and calling it again won't have any good effects. Anyway, that option simple tells SharpCap not to load direct drivers to any camera, so if you did manage to persuade SharpCap to call that with the parameter set to false the first time then you'd get only ASCOM and Directshow cameras being detected...

The behaviour you describe - where the snapshot frame is the previous frame that was captured (ie the one showing on the screen at the moment) applies in 2.10 for exposures longer than 1 second. However, there is a check to see if the camera settings have been unchanged since the time that that previous frame was captured, so if you tweak any of the camera settings (gain, exposure, etc) by a tiny bit you should be able to stop that from happening.


Remember that SharpCap works as a video camera application, and frames are rolling all the time. If you set a 5 second exposure then you will get a new frame arrive every 5 seconds. If you start that at time t=0, then ask for a snapshot at time t=7, the snapshot will be completed at time t=10 and cover the time from t=5 to t=10 (and if you don't do the tweak of adjusting a parameter then your snapshot would cover the time from t=0 to t=5).

If you really want the snapshot to cover a particular section of time, then the best thing to do is to set the exposure to a lower value (0.01s) then set it to 5s when you want the snapshot to start, then grab a single frame, then set it back.

Hope this helps,


Posts: 15
Joined: Wed Mar 08, 2017 9:46 am

Re: Skip Advanced Capture

Post by pgn » Mon Apr 17, 2017 1:14 pm

Helped a lot. Many thanks.
The problem here is that I need to capture a frame from the time the "capture frame" command is given. And not use any previously buffered image data.

Here are my utilitarian code snippets. For anyone needing a jumping off point be aware I know relatively little of SharpCap/python.

Initialise stage:
  • current_exposure = SharpCap.SelectedCamera.Controls.Exposure.ExposureMs
    current_gain = SharpCap.SelectedCamera.Controls.Gain.Value

    def capt_now(): # Probably don't need to change both gain and exposure
    • SharpCap.SelectedCamera.Controls.Exposure.ExposureMs = 100 # set arbitrary value 0.1 sec
      SharpCap.SelectedCamera.Controls.Gain.Value = 10
      SharpCap.SelectedCamera.CaptureSingleFrameTo(cap_lib + "capture_start_bucket.png") # get those values read
      SharpCap.SelectedCamera.Controls.Exposure.ExposureMs = current_exposure # restore values
      SharpCap.SelectedCamera.Controls.Gain.Value = current_gain
Body of Program:
  • capt_now()
    SharpCap.SelectedCamera.CaptureSingleFrameTo(cap_lib + "im" + time.time().ToString() + "a.png")
    while SharpCap.SelectedCamera.Capturing: # otherwise next call to capt_now will cause saving of truncated frame
    • time.sleep(.01)
Note: you need to import the 'time' (and possibly 'os') modules

If useful to anyone, good luck.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest