I am programming a software in C# to control and receiving images from a spectral camera that uses cameralink interface, using a Framegrabber of Matrox company and the ActiveMIL libraries. I am using Visual Studio 2008.
The library gives ActiveX controls to receive and displaying camera images in a control window, but I need to pass the data loaded by the control to my own array.
The library gives me the following method to make this:
void object.Get{
ref Array UserArray,
ImFormatConstants Format,
ImBandConstats Band,
int OffsetX,
int OffsetY,
int SizeX,
int SizeY
}
Then, I wrote my code as follow:
Object IMG = new Object[256*320]; //Size of image is 256 rows and 320 columns
axMImage1.Get(ref IMG, Matrox.ActiveMIL.ImFormatConsts.imPlanar, Matrox.ActiveMIL.ImBandConstants.imAllBands, 0, 0, 320, 256);
When I execute this code, I get the following error:
An invalid VARIANT was detected during a conversion from an unmanaged VARIANT to a managed object. Passing invalid VARIANTs to the CLR can cause unexpected exceptions, corruption or data loss
Can you help me to understand the error?
NOTE: the parameters functions says that the first parameter is an Array passed by reference, but if I use and declare an Array as follow:
Array[] IMG = new Array[256*320];
I receive the following error:
Argument '1': cannot convert from 'ref System.Array[]' to 'ref object'
Thanks.