Ejemplo n.º 1
0
        /// <summary>
        /// Connects to the MRCamera and prepares it for capturing.
        /// </summary>
        /// <returns>
        /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successfully initialized the MR camera.
        /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to an invalid input parameter.
        /// MLResult.Result will be <c>MLResult.Code.MediaGenericAlreadyExists</c> if the MR camera was already initialized.
        /// MLResult.Result will be <c>MLResult.Code.MediaGenericNoInit</c> if the MR camera was not properly initialized.
        /// </returns>
        private MLResult.Code SetupMLMRCamera()
        {
            if (this.isConnected)
            {
                return(MLResult.Code.Ok);
            }

            NativeBindings.InputContextNative contextNative = new NativeBindings.InputContextNative();
            contextNative.Data = this.inputContext;
            MLResult.Code resultCode = NativeBindings.MLMRCameraConnect(ref contextNative);
            if (!MLMRCamera.DidNativeCallSucceed(resultCode, "MLMRCameraConnect"))
            {
                return(resultCode);
            }

            this.isConnected = true;

            NativeBindings.CallbacksNative callbacksNative = NativeBindings.CreateCallbacks();
            resultCode = NativeBindings.MLMRCameraSetCallbacks(ref callbacksNative, IntPtr.Zero);
            if (!MLMRCamera.DidNativeCallSucceed(resultCode, "MLMRCameraSetCallbacks"))
            {
                return(resultCode);
            }

            return(resultCode);
        }