Example #1
0
        public static DS4CalibrationRecord Calibrate(PXCMCapture.Device device)
        {
            PXCMProjection projection = device.CreateProjection();
            /* Get a calibration instance */
            PXCMCalibration calib = projection.QueryInstance <PXCMCalibration>();

            PXCMCalibration.StreamCalibration calibration;
            PXCMCalibration.StreamTransform   transformation;

            calib.QueryStreamProjectionParameters(PXCMCapture.StreamType.STREAM_TYPE_COLOR, out calibration, out transformation);

            float[] translation = transformation.translation;

            DS4CalibrationRecord record = new DS4CalibrationRecord
            {
                DeviceCapture = new DS4CalibrationRecordInternal
                {
                    ColorFocalLength = device.QueryColorFocalLength().toFloatArray(),
                    DepthFocalLength = device.QueryDepthFocalLength().toFloatArray(),

                    ColorFOV = device.QueryColorFieldOfView().toFloatArray(),
                    DepthFOV = device.QueryDepthFieldOfView().toFloatArray(),

                    ColorPrincipalPoint = device.QueryColorPrincipalPoint().toFloatArray(),
                    DepthPrincipalPoint = device.QueryDepthPrincipalPoint().toFloatArray(),

                    ColorWidth  = Frame.COLOR_WIDTH,
                    ColorHeight = Frame.COLOR_HEIGHT,

                    DepthWidth  = Frame.DEPTH_WIDTH,
                    DepthHeight = Frame.DEPTH_HEIGHT,
                    DepthStride = Frame.DEPTH_STRIDE,

                    LowConfValue = device.QueryDepthLowConfidenceValue(),

                    Extrinsics = new float[] { 1.0f,
                                               0.0f,
                                               0.0f,
                                               translation[0],
                                               0.0f,
                                               1.0f,
                                               0.0f,
                                               translation[1],
                                               0.0f,
                                               0.0f,
                                               1.0f,
                                               translation[2],
                                               0.0f,
                                               0.0f,
                                               0.0f,
                                               1.0f }
                },

                API = "RSSDK"
            };

            return(record);
        }