Capture overrun

A place to report problems and bugs in SharpCap
Forum rules


If you have a problem or question, please check the FAQ to see if it already has an answer : https://www.sharpcap.co.uk/sharpcap-faqs

Please also read about Troubleshooting USB Issues before posting.

*** Please do not post license keys - please report any problems with licensing to 'admin' by private message ***

Please include the following details in any bug report:

* Version of SharpCap
* Camera and other hardware being user
* Operating system version
* Contents of the SharpCap log after the problem has occurred.
[If SharpCap crashes, please send the bug report when prompted instead of including the log]
Post Reply
3ricJohanson
Posts: 13
Joined: Wed Jun 03, 2020 9:02 pm

Capture overrun

#1

Post by 3ricJohanson »

I don't have log files of this, but I can produce them if they are helpful.

I'm sometimes running long sequences of captures. This looks something like setting a bunch of camera parameters, then capturing 200 frames. Then doing it over and over again.

Here's the helper functions I'm using:

Code: Select all

def set_capture_count(exposure_count): 
    SharpCap.SelectedCamera.CaptureConfig.CaptureLimitType = CaptureLimitType.FrameLimited
    SharpCap.SelectedCamera.CaptureConfig.CaptureLimitCount = exposure_count
    return

def do_capture(): 
    while True:
      if not SharpCap.SelectedCamera.Capturing :
        break
      print ("Waiting for capture to complete..")
      time.sleep(1)
    print ("capturing... ")
    SharpCap.SelectedCamera.PrepareToCapture()
    SharpCap.SelectedCamera.RunCapture()
    while True:
      if SharpCap.SelectedCamera.Capturing :
        print SharpCap.SelectedCamera.CapturedFrameCount
      else: 
        break
      if SharpCap.SelectedCamera.CapturedFrameCount > total_exposures+1:
         print ("Capture overrun.....")
         SharpCap.SelectedCamera.CancelCapture()
         break
#      time.sleep((current_exposure_time*1000)+0.1)
      time.sleep(1)
I'm having intermittent problems RunCapture() going crazy on me. It will (1 out of 100? 200 ? ) times being called sometimes just capture forever. You can see in the code above that I'm trying to detect the capture overrun and call CancelCapture(), but this doesn't actually work -- it just keeps capturing and capturing and capturing. Exiting or killing the sharpcap process is the only thing that seems to stop it. It's intermittent. My workaround has been to use CaptureSingleFrame() which works awesome. I've captured hundreds of thousands of frames this way without a single problem of this sort.

Any ideas what's going on here? Shall I try to get verbose logging information when this is happening? (might be hard, based the runtime to reproduce this)

Here's a snip from the log when one of these events are happening:

Code: Select all

Verbose:	11:05:07.8590382 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Completed (returned False) GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.8590382 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Starting GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.8640513 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Completed (returned False) GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.8640513 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Starting GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.8690648 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Completed (returned False) GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.8690648 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Starting GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.8740730 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Completed (returned False) GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.8740730 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Starting GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.8871082 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Completed (returned False) GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.8871082 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Starting GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Debug:	11:05:07.8971352 Thread:#1 SharpCap.Base.BaseImageProvider.BeforeStopCapture() :: Ended
Info:	11:05:07.8971352 Thread:#1 SharpCap.MultiCaptureProvider.SendCaptureEvent(Object sender, CaptureEventArgs e) :: Capture Event : StopCapture
Debug:	11:05:07.8971352 Thread:#1 SharpCap.Models.Application.OnStopCapture() :: Started
Debug:	11:05:07.8971352 Thread:#1 SharpCap.Models.Application.OnStopCapture() :: Ended
Info:	11:05:07.8971352 Thread:#1 SharpCap.ViewModels.SharpCapViewModel.appModel_OnCaptureEvent(Object sender, CaptureEventArgs e) :: StopCapture event received in UI thread
Info:	11:05:07.8981377 Thread:#1 SharpCap.ImageProcessing.AstroTortillaPlateSolver.CygwinBinPathImpl() :: Using Unknown plate solver found at c:\cygwin\bin\
Info:	11:05:07.8981377 Thread:#1 SharpCap.ImageProcessing.AstroTortillaPlateSolver.IsAvailable() :: Plate solver not available
Info:	11:05:07.8991402 Thread:#1 SharpCap.ImageProcessing.AstapPlateSolver.IsAvailable() :: Astap Plate solver not available
Info:	11:05:07.8991402 Thread:#1 SharpCap.ImageProcessing.AstroTortillaPlateSolver.CygwinBinPathImpl() :: Using Unknown plate solver found at c:\cygwin\bin\
Info:	11:05:07.8991402 Thread:#1 SharpCap.ImageProcessing.AstroTortillaPlateSolver.IsAvailable() :: Plate solver not available
Debug:	11:05:07.8991402 Thread:#1 SharpCap.UI.SharpCapForm.OnStopCapture() :: Started
Debug:	11:05:07.8991402 Thread:#1 SharpCap.UI.SharpCapForm.OnStopCapture() :: Ended
Verbose:	11:05:07.9011455 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Completed (returned False) GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.9031512 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Starting GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Debug:	11:05:07.9031512 Thread:#1 SharpCap.Base.CaptureProviderBase`1.StopCapture() :: StopCapture event sent
Info:	11:05:07.9031512 Thread:#1 SharpCap.Base.CaptureProviderBase`1.StopCapture() :: Ended
Info:	11:05:07.9031512 Thread:#1 SharpCap.MultiCaptureProvider.CloseDevice() :: Stopping preview to close device
Info:	11:05:07.9031512 Thread:#1 SharpCap.Base.CaptureProviderBase`1.StopPreview() :: Started
Debug:	11:05:07.9031512 Thread:#1 SharpCap.Base.BaseImageProvider.Stop() :: Started
Debug:	11:05:07.9031512 Thread:#1 SharpCap.Base.CameraProxyBase.StopPreview() :: Started
Verbose:	11:05:07.9181910 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.GetQHYCCDLiveFrame :: Completed (returned False) GetQHYCCDLiveFrame(6036, 4036, 16, 1, 1426128896)
Verbose:	11:05:07.9181910 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.StopLive :: Starting StopLive()
Verbose:	11:05:08.0324940 Thread:Grab Thread#15 SharpCap.Cameras.QHY.Camera.StopLive :: Completed (returned null) StopLive()
Debug:	11:05:08.0685906 Thread:Grab Thread#15 SharpCap.Base.CameraProxyBase.GrabThreadProc() :: Ended
Info:	11:05:08.1232439 Thread:#26 SharpCap.Models.Application.set_TargetName(String value) :: Target name changed to Gain.311-Exp.1000-Temp.-20
Verbose:	11:05:08.1232439 Thread:#26 SharpCap.Base.PropertyControls.BaseValuePropertyControl`3.set_Value(TInterfaceType value) :: Ignoring property set on Exposure because value of 1000 is already the target value of 1000
Verbose:	11:05:08.1242471 Thread:#26 SharpCap.Base.PropertyControls.BaseValuePropertyControl`3.set_Value(TInterfaceType value) :: Ignoring property set on Gain because value of 255 is already the target value of 255
Debug:	11:05:08.1693668 Thread:#1 SharpCap.Base.CameraProxyBase.StopPreview() :: Ended
Debug:	11:05:08.1713721 Thread:#1 SharpCap.Base.BaseImageProvider.Stop() :: Ended
Info:	11:05:08.1733774 Thread:#1 SharpCap.MultiCaptureProvider.SendCaptureEvent(Object sender, CaptureEventArgs e) :: Capture Event : StopPreview
Info:	11:05:08.1914243 Thread:#1 SharpCap.Base.Memory.MappedBufferFactory+MemoryManager.DropStashedFrames() :: Drop stashed frames reclaimed 171282432 bytes of memory.
Info:	11:05:08.1914243 Thread:#1 SharpCap.ViewModels.SharpCapViewModel.appModel_OnCaptureEvent(Object sender, CaptureEventArgs e) :: StopPreview event received in UI thread
Info:	11:05:08.3951888 Thread:#1 SharpCap.Base.CaptureProviderBase`1.StopPreview() :: Ended
Info:	11:05:08.3960924 Thread:#1 SharpCap.Base.CaptureProviderBase`1.CloseDevice() :: Started
Debug:	11:05:08.3960924 Thread:#1 SharpCap.Base.CaptureProviderBase`1.CloseTheImageProvider() :: Started
Debug:	11:05:08.3960924 Thread:#1 SharpCap.Base.BaseImageProvider.Close() :: Started
Verbose:	11:05:08.3960924 Thread:#1 SharpCap.Cameras.QHY.Camera.Dispose :: Starting Dispose()
Verbose:	11:05:08.3960924 Thread:#1 SharpCap.Cameras.QHY.Camera.Dispose :: Completed (returned null) Dispose()
Info:	11:05:08.3960924 Thread:#1 SharpCap.Base.CameraProxyBase.Dispose(Boolean disposing) :: Started
Debug:	11:05:08.3960924 Thread:#1 SharpCap.Base.BaseImageProvider.Close() :: Ended
Debug:	11:05:08.3960924 Thread:#1 SharpCap.Base.CaptureProviderBase`1.CloseTheImageProvider() :: Ended
Debug:	11:05:08.3960924 Thread:#1 SharpCap.Base.SimpleCaptureProvider.OnDeviceClosed() :: Started
Debug:	11:05:08.3960924 Thread:#1 SharpCap.Base.SimpleCaptureProvider.OnDeviceClosed() :: Ended
Info:	11:05:08.3960924 Thread:#1 SharpCap.Base.CaptureProviderBase`1.CloseDevice() :: Ended
Info:	11:05:08.3960924 Thread:#1 SharpCap.MultiCaptureProvider.SendCaptureEvent(Object sender, CaptureEventArgs e) :: Capture Event : DeviceClosed
Info:	11:05:08.3960924 Thread:#1 SharpCap.ViewModels.SharpCapViewModel.appModel_OnCaptureEvent(Object sender, CaptureEventArgs e) :: DeviceClosed event received in UI thread
Info:	11:05:08.4117197 Thread:#1 SharpCap.Base.CaptureProviderBase`1.Dispose(Boolean bDisposing) :: Started
Error:	11:05:08.4117197 Thread:#1 SharpCap.Base.CaptureProviderBase`1.Dispose(Boolean bDisposing) :: Disposing of QHYCaptureProvider
Debug:	11:05:08.4117197 Thread:#1 SharpCap.Base.BaseImageProvider.Dispose(Boolean disposing) :: Started
Debug:	11:05:08.4117197 Thread:#1 SharpCap.Base.BaseImageProvider.Dispose(Boolean disposing) :: Ended
Info:	11:05:08.4117197 Thread:#1 SharpCap.Base.CaptureProviderBase`1.Dispose(Boolean bDisposing) :: Ended
Info:	11:05:08.4117197 Thread:#1 SharpCap.ViewModels.SharpCapViewModel.appModel_OnCaptureEvent(Object sender, CaptureEventArgs e) :: StatusBarUpdate event received in UI thread
Verbose:	11:05:08.7867606 Thread:#1 SharpCap.Cameras.Atik.AtikSdk.ArtemisShutdown :: Starting ArtemisShutdown()
Warning:	11:05:08.8023853 Thread:#1 SharpCap.Base.Utilities.LoggingProxy.HandleMethodCall(IMethodCallMessage methodCall) :: Exception of type 'DllNotFoundException' from Exception from SharpCap.Cameras.Atik.AtikSdk.ArtemisShutdown() : Unable to load DLL 'AtikCameras.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) 
Stack Trace:   at SharpCap.Cameras.Atik.AtikSdk.__Internal.ArtemisShutdown()
   at SharpCap.Cameras.Atik.AtikSdk.ArtemisShutdown() in C:\Documents\Source Code\SharpCap3.2\src\SharpCap.Cameras.Atik\AtikSdk.cs:line 856
Warning:	11:05:08.8180114 Thread:#1 SharpCap.MultiCaptureProvider.Dispose() :: Exception of type 'DllNotFoundException' from Disposing of device enumerators : Unable to load DLL 'AtikCameras.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) 
Stack Trace:
Server stack trace: 
   at SharpCap.Cameras.Atik.AtikSdk.__Internal.ArtemisShutdown()
   at SharpCap.Cameras.Atik.AtikSdk.ArtemisShutdown() in C:\Documents\Source Code\SharpCap3.2\src\SharpCap.Cameras.Atik\AtikSdk.cs:line 856

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at SharpCap.Cameras.Atik.AtikSdk.ArtemisShutdown()
   at SharpCap.Cameras.Atik.AtikDeviceEnumerator.Dispose(Boolean disposing) in C:\Documents\Source Code\SharpCap3.2\src\SharpCap.Cameras.Atik\AtikCaptureProvider.cs:line 36
   at SharpCap.Base.SimpleDeviceEnumerator.Dispose() in C:\Documents\Source Code\SharpCap3.2\src\SharpCap.Base\SimpleCaptureProvider.cs:line 245
   at SharpCap.MultiCaptureProvider.Dispose() in C:\Documents\Source Code\SharpCap3.2\src\SharpCap\Models\MultiCaptureProvider.cs:line 284
   
User avatar
admin
Site Admin
Posts: 13177
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Capture overrun

#2

Post by admin »

Hi,

Did you happen to notice if the frame counter had got stuck on the occasions when the capture doesn't complete? I'm wondering if the camera had stopped responding to SharpCap? In that case SharpCap would never hit the target frame count and would carry on waiting in the probably vain hope that the frames would start up again.

Unfortunately the qhy cameras are a little trickier than others to deal with in this regard – a lot of camera brands have a way for SharpCap to ask if a frame is ready, or to ask for a new frame and specify a timeout so that if one doesn't arrive control returns to SharpCap. On those cameras I can write code that spots that the frame becomes overdue and tries to reset the camera. On qhy cameras all I can do is ask for the frame and hope that the SDK returns to me!

Cheers, Robin
3ricJohanson
Posts: 13
Joined: Wed Jun 03, 2020 9:02 pm

Re: Capture overrun

#3

Post by 3ricJohanson »

When I was capturing "real" photos it just kept going (saving out to separate fits files), that had actual, moving images (my living room). Counters continues ticking upwards.... just never stopping!
User avatar
admin
Site Admin
Posts: 13177
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Capture overrun

#4

Post by admin »

Hi,

Ah, ok, nothing to do with the camera freezing up then!

I noticed that you are using cancel capture to try to stop the capture in progress – that's an incorrect use of that function call, which is designed to abandon the capture that has been prepared but not yet started with the RunCapture call. If you need to stop capture that is already running then use StopCapture. Maybe that will make your scripting solution work. Still not quite sure how the capture manages to overrun yet.

Thanks, Robin
Post Reply