Hello,
I’m encountering strange behaviour when trying to save cubes from the spectral package (in .NET)
I have two cameras that get data from two different framegrabbers. They both are defined by the same class.
To start capturing I use the following:
_stream.RingBuffer.ChangeCount(ApproxNumLines, DeviceUpdateMode.NewDeviceImage);
_stream.RingBuffer.LockMode = RingBufferLockMode.On;
new Thread(() => CaptureThread()).Start();
The capturing thread:
_stream.Start();
StreamImage imgstream;
while (_isCapturing)
{
WaitStatus res;
imgstream = _stream.WaitFor(new
Stemmer.Cvb.Utilities.UsTimeSpan(1000000), out res);
if (res == WaitStatus.Timeout)
{
HandleError($"Camera Timeout");
return;
}
_data.Add(imgstream);
}
_stream.Stop();
Where _data is a list:
private List<StreamImage> _data;
The cube is created after capturing was stopped:
_cube = Stemmer.Cvb.Spectral.Cube.FromImages(_data, Stemmer.Cvb.Spectral.CubeEncoding.BandInterleavedByLine);
Stemmer.Cvb.Spectral.MetaData metaData = _cube.MetaData;
metaData.Wavelengths = _settings.wavelength;
And finally saved:
_cube.Save(filepath + '\\' + filename + ".hdr", filepath + '\\' + filename + ".bin");
after saving, the data is disposed:
_data.Clear(); _cube.Dispose(); _stream.RingBuffer.Dispose();
This works without problem if only a single camera is used, and thus only one instance of the class exists (this has been tested for both cameras). When using two cameras the cube from the first one will be saved succesfully but the _cube.Save()
call of the second class instance will throw a "Error Writing Cube"
Exception.
I am using cvb version 13.02.004 but use the CVSpectral dll mentioned in this post: "Error getting DataType" when creating StackedCube from Image array (as I was having the same issues)
As both cameras are defined by a different instance of the class and thus share no resources, this looks like weird behaviour to me. Is there any cause or explanation of this behaviour? Is there any way to have more information about the exception, maybe more info is logged somewhere?
Thanks!