Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert VisionImage to Standard Format

I have the following C# code for capturing an image from a frame grabber and then displaying it:

 

      while (true) {
        try {
          session.Snap(vImage);  // vImage is of type VisionImage
          vImage.WritePngFile("C:\\Captured\\frame.png");
          picture.ImageLocation = "C:\\Captured\\frame.png";  // picture is a PictureBox
        } catch (Exception err) { MessageBox.Showerr.ToString()) ; }

     }

 

This is not very efficient, as the image needs to be read from disc to display it in a PictureBox. Is there a way to convert VisionImage into a format that PictureBox can understand so I can avoid the extra I/O? Thanks.

0 Kudos
Message 1 of 2
(4,641 Views)

Hi cdl3,

 

You could try convert the image to an array with ImageToArray() or the VI below. 

 

IMAQ ImageToArray VI

http://zone.ni.com/reference/en-XX/help/370281M-01/imaqvision/imaq_imagetoarray/

 

I found a C# example at the bottom of this thread (untested). You will need to determine the pixel type of your converted image. Let us know if this is helpful!

 

Regards,

--
Peter Rifken - Field Engineer & Business Manager
Boston / North New England & Maine
0 Kudos
Message 2 of 2
(4,628 Views)