This ist my first CVB project and I think it´s a basic issue but i could not find what I needed in the forum.
I want to grab and save the images sent by two cameras which are connected via GigeVision. The cameras recieve an external trigger signal from a measurement device.
while (cbGrab.Checked)
{
try
{
using (StreamImage image = await Device0.Stream.WaitAsync())
{
if (cbSaveImages.Checked)
{
var cloneIMG = image.Clone();
Task t = Task.Run(() => asyncWriteToRingBuffer(cloneIMG, 0, RecPacks[0].iGrabedImages++, DateTime.Now));
}
RecPacks[0].iGrabCheck += 1;
}
using (StreamImage image = await Device1.Stream.WaitAsync())
{
if (cbSaveImages.Checked)
{
var cloneIMG = image.Clone();
Task t = Task.Run(() => asyncWriteToRingBuffer(cloneIMG, 1, RecPacks[1].iGrabedImages++, DateTime.Now));
}
RecPacks[1].iGrabCheck += 1;
}
}
catch (InvalidOperationException ex)
{
Console.WriteLine("Exception in cbGrab: " + ex.Message);
}
catch (TaskCanceledException ex)
{
Console.WriteLine("Exception in cbGrab: " + ex.Message);
}
}
(asyncWriteToRingBuffer is my funktion to convert and save the Images)
Problems accure when the Cameras dont get triggers and dont sent images for a while. This is unavoidable in my project. When there are no Images for more than 3 or 4 seconds there will be no more recieved, even if the cameras continue sending after this pause. Nothing else happens. There is no exception thrown or anythis. The streams are still running but do not get any more images.
I assume that the Device objects or their Streams do have an internal timeout which ends the recieving.
At the moment I handle this issue by stopping and restarting the streams of both cameras with a timer if the Cameras don´t sent anything for a while. After this the timeout is resetted and i can wait another 3 seconds for new images bevor i have to restart another time.
Obviously this way is not optimal. When an image arrives just while i restart the streams it might be damaged or lost. When i restart this way it takes up to 1.5 seconds.
Is there a way to avoid this timeout? Or how could i improve my workaround?
Thank you for your support!