Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

How to access lavVIEW image data from Visual Basic6?

Hello Everyone,
I use a image display from the NI Vision module to capture a still image of a live video.  Is there a way to access the image data from Visual Basic?  When I looked at the data structure of the image from within Visual Basic, I saw two components:
   
    imageData(0) = "video"    ' VB string
    imageData(1)                   ' Unsupported type

Is it possible to convert the image data to a type that's accessible from within VB?

Thanks very much for your information.

0 Kudos
Message 1 of 6
(7,748 Views)
Hey uits,
 
The best way to pass an image from one API to another (such as VB) is to pass it as a 2-D Array, since most programming languages can accept and use arrays. There is a function that comes with the Vision Development Module that is called IMAQ ImageToArray. You can use this in your non-VB code and then pass the 2D array to your VB code. Then in your VB code you can do what you would like to that array of image pixel data.
 
I hope this helps. Please let me know if you have any further questions about this functionality. Thanks, and have a great day.
 
Regards,
DJ L.
0 Kudos
Message 2 of 6
(7,741 Views)
Hello DJ L,
Thanks for the reply.  I attached the VIs to help me better explain my question.  I'm trying to communicate with a VI running on another machine.  If I just run the labVIEW program (remote tracker continuous.vi) , everything is fine.  I can grab an image and display it in the LSLO display box.  When I try to access the data from VB6,  all is fine except the LSLO image data.  Below is my VB6 code:

'set the calling parameters
Private Sub setTrackerParams()
    paramNames(0) = "Track"
    paramNames(1) = "Video"
    ...........
    paramNames(14) = "LSLO"
End Sub

'call labVIEW remotely
Private Sub callLabView()
  
    paramVals(0) = True
    paramVals(1) = True
    .....
    Call vi.Call(paramNames, paramVals)

    'display the retrived values
    txtDataPath.Text = paramVals(7)
    ......
   
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' here, if I try to access the paramVals(14), I run into the problem I mentioned in my original message,
    '  paramVals(14)(0) = "Video"
    ' paramVals(14)(1) =  'variant type/unsupport in VB6
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub

Hope this is a better description of the problem.  Thanks very much for any insight
0 Kudos
Message 3 of 6
(7,731 Views)
Hey uits,
 
Like I mentioned in my previous post, try and use the IMAQ ImageToArray.VI in your LabVIEW program, and then you won't have a problem with the variant data type in your VB program. The reason I say to use the ImageToArray function, is because in LabVIEW the Image wire (purple) that you see is actually a Data Type of its own. It actually used to be a cluster of the 2-D array of pixel data and some other information about the image. NI created an "Image Data Type" for images instead of using a cluster. If you try to pass this Image Data type to your VB program, it will be seen as a variant data type. Therefore, as I have mentioned, use the IMAQ ImageToArray.VI in your LabVIEW program and then you can get the image data into your VB program as an array, and not as the variant.
 
Please let me know if you are still confused about using the IMAQ ImageToArray.VI in your LabVIEW program. Thanks, and have a great day.
 
Regards,
DJ L.
0 Kudos
Message 4 of 6
(7,726 Views)
Hello DJ L.
My delima is that I don't have a CWIMAQImage object to work with.  All I have are the raw data returned in 'paramVals' from the VB Call vi.Call(paramNames, paramVals).  I created a NEW CWIMAQImage object in my vb code, and tried to invoke CWIMAQImage.ArrayToImage(paramVals), but got the error 'Variable uses an Automation type not supported in Visual Basic'. 

More suggestions?
Thanks very much

0 Kudos
Message 5 of 6
(7,710 Views)
Hey uits,

"The Type property determines the resulting image type. For example, to create a color image from an input 2D array of integers, set the Type property to cwimaqImageTypeRGB32 and call ArrayToImage.

If the image type is not cwimaqImageTypeComplex or cwimaqImageTypeRGBU64, the input array is a 2D array of scalars.

If the image type is cwimaqImageTypeComplex, the input array is a 1D array of two elements. The first element is a 2D array containing the real plane, and the second element is a 2D array containing the imaginary plane. Both the arrays must have the same size.

If the image type is cwimaqImageTypeRGBU64, the input array is a 2D array of 1D arrays with 4 integer elements (the Red, Blue, Green, and Alpha channels of each pixel)."

The above can be found in the NI Vision for Visual Basic Reference Help file.

Make sure that the paramVals has the datatype of 1D or 2D arrays, and then you should be able to convert that Array (not variant) to an Image.
 
Regards,
DJ L.
0 Kudos
Message 6 of 6
(7,697 Views)