//----------------------------------------------------------------- public void StartVideoModeAsync(CameraParameters setupParams, AudioState audioState, OnVideoModeStartedCallback onVideoModeStartedCallback) { if (m_NativePtr == IntPtr.Zero) { throw new InvalidOperationException("You must create a Video Capture Object before starting its video mode."); } if (onVideoModeStartedCallback == null) { throw new ArgumentNullException("onVideoModeStartedCallback"); } if (setupParams.cameraResolutionWidth == default(int) || setupParams.cameraResolutionHeight == default(int)) { throw new ArgumentOutOfRangeException("setupParams", "The camera resolution must be set to a supported resolution."); } if (setupParams.frameRate == default(float)) { throw new ArgumentOutOfRangeException("setupParams", "The camera frame rate must be set to a supported recording frame rate."); } StartVideoMode_Internal(m_NativePtr, (int)audioState, onVideoModeStartedCallback, setupParams.hologramOpacity, setupParams.frameRate, setupParams.cameraResolutionWidth, setupParams.cameraResolutionHeight, (int)setupParams.pixelFormat); }
/// <summary> /// Asynchronously starts video mode. /// /// Activates the web camera with the various settings specified in CameraParameters. /// Only one VideoCapture instance can start the video mode at any given time. /// After starting the video mode, you listen for new video frame samples via the VideoCapture.FrameSampleAcquired event, /// or by calling VideoCapture.RequestNextFrameSample() when will return the next available sample. /// While in video mode, more power will be consumed so make sure that you call VideoCapture.StopVideoModeAsync qhen you can afford the start/stop video mode overhead. /// </summary> /// <param name="setupParams">Parameters that change how video mode is used.</param> /// <param name="onVideoModeStartedCallback">This callback will be invoked once video mode has been activated.</param> public async void StartVideoModeAsync(CameraParameters setupParams, OnVideoModeStartedCallback onVideoModeStartedCallback) { var mediaFrameSource = _mediaCapture.FrameSources[_frameSourceInfo.Id]; //Returns a MediaFrameSource if (mediaFrameSource == null) { onVideoModeStartedCallback?.Invoke(new VideoCaptureResult(1, ResultType.UnknownError, false)); return; } var pixelFormat = ConvertCapturePixelFormatToMediaEncodingSubtype(setupParams.pixelFormat); _frameReader = await _mediaCapture.CreateFrameReaderAsync(mediaFrameSource, pixelFormat); _frameReader.FrameArrived += HandleFrameArrived; await _frameReader.StartAsync(); VideoEncodingProperties properties = GetVideoEncodingPropertiesForCameraParams(setupParams); // Historical context: https://github.com/VulcanTechnologies/HoloLensCameraStream/issues/6 if (setupParams.rotateImage180Degrees) { properties.Properties.Add(ROTATION_KEY, 180); } // gr: taken from here https://forums.hololens.com/discussion/2009/mixedrealitycapture IVideoEffectDefinition ved = new VideoMRCSettings(setupParams.enableHolograms, setupParams.enableVideoStabilization, setupParams.videoStabilizationBufferSize, setupParams.hologramOpacity); await _mediaCapture.AddVideoEffectAsync(ved, MediaStreamType.VideoPreview); await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(STREAM_TYPE, properties); onVideoModeStartedCallback?.Invoke(new VideoCaptureResult(0, ResultType.Success, true)); }
public void StartVideoModeAsync(CameraParameters setupParams, OnVideoModeStartedCallback onVideoModeStartedCallback) { setupParams.camMode = CamMode.VideoMode; setupParams.hologramOpacity = 1; m_CaptureContext.StartCaptureMode(setupParams); var result = new VideoCaptureResult(); result.resultType = CaptureResultType.Success; onVideoModeStartedCallback?.Invoke(result); }
/// <summary> /// Asynchronously starts video mode. /// /// Activates the web camera with the various settings specified in CameraParameters. /// Only one VideoCapture instance can start the video mode at any given time. /// After starting the video mode, you listen for new video frame samples via the VideoCapture.FrameSampleAcquired event, /// or by calling VideoCapture.RequestNextFrameSample() when will return the next available sample. /// While in video mode, more power will be consumed so make sure that you call VideoCapture.StopVideoModeAsync qhen you can afford the start/stop video mode overhead. /// </summary> /// <param name="setupParams">Parameters that change how video mode is used.</param> /// <param name="onVideoModeStartedCallback">This callback will be invoked once video mode has been activated.</param> public async void StartVideoModeAsync(CameraParameters setupParams, OnVideoModeStartedCallback onVideoModeStartedCallback) { var mediaFrameSource = _mediaCapture.FrameSources[_frameSourceInfo.Id]; //Returns a MediaFrameSource if (mediaFrameSource == null) { onVideoModeStartedCallback?.Invoke(new VideoCaptureResult(1, ResultType.UnknownError, false)); return; } bool requires_change = mediaFrameSource.CurrentFormat.VideoFormat.Width != setupParams.cameraResolutionWidth || mediaFrameSource.CurrentFormat.VideoFormat.Height != setupParams.cameraResolutionHeight || (int)Math.Round(((double)mediaFrameSource.CurrentFormat.FrameRate.Numerator / mediaFrameSource.CurrentFormat.FrameRate.Denominator)) != setupParams.frameRate; if (requires_change) { await SetFrameType(mediaFrameSource, setupParams.cameraResolutionWidth, setupParams.cameraResolutionHeight, setupParams.frameRate); } // gr: taken from here https://forums.hololens.com/discussion/2009/mixedrealitycapture IVideoEffectDefinition ved = new VideoMRCSettings(setupParams.enableHolograms, setupParams.enableVideoStabilization, setupParams.videoStabilizationBufferSize, setupParams.hologramOpacity, setupParams.recordingIndicatorVisible); await _mediaCapture.AddVideoEffectAsync(ved, STREAM_TYPE); if (!_sharedStream) { VideoEncodingProperties properties = GetVideoEncodingPropertiesForCameraParams(setupParams); // Historical context: https://github.com/VulcanTechnologies/HoloLensCameraStream/issues/6 if (setupParams.rotateImage180Degrees) { properties.Properties.Add(ROTATION_KEY, 180); } // We can't modify the stream properties if we are sharing the stream await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(STREAM_TYPE, properties); } var pixelFormat = ConvertCapturePixelFormatToMediaEncodingSubtype(setupParams.pixelFormat); _frameReader = await _mediaCapture.CreateFrameReaderAsync(mediaFrameSource, pixelFormat); _frameReader.FrameArrived += HandleFrameArrived; await _frameReader.StartAsync(); onVideoModeStartedCallback?.Invoke(new VideoCaptureResult(0, ResultType.Success, true)); }
//----------------------------------------------------------------- public void StartVideoModeAsync(CameraParameters setupParams, AudioState audioState, OnVideoModeStartedCallback onVideoModeStartedCallback) { if (onVideoModeStartedCallback == null) { throw new ArgumentNullException("onVideoModeStartedCallback"); } if (setupParams.cameraResolutionWidth == default(int) || setupParams.cameraResolutionHeight == default(int)) { throw new ArgumentOutOfRangeException("setupParams", "The camera resolution must be set to a supported resolution."); } if (setupParams.frameRate == default(float)) { throw new ArgumentOutOfRangeException("setupParams", "The camera frame rate must be set to a supported recording frame rate."); } StartVideoMode_Internal(setupParams, audioState, onVideoModeStartedCallback); }
/// <summary> /// Asynchronously starts video mode. /// /// Activates the web camera with the various settings specified in CameraParameters. /// Only one VideoCapture instance can start the video mode at any given time. /// After starting the video mode, you listen for new video frame samples via the VideoCapture.FrameSampleAcquired event, /// or by calling VideoCapture.RequestNextFrameSample() when will return the next available sample. /// While in video mode, more power will be consumed so make sure that you call VideoCapture.StopVideoModeAsync qhen you can afford the start/stop video mode overhead. /// </summary> /// <param name="setupParams">Parameters that change how video mode is used.</param> /// <param name="onVideoModeStartedCallback">This callback will be invoked once video mode has been activated.</param> public async void StartVideoModeAsync(CameraParameters setupParams, OnVideoModeStartedCallback onVideoModeStartedCallback) { var mediaFrameSource = _mediaCapture.FrameSources[_frameSourceInfo.Id]; //Returns a MediaFrameSource if (mediaFrameSource == null) { onVideoModeStartedCallback?.Invoke(new VideoCaptureResult(1, ResultType.UnknownError, false)); return; } var pixelFormat = ConvertCapturePixelFormatToMediaEncodingSubtype(setupParams.pixelFormat); _frameReader = await _mediaCapture.CreateFrameReaderAsync(mediaFrameSource, pixelFormat); _frameReader.FrameArrived += HandleFrameArrived; await _frameReader.StartAsync(); VideoEncodingProperties properties = GetVideoEncodingPropertiesForCameraParams(setupParams); properties.Properties.Add(ROTATION_KEY, 180); await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(STREAM_TYPE, properties); onVideoModeStartedCallback?.Invoke(new VideoCaptureResult(0, ResultType.Success, true)); }
private static void InvokeOnVideoModeStartedDelegate(OnVideoModeStartedCallback callback, long hResult) { callback(MakeCaptureResult(hResult)); }
private extern void StartVideoMode_Internal(CameraParameters cameraParameters, AudioState audioState, OnVideoModeStartedCallback onVideoModeStartedCallback);
public void StartVideoModeAsync(CameraParameters setupParams, OnVideoModeStartedCallback onVideoModeStartedCallback) { throw new NotImplementedException(); }
public void StartVideoModeAsync(CameraParameters setupParams, AudioState audioState, OnVideoModeStartedCallback onVideoModeStartedCallback) { m_RecordBehaviour.SetConfigration(setupParams); if (onVideoModeStartedCallback != null) { var result = new VideoCaptureResult(); result.resultType = CaptureResultType.Success; onVideoModeStartedCallback(result); } }
public void StartCamera(Mode mode = Mode.LISTENER, OnVideoModeStartedCallback videoStart = null) { VideoModeStartedCallback = videoStart; VideoMode = mode; VideoCapture?.StartVideoModeAsync(Params, OnVideoModeStarted); }
public void StartVideoModeAsync(CameraParameters setupParams, AudioState audioState, OnVideoModeStartedCallback onVideoModeStartedCallback) { if (this.m_NativePtr == IntPtr.Zero) { throw new InvalidOperationException("You must create a Video Capture Object before starting its video mode."); } if (onVideoModeStartedCallback == null) { throw new ArgumentNullException("onVideoModeStartedCallback"); } if ((setupParams.cameraResolutionWidth == 0) || (setupParams.cameraResolutionHeight == 0)) { throw new ArgumentOutOfRangeException("setupParams", "The camera resolution must be set to a supported resolution."); } if (setupParams.frameRate == 0f) { throw new ArgumentOutOfRangeException("setupParams", "The camera frame rate must be set to a supported recording frame rate."); } this.StartVideoMode_Internal(this.m_NativePtr, (int) audioState, onVideoModeStartedCallback, setupParams.hologramOpacity, setupParams.frameRate, setupParams.cameraResolutionWidth, setupParams.cameraResolutionHeight, (int) setupParams.pixelFormat); }
private extern void StartVideoMode_Internal(IntPtr videoCaptureObj, int audioState, OnVideoModeStartedCallback onVideoModeStartedCallback, float hologramOpacity, float frameRate, int cameraResolutionWidth, int cameraResolutionHeight, int pixelFormat);