Strange Behaviour When Saving Cubes (Spectral)

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!

Hi @MathieuVDC,

Did you actually run into the out-of-range exception/“Error getting DataType” and had to replace the DLL or did you update it on reading the post beforehand?

You can see more logging in the LogGUI which comes with your CVB installation. Please configure the logging first (View->Configure) by adding the modules to log (Spectral, maybe CVB, DriverDLO). Also set the module logging to “debug”, save configuration, start logging and (re-)start your application. If you can get more information to post here that would be great.

Else I would suggest to set the default logging to debug and send the saved json log to our support de.support@stemmer-imaging.com referencing this thread.

Hi @usernv,

I got the “Error getting Datatype” which is why I replaced the DLL.

I’ve made the log file:

silogsvc.zip (642.7 KB)

There seems to be no error messages in the log, even though my application throws “Errror Writing Cube” exception?

The first cube is created at 09:59:53.443571 and saved at 09:59:53.45539 (succesfully)

The second cube is created at 09:59:55.711536 and saved at 09:59:55.715526 (unsuccesfully)

@usernv,

Any further info on this?

Yes, it is a bug/a problem with licensing. When the second camera is opened, it has no license and thus cannot save the cube. I need to get some feedback and will send you the updated driver later today.

Okay. Thanks for the help!

Can you please check if you have a license for the Spectral tool? It is a independent license from the camera suite. A full trial license would also suffice.

How can I check this? I’m currently licensed using a USB dongle. On the cvb License Manager I can see this:
Knipsel

I am sorry to tell you this, but you are missing the needed license for CVSpectral. It would be separately listed in the license manager. CVSpectral is neither part of the image manager nor the foundation. You can check for available licenses here:

Weird. The Stemmer sales people were aware of our need for the Spectral software and yet offered us only the Foundation. We will look into ordering the Spectral License. However this does not explain why I am able to save the data once?

We have some slack in the licensing process. For instance if you use a license dongle on a running production PC and someone removes the dongle by accident, the system continues running for a while before embedding the watermark. In you case the call to the license probably comes fast enough so that no license could have been detected yet. In this case we allow the call so you won’t have any trouble for now. The second cube save then correctly detects the missing license and returns an error.

If I look on the Magic Numbers page there seems to be a Spectral license

Or is a Magic Number not a license?

The serial 999 is the standard value for developer dongles which unlock all tools. You should have gotten a magic number which fits your dongle number (not 999). You would enter the tool name and magic number and then the dongle unlocks the tool.
The other option is a dongle which comes with the magic number preset. This would then add the unlocked tool to the bottom after all 999 tools with your dongle number.

My dongle is plugged into the PC. The spectral tool stays at 999. But so does everything else, what exactly does that mean? That nothing is licensed? Even so, everything right now is being licensed by a trial license because of the 999? So the failure of my code is not a licensing error?

When you open the camera or cvmock.vin with the CVB Viewer you should see a watermark embedded. All 999 Serials are always displayed. Do you have a trial license activated simultaneously to the dongle? If so it is possible that the trial overrides the dongle. Maybe remove the trial license and try with the dongle again.
But if you do not have purchased the Spectral tool, you will not have the license for it.
You can also check for a faulty dongle with the watermark embedded. Adding the dongle should remove the watermark after a few seconds.

When the dongle is disconnected I see the watermark, it then disappears after inserting the dongle. So it seems a trial version is blocking me from seeing which Tools are licensed. How can I remove the trial license?

No, this is normal behaviour. If you would remove the dongle but still get no watermark the trial license would be active. I checked with your orders and could not find one for the CVSpectral license. I also informed sales so they can get in contact with you.
Sorry that this was somehow overlooked and I hope we can find a suitable solution soon.

Hello @usernv,

I’ve got a trial license for now and the Spectral License has been ordered. Everything seems to be working now. Thank you for your help.

2 Likes