Skip Advanced Capture

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

Skip Advanced Capture

#1

Post by pgn »

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
admin
Site Admin
Posts: 13122
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Skip Advanced Capture

#2

Post by admin »

Hi,

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.

However...

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,

Robin
pgn
Posts: 17
Joined: Wed Mar 08, 2017 9:46 am

Re: Skip Advanced Capture

#3

Post by pgn »

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.
pgn
Posts: 17
Joined: Wed Mar 08, 2017 9:46 am

Re: Skip Advanced Capture

#4

Post by pgn »

Robin. You provided advice last year on how to start a frame capture from the actual time it is requested (IE not from the buffer). Basically this was by resetting the camera. I noticed some activity in this area and wondered if you had added a more sophisticated option. Grateful for an update.
User avatar
admin
Site Admin
Posts: 13122
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Skip Advanced Capture

#5

Post by admin »

Hi,

there is no real change on that at the moment - in a future version (3.3 I hope) there will be proper support for still capture which means that the camera will no longer need to be running like a video camera all the time and you will be able to press (or script) a single capture.

cheers,

Robin
pgn
Posts: 17
Joined: Wed Mar 08, 2017 9:46 am

Re: Skip Advanced Capture

#6

Post by pgn »

Hi,

are you still on track for this feature (quoting you below and at top of this "mail chain")?

... in a future version (3.3 I hope) there will be proper support for still capture which means that the camera will no longer need to be running like a video camera all the time and you will be able to press (or script) a single capture. ...

Also, any new features I might have missed to do with scripting captures?

Many thanks.

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

Re: Skip Advanced Capture

#7

Post by admin »

Hi,

Sequencing and the still mode will be the main features for version 3.3. If you have a look across in the announcements forum you will see I posted a screenshot of the current prototype of the sequencing tool yesterday.

Cheers, Robin
Post Reply