I have been puzzled by the problem for days, and your help is sincerely appreciated.
I use VB6 and a NI1430 board to grab images from a UNIQ1830-CL camera. After the image is obtained, I use ImageToArray to get the data, and pass the array to a C++ function to do centroiding for a subregion of the image. The C++ function resides in a custom-made dll named 'mathLib'.
The signature of the C++ function is:
STDMETHODIMP Cmath::centroid(VARIANT *image, int left, int width, int top, int height, VARIANT *theCentroid) ;
To call the C function from VB6, I do:
dim centroid as variant
dim imageData as variant
...
let imageData = CWIMAQImage.ImageToArray
Let centroid = mathLib.centroid(imageData, regionLeft, regionWidth, regionTop, regionHeight)
...
I tried the NI1430 and a board from another company. The 'imageData' look the same in VB6 - both are 2D Integer arrays of size 1024x1024. However when the array is passed to the C++ routine, there is a 5 times difference in processing speed. I examined the array on the C++ side. It turns out that the 'vt' field has different values. For the array coming from NI1430, vt = 0x2002 (i.e. VT_ARRAY & VT_I2), which incates it's passed in by value. While for the array coming from the other board, vt = 0x6002 (i.e. VT_BYREF & VT_ARRAY & VT_I2), which says it's passed by reference. Since I call the C++ function for many sub regions in the image, and each call results in a new copy of the NI image array, the slowness in speed for the NI board is profound.
So my question is: In VB6, how do I get a reference to the array returned by ImagetoArray() ? I've tried to obtain the address of the array, pass the first element of the array, etc. none of them worked. Please help.