/// <summary>
 /// Start capturing raw video.
 /// </summary>
 public void StartCapture()
 {
     if (!_isCapturing && MLCamera.IsStarted && _isCameraConnected)
     {
         MLResult result = MLCamera.StartRawVideoCapture();
         if (result.IsOk)
         {
             _isCapturing      = true;
             _captureStartTime = Time.time;
             OnVideoCaptureStarted?.Invoke();
             SetupCameraIntrinsics();
         }
         else
         {
             CheckPrivilegeDenied(result);
             Debug.LogErrorFormat("Error: RawVideoCaptureExample failed to start raw video capture. Reason: {1}", MLCamera.GetErrorCode().ToString());
         }
     }
     else
     {
         Debug.LogErrorFormat("Error: RawVideoCaptureExample failed to start raw video capture.");
     }
 }
Exemple #2
0
        ///// <summary>
        ///// Start capturing video to input filename.
        ///// </summary>
        ///// <param name="fileName">File path to write the video to.</param>
        //public void StartCapture(string fileName)
        //{
        //    #if PLATFORM_LUMIN
        //    if(!_isCapturing && MLCamera.IsStarted && _isCameraConnected)
        //    {
        //        // Check file fileName extensions
        //        string extension = System.IO.Path.GetExtension(fileName);
        //        if (string.IsNullOrEmpty(extension) || !extension.Equals(_validFileFormat, System.StringComparison.OrdinalIgnoreCase))
        //        {
        //            Debug.LogErrorFormat("Invalid fileName extension '{0}' passed into Capture({1}).\n" +
        //                "Videos must be saved in {2} format.", extension, fileName, _validFileFormat);
        //            return;
        //        }

        //        string pathName = System.IO.Path.Combine(Application.persistentDataPath, fileName);

        //        MLResult result = MLCamera.StartVideoCapture(pathName);
        //        if (result.IsOk)
        //        {
        //            _isCapturing = true;
        //            _captureStartTime = Time.time;
        //            _captureFilePath = pathName;
        //            OnVideoCaptureStarted.Invoke();
        //        }
        //        else
        //        {
        //            Debug.LogErrorFormat("Error: VideoCaptureExample failed to start video capture for {0}. Reason: {1}", fileName, MLCamera.GetErrorCode().ToString());
        //        }
        //    }
        //    else
        //    {
        //        Debug.LogErrorFormat("Error: VideoCaptureExample failed to start video capture for {0} because '{1}' is already recording!",
        //            fileName, _captureFilePath);
        //    }
        //    #endif
        //}

        /// <summary>
        /// Start capturing raw video.
        /// </summary>
        public void StartRawCapture()
        {
            #if PLATFORM_LUMIN
            if (!_isCapturing && MLCamera.IsStarted && _isCameraConnected)
            {
                MLResult result = MLCamera.StartRawVideoCapture();
                if (result.IsOk)
                {
                    _isCapturing = true;
                    //_captureStartTime = Time.time;
                    OnRawVideoCaptureStarted.Invoke();
                    SetupCameraIntrinsics();
                }
                else
                {
                    Debug.LogErrorFormat("Error: VideoCaptureExample failed to start raw video capture. Reason: {1}", MLCamera.GetErrorCode().ToString());
                }
            }
            else
            {
                Debug.LogErrorFormat("Error: VideoCaptureExample failed to start raw video capture.");
            }
            #endif
        }