Quantcast
Channel: Measurement Studio for VC++ topics
Viewing all articles
Browse latest Browse all 654

Puzzled by passing array from VB6 to vc++

$
0
0

Hello,

 

Problem setup:

I'm using a NI1430 board to grab images from a 12-bit ccd camera in a VB6 application. 

 

After an image is obtained, I call 

                     CWIMAQImage.ImageToArray()

to get the data, and pass it on to a VC++ dll to do some processing. 

 

The C++ function looks like this:

 

                          STDMETHODIMP Cmath::centroid(VARIANT *image, short width, short height, ... VARIANT *theCentroid)

 

where the first parameter, VARIANT *image, is the data array.

 

 

Problem:

I have a frame grabber from a different company.  They provide a method to extract the data array as well, something like: ImageClass.getImageData(). 

 

When I pass the the data arrays from the different boards to my C++ routine, the array from NI runs 10 times slower than the other one.

 

The arrays look identical on the VB6 side - they are both integer arrays of the same size.

 

When I inspect the data  passed in on the C++ side.  It turns out that

 

for the NI 1430 board,

           image -> vt == 0x2002,  indicating the data coming in is truely an array of integers

 

while for my other board, 

         image ->vt == 0x6002, indicating the data are passed in as a reference to an array of integers.

 

I believe this is where the 10x difference in processing speed originates

 

Questions:

I'm puzzled by how two identical arrays from the VB6 side are passed into C++ so differently.  There is no intermediate step between getting the array on the VB6 side and calling the VC++ routine. 

 

How can I pass the data array from the NI board (CWIMAQImage.ImageToArray()) by reference rather than by value to the C++ routine?

 

 

Thank you so much for your insight.  I've been struggling with this problem for quite sometime ...

 

 

 

 


Viewing all articles
Browse latest Browse all 654

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>