コード例 #1
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;
        }
コード例 #2
0
ファイル: PGRFlyCapture.cs プロジェクト: NinjaSteph/SureShot
        /// <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;
        }