Exemple #1
0
            // Methods

            /// <summary>
            /// Check if the properties are properly set.
            /// </summary>
            public void PropertyCheck(ArucoCamera arucoCamera)
            {
                // Check for camera ids
                if (CameraId1 >= arucoCamera.CameraNumber)
                {
                    throw new ArgumentOutOfRangeException("CameraId1", "The id of the first camera is higher than the number of the cameras.");
                }
                if (CameraId2 >= arucoCamera.CameraNumber)
                {
                    throw new ArgumentOutOfRangeException("CameraId2", "The id of the second camera is higher than the number of the cameras.");
                }

                // Check for equality of image sizes
                if (arucoCamera.ImageTextures[CameraId1].width != arucoCamera.ImageTextures[CameraId2].width ||
                    arucoCamera.ImageTextures[CameraId1].height != arucoCamera.ImageTextures[CameraId2].height)
                {
                    throw new Exception("The two cameras must have the same image size.");
                }

                // Check for the calibration flags
                calibrationFlagsPinholeController = CalibrationFlagsController as CalibrationFlagsPinholeController;
                calibrationFlagsOmnidirController = CalibrationFlagsController as CalibrationFlagsOmnidirController;
                if (CalibrationFlagsController == null ||
                    (calibrationFlagsPinholeController == null && calibrationFlagsOmnidirController == null))
                {
                    throw new ArgumentNullException("CalibrationFlagsController", "This property needs to be set to configure the calibrator.");
                }
                else if (arucoCamera.UndistortionType == UndistortionType.Pinhole && calibrationFlagsPinholeController == null)
                {
                    throw new ArgumentException("CalibrationFlagsController", "The camera is set for the pinhole undistortion, but the calibration flags are"
                                                + " not. Use CalibrationFlagsPinholeController instead.");
                }
                else if (new[] { UndistortionType.OmnidirPerspective, UndistortionType.OmnidirCylindrical, UndistortionType.OmnidirLonglati,
                                 UndistortionType.OmnidirStereographic }.Contains(arucoCamera.UndistortionType) && calibrationFlagsOmnidirController == null)
                {
                    throw new ArgumentException("CalibrationFlagsController", "The camera is set for an omnidir undistortion, but the calibration flags are"
                                                + " not. Use CalibrationFlagsOmnidirController instead.");
                }
            }
Exemple #2
0
            // ArucoDetector Methods

            /// <summary>
            /// Check if the properties are properly set and and reset the calibration.
            /// </summary>
            protected override void PreConfigure()
            {
                // Check for the board
                if (CalibrationBoard == null)
                {
                    throw new ArgumentNullException("CalibrationBoard", "This property needs to be set to configure the calibrator.");
                }

                // Check for the calibration flags
                calibrationFlagsPinholeController = CalibrationFlagsController as CalibrationFlagsPinholeController;
                calibrationFlagsOmnidirController = CalibrationFlagsController as CalibrationFlagsOmnidirController;
                if (CalibrationFlagsController == null ||
                    (calibrationFlagsPinholeController == null && calibrationFlagsOmnidirController == null))
                {
                    throw new ArgumentNullException("CalibrationFlagsController", "This property needs to be set to configure the calibrator.");
                }
                else if (ArucoCamera.UndistortionType == UndistortionType.Pinhole && calibrationFlagsPinholeController == null)
                {
                    throw new ArgumentException("CalibrationFlagsController", "The camera is set for the pinhole undistortion, but the calibration flags are"
                                                + " not. Use CalibrationFlagsPinholeController instead.");
                }
                else if (new[] { UndistortionType.OmnidirPerspective, UndistortionType.OmnidirCylindrical, UndistortionType.OmnidirLonglati,
                                 UndistortionType.OmnidirStereographic }.Contains(ArucoCamera.UndistortionType) && calibrationFlagsOmnidirController == null)
                {
                    throw new ArgumentException("CalibrationFlagsController", "The camera is set for an omnidir undistortion, but the calibration flags are"
                                                + " not. Use CalibrationFlagsOmnidirController instead.");
                }

                // Check for the stereo calibration properties
                foreach (var stereoCameraPair in StereoCalibrationCameraPairs)
                {
                    stereoCameraPair.PropertyCheck(ArucoCamera);
                }

                ResetCalibration();
            }