Shutdown Cleanly with Infinite Timeout and hardware trigger
AnsweredI have an application that uses an external hardware trigger.
camera->TriggerMode.SetValue(TriggerMode_Off);
camera->TriggerSource.SetValue(TriggerSource_Line2);
camera->TriggerActivation.SetValue(TriggerActivation_FallingEdge);
camera->TriggerSelector.SetValue(TriggerSelector_FrameStart);
camera->TriggerMode.SetValue(TriggerMode_On);
camera->AcquisitionMode.SetValue(AcquisitionMode_Continuous);
camera->TLStream.StreamBufferCountMode.SetValue(Spinnaker::StreamBufferCountModeEnum::StreamBufferCountMode_Manual);
camera->TLStream.StreamBufferCountManual.SetValue(10);
camera->TLStream.StreamBufferHandlingMode.SetValue(Spinnaker::StreamBufferHandlingModeEnum::StreamBufferHandlingMode_OldestFirst);
Since the time between triggers varies and will, at times, be very long, I have the timeout set to infinite.
Acquisition is running on it's own thread in a loop:
camera->BeginAcquisition();
// Other setup code
while(running) {
ptrGrabResult = camera->GetNextImage(INFINITE);
/*frame handling code*/
}
Where I am stuck is at shutting down the application cleanly...
Let's say the external trigger will not be firing for a while and the GetNextImage() call is just blocked until it does. If I want to shutdown the application at this time, it appears I can't do much until GetNextImage returns.
From the main thread, if I call:
camera->EndAcquisition();
It hangs until the GetNextImage call returns.
Forcing the camera's hardware trigger to fire resolves the issue, but this is not a great option for the application as it would require a hardware change in our system (a small one, but we'd prefer no change at all).
Is there a way to interrupt the call to GetNextImage when ready to shutdown? Is there a better design for handling shutdown when there GetNextImage timeout is set to INFINITE?
-
Official comment
Hello,
Basically, GetNextImage is implemented such that it blocks until image arrives in the allocated buffer.
With your application logic and program implementation, I would rather not set the timeout to infinite.
Instead apply any of these options:
- use image event approach to grab image from camera(recommended). Please reference ImageEvents example code part of spinnaker sdk on how to implement this.
- Set specific timeout period for each GetNextImage, and ignore any timeout exception
I hope this approach helps to resolve this issue.
Regards,
Ifeanyi
Please sign in to leave a comment.
Comments
1 comment