Hi everyone,
I am currently working with the new Managed Wrappers, that will be part of the next CVB release.
I’m running into an exception that I’m not sure where to start searching for.
private TaskCompletionSource<int> _stopGrabTCS;
public async Task ProcessImages()
{
var kernel = new double[3, 3]
{
{ 0, -1, 0 },
{ -1, 4, -1 },
{ 0, -1, 0 },
};
Grabbing = false;
await _stopGrabTCS.Task; // Is set to 1 in Grabbing, when the Grab was actually stopped.
_device.RingBuffer.LockMode = RingBufferLockMode.On;
await SetTriggerMode(TriggerState.On);
var stream = _device.Streams[0];
while (State == States.Displaying)
{
using (CvbImage composedImage = new CvbImage(Image.Width, Image.Height))
{
Task[] processing = new Task[256];
for (int i = 0; i < 256; i++)
{
SendSoftwareTrigger();
var image = await stream.WaitAsync();
NotifyOfPropertyChange(() => Image);
processing[i] = Task.Run(() =>
{
using (var filterImage = Filter.User(image, kernel))
{
// Some more filter operations going on here,
}
{
CopyPixelsWithValue(filterImage, composedImage, (byte)i); // Writes values using LinearAccess
}
}
}
}
});
}
await Task.WhenAll(processing);
// This is where the exception occurs.
//This call is needed, to free the RingBuffer, otherwise no more images
// will be acquried when the buffer is full. In this case NumBuffers is set to 256.
foreach (var img in _device.RingBuffer)
{
img.Unlock();
}
// processing finished
// Image gets saved to given path
}
}
// Set camera back to freerun
}
Exception:
at Stemmer.Cvb.Runtime.InteropServices.Processing.GenericInvocation[TOut](StandardProcessingFunction1`1 fn)
at Stemmer.Cvb.Driver.RingBuffer.get_Count()
at Stemmer.Cvb.Driver.RingBuffer.d__22.MoveNext()
I had a short talk with @parsd, who told me, that this happens due to an error in RBNumbuffer.
When I had a look into the DeviceImage of the GeniCam.vin, I saw, that an AccessViolation occured.
The problem occurs randomly, sometimes the application runs a day without failing, sometimes it happens within the first 5 minutes.
I’m really puzzled and appreciate any help I can get.