예제 #1
0
        public static bool Transformation2dTo3d(Calibration calibration, float[] sourcePoint2d, float sourceDepth,
                                                CalibrationType sourceCamera, CalibrationType targetCamera, ref float[] targetPoint3d, ref int valid)
        {
            bool succeeded = false;

            if (sourceCamera == CalibrationType.Depth)
            {
                succeeded = IntrinsicTransformation.Unproject(calibration.DepthCameraCalibration, sourcePoint2d, sourceDepth, ref targetPoint3d, ref valid);
            }
            else if (sourceCamera == CalibrationType.Color)
            {
                succeeded = IntrinsicTransformation.Unproject(calibration.ColorCameraCalibration, sourcePoint2d, sourceDepth, ref targetPoint3d, ref valid);
            }

            if (!succeeded)
            {
                return(false);
            }

            if (sourceCamera == targetCamera)
            {
                return(true);
            }
            else
            {
                return(Transformation3dTo3d(calibration, targetPoint3d, sourceCamera, targetCamera, ref targetPoint3d));;
            }
        }
예제 #2
0
        public static bool Transformation3dTo2d(Calibration calibration, float[] sourcePoint3d,
                                                CalibrationType sourceCamera, CalibrationType targetCamera, ref float[] targetPoint2d, ref int valid)
        {
            float[] targetPoint3d = new float[3];
            if (sourceCamera == targetCamera)
            {
                targetPoint3d[0] = sourcePoint3d[0];
                targetPoint3d[1] = sourcePoint3d[1];
                targetPoint3d[2] = sourcePoint3d[2];
            }
            else
            {
                bool succeeded = Transformation3dTo3d(calibration, sourcePoint3d, sourceCamera, targetCamera, ref targetPoint3d);
                if (!succeeded)
                {
                    return(false);
                }
            }

            if (targetCamera == CalibrationType.Depth)
            {
                return(IntrinsicTransformation.Project(calibration.DepthCameraCalibration, targetPoint3d, ref targetPoint2d, ref valid));
            }
            else if (targetCamera == CalibrationType.Color)
            {
                return(IntrinsicTransformation.Project(calibration.ColorCameraCalibration, targetPoint3d, ref targetPoint2d, ref valid));
            }

            return(true);
        }