예제 #1
0
        /// <summary>
        /// Get the intrinsic calibration parameters.
        /// </summary>
        /// <param name="cameraId">The id of the camera.</param>
        /// <param name="outParameters">The intrinsic calibration parameters.</param>
        /// <returns>
        /// MLResult.Result will be <c>MLResult.Code.Ok</c> if obtained result extras successfully.
        /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed to obtain result extras due to invalid input parameter.
        /// </returns>
        private MLResult InternalGetIntrinsicCalibrationParameters(MLCVCameraNativeBindings.CameraID cameraId, out MLCVCamera.IntrinsicCalibrationParameters outParameters)
        {
            outParameters = new MLCVCamera.IntrinsicCalibrationParameters();

            MLCVCameraNativeBindings.IntrinsicCalibrationParametersNative internalParameters =
                MLCVCameraNativeBindings.IntrinsicCalibrationParametersNative.Create();

            MLResult.Code resultCode = MLCVCameraNativeBindings.MLCVCameraGetIntrinsicCalibrationParameters(Handle, cameraId, ref internalParameters);

            MLResult parametersResult = MLResult.Create(resultCode);

            if (!parametersResult.IsOk)
            {
                MLPluginLog.ErrorFormat("MLCamera.InternalGetIntrinsicCalibrationParameters failed to get camera parameters. Reason: {0}", parametersResult);
            }
            else
            {
                outParameters.Width          = internalParameters.Width;
                outParameters.Height         = internalParameters.Height;
                outParameters.FocalLength    = new Vector2(internalParameters.FocalLength.X, internalParameters.FocalLength.Y);
                outParameters.PrincipalPoint = new Vector2(internalParameters.PrincipalPoint.X, internalParameters.PrincipalPoint.Y);
                outParameters.FOV            = internalParameters.FOV;
                outParameters.Distortion     = new double[internalParameters.Distortion.Length];
                internalParameters.Distortion.CopyTo(outParameters.Distortion, 0);
            }

            return(parametersResult);
        }
예제 #2
0
        /// <summary>
        /// Get the frame pose.
        /// </summary>
        /// <param name="cameraId">The camera id.</param>
        /// <param name="vcamTimestamp">The timestamp of the frame pose.</param>
        /// <param name="outTransform">The transform of the frame pose.</param>
        /// <returns>
        /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful.
        /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error.
        /// </returns>
        private MLResult InternalGetFramePose(MLCVCameraNativeBindings.CameraID cameraId, ulong vcamTimestamp, out Matrix4x4 outTransform)
        {
            MagicLeapNativeBindings.MLTransform outInternalTransform = new MagicLeapNativeBindings.MLTransform();

            MLResult.Code resultCode = MLCVCameraNativeBindings.MLCVCameraGetFramePose(Handle, headTrackerHandle, cameraId, vcamTimestamp, ref outInternalTransform);
            MLResult      poseResult = MLResult.Create(resultCode);

            if (!poseResult.IsOk)
            {
                MLPluginLog.ErrorFormat("MLCamera.InternalGetFramePose failed to get camera frame pose. Reason: {0}", poseResult);
                outTransform = new Matrix4x4();
            }
            else
            {
                outTransform = MLConvert.ToUnity(outInternalTransform);
            }

            return(poseResult);
        }