示例#1
0
        /// <summary>
        /// Grabs
        /// </summary>
        /// <param name="camImage"></param>
        /// <returns></returns>
        public PGRFlyModule.FlyCaptureImage GrabRGBImage(IntPtr camImage)
        {
            int ret;

            ret = PGRFlyDllBridge.flycaptureGrabImage2(flycapContext, ref image);
            if (ret != 0)
            {
                //ReportError(ret, "flycaptureGrabImage2");
                PGRFlyModule.FlyCaptureImage tmpImage = new PGRFlyModule.FlyCaptureImage();
                tmpImage.pData = null;
                return(tmpImage);
            }

            if (cameraModel == PGRFlyModule.FlyCaptureCameraModel.FLYCAPTURE_DRAGONFLY2)
            {
                return(image);
            }
            else
            {
                // Convert the image.
                flycapRGBImage.pData       = (byte *)camImage;
                flycapRGBImage.pixelFormat = PGRFlyModule.FlyCapturePixelFormat.FLYCAPTURE_BGR;
                ret = PGRFlyDllBridge.flycaptureConvertImage(flycapContext, ref image, ref flycapRGBImage);
                if (ret != 0)
                {
                    ReportError(ret, "flycaptureConvertImage");
                }

                return(flycapRGBImage);
            }
        }
示例#2
0
        /// <summary>
        /// Initializes the camera driver
        /// </summary>
        /// <param name="cameraIndex">If only one Point Grey camera is connected, then use '0'.
        /// If more than one Point Grey cameras connected, then use between '0' and 'number of
        /// Point Grey cameras connected - 1'</param>
        /// <param name="frameRate">The frame rate you desire</param>
        /// <param name="videoMode"></param>
        /// <param name="grayscale"></param>
        unsafe public void Initialize(int cameraIndex, PGRFlyModule.FlyCaptureFrameRate frameRate,
                                      PGRFlyModule.FlyCaptureVideoMode videoMode, bool grayscale)
        {
            this.cameraIndex = cameraIndex;

            int flycapContext;
            int ret;

            // Create the context.
            ret = PGRFlyDllBridge.flycaptureCreateContext(&flycapContext);
            if (ret != 0)
            {
                ReportError(ret, "flycaptureCreateContext");
            }

            // Initialize the camera.
            ret = PGRFlyDllBridge.flycaptureInitialize(flycapContext, cameraIndex);
            if (ret != 0)
            {
                ReportError(ret, "flycaptureInitialize");
            }

            // Get the info for this camera.
            ret = PGRFlyDllBridge.flycaptureGetCameraInformation(flycapContext, ref flycapInfo);
            if (ret != 0)
            {
                ReportError(ret, "flycaptureGetCameraInformation");
            }

            if (flycapInfo.CameraType ==
                PGRFlyModule.FlyCaptureCameraType.FLYCAPTURE_BLACK_AND_WHITE && !grayscale)
            {
                throw new GoblinException("This Point Grey camera is B&W, so you need to initialize " +
                                          "the video capture device with grayscale");
            }

            cameraType  = flycapInfo.CameraType;
            cameraModel = flycapInfo.CameraModel;

            // Start FlyCapture.

            /*if (cameraModel == PGRFlyModule.FlyCaptureCameraModel.FLYCAPTURE_DRAGONFLY2)
             *  ret = PGRFlyDllBridge.flycaptureStart(flycapContext,
             *      PGRFlyModule.FlyCaptureVideoMode.FLYCAPTURE_VIDEOMODE_640x480RGB, frameRate);
             * else*/
            ret = PGRFlyDllBridge.flycaptureStart(flycapContext, videoMode, frameRate);

            if (ret != 0)
            {
                ReportError(ret, "flycaptureStart");
            }

            this.flycapContext = flycapContext;
        }
示例#3
0
        public void Dispose()
        {
            int ret;

            // Stop FlyCapture.
            ret = PGRFlyDllBridge.flycaptureStop(flycapContext);

            /*if (ret != 0)
             *  ReportError(ret, "flycaptureStop");*/

            // Destroy the context.
            ret = PGRFlyDllBridge.flycaptureDestroyContext(flycapContext);

            /*if(ret != 0)
             *  ReportError(ret, "flycaptureDestroyContext");*/
        }