Use CaptureSingleFrameTo capture multiple frames

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
yifei
Posts: 2
Joined: Sun Dec 31, 2017 9:27 pm

Use CaptureSingleFrameTo capture multiple frames

Post by yifei » Sun Dec 31, 2017 9:46 pm

I want to take more several frames using multiple CaptureSingleFrameTo command, I found the 2nd, 4th, 6th call always have problem.
Here is my code, and the running result

Code: Select all

import clr ; clr.AddReference("SharpCap.Base") ; from SharpCap.Base.PropertyControls import CommonPropertyIDs;  

import time
import os.path
import datetime

SharpCap.SelectedCamera.GetControl(CommonPropertyIDs.Exposure).Value = 10
p = r'C:\Users\owner\Desktop\SharpCap Captures'
for i in range(4):
	fn = os.path.join(p, '{i}.fits'.format(i=i))
	start = datetime.datetime.now().strftime('%H:%M:%S')
	SharpCap.SelectedCamera.CaptureSingleFrameTo(fn)
	end = datetime.datetime.now().strftime('%H:%M:%S')
	print 'Capture', fn, 'from', start, 'to', end

You can see I want to capture 4 frames, each of them are 10s exposure. I print out the time taken by each capture, here is the result

Code: Select all

Capture C:\Users\owner\Desktop\SharpCap Captures\0.fits from 13:36:36 to 13:36:39
Capture C:\Users\owner\Desktop\SharpCap Captures\1.fits from 13:36:39 to 13:36:40
Capture C:\Users\owner\Desktop\SharpCap Captures\2.fits from 13:36:40 to 13:36:49
Capture C:\Users\owner\Desktop\SharpCap Captures\3.fits from 13:36:49 to 13:36:50
You can see the first 1 take 3 seconds, this make sense as it already buffered for some time.
the 2nd one take 1 second, which doesn't make sense.
the 3rd one take about 10 second, which make sense.
the 4th one take 1 second, which doesn't make sense.

Then I take a look at those files, 0.fits and 1.fits are exact the same, 2.fits and 3.fits are the same.
It can be confirmed by looking at the header, the DATE-OBS (System Clock-Frame Grabbed) are the same.

I also tried add a time.sleep(4) in between but doesn't work.

My camera is ASI1600M Pro Cool, my SharpCap is 3.0.4008, I'm running on a Windows 10.

Thanks!

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

Re: Use CaptureSingleFrameTo capture multiple frames

Post by admin » Mon Jan 01, 2018 2:15 pm

Hi,

try

Code: Select all

SharpCap.SelectedCamera.CaptureSingleFrameTo(fn, false)
The second parameter being set to false tells SharpCap that it is not allowed to save the last frame received as the capture frame (which is what you are seeing). In theory, you shouldn't need this as it shouldn't use the last frame received if it has already been saved, but it sounds like there is a bug with that.

cheers,

Robin

yifei
Posts: 2
Joined: Sun Dec 31, 2017 9:27 pm

Re: Use CaptureSingleFrameTo capture multiple frames

Post by yifei » Mon Jan 01, 2018 4:48 pm

It worked! Thank you!

I also noticed if I click the snapshot button in the Toolbar to take snapshots, it will encounter the same issue -- the first snapshot will wait for current frame finish, then after that, if I click snapshot again, it just immediately saves the previous buffered image, but if I click snapshot the 3rd time, it will always wait for the frame to finish. Sounds like a bug to me.

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

Re: Use CaptureSingleFrameTo capture multiple frames

Post by admin » Tue Jan 02, 2018 6:06 pm

Yes, agreed - definitely a bug there - will be fixed in the next build.

thanks,

Robin

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest