IMAQ.Getthearray.convertToU8 C# (CSharp) Method

convertToU8() public static method

public static convertToU8 ( NationalInstruments rgb32Array ) : ].byte[
rgb32Array NationalInstruments
return ].byte[
        public static byte[,] convertToU8(NationalInstruments.Vision.Rgb32Value[,] rgb32Array)
        {
            byte[,] arrayToReturn = new byte[rgb32Array.GetLength(0),rgb32Array.GetLength(1)];
            for(int i = 0; i < rgb32Array.GetLength(0); i++)
            {
                for (int j = 0; j < rgb32Array.GetLength(1); j++){
                    arrayToReturn[i,j] = rgb32Array[i,j].Blue;

                }
            }
            return arrayToReturn;
        }

Usage Example

示例#1
0
        public byte[,] SingleSnapshot(string attributesPath, bool addToImageList)
        {
            imageWindow.WriteToConsole("Taking snapshot");
            imageWindow.WriteToConsole("Applied camera attributes from " + attributesPath);
            SetCameraAttributes(attributesPath);
            try
            {
                if (state == CameraState.FREE || state == CameraState.READY_FOR_ACQUISITION)
                {
                    image = new VisionImage();

                    state = CameraState.READY_FOR_ACQUISITION;
                    try
                    {
                        imaqdxSession.Snap(image);

                        if (windowShowing)
                        {
                            imageWindow.AttachToViewer(image);
                        }
                        if (addToImageList)
                        {
                            imageList.Add(image);
                        }
                        image.WriteFile("test.bmp");

                        PixelValue2D pval = image.ImageToArray();
                        byte[,] u8array = Getthearray.convertToU8(pval.Rgb32);
                        double max = Getthearray.Findthemaximum(u8array);
                        imageWindow.WriteToConsole(max.ToString("F6"));
                        state = CameraState.FREE;
                        return(u8array);
                    }
                    catch (ObjectDisposedException e)
                    {
                        MessageBox.Show(e.Message);
                        throw new ObjectDisposedException("");
                    }
                    catch (ImaqdxException e)
                    {
                        MessageBox.Show(e.Message);
                        throw new ImaqdxException();
                    }
                    catch (VisionException e)
                    {
                        MessageBox.Show(e.VisionErrorText);
                        throw e;
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (TimeoutException)
            {
                return(null);
            }
        }
All Usage Examples Of IMAQ.Getthearray::convertToU8