05-09-2012 10:38 AM
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.
05-11-2012 12:41 PM
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,