public async Task StopRecording() { if (!GetSensor() || !_isRecording) { return; } if (!ReferenceEquals(null, _recorder)) { await _recorder.StopAsync(); _recorder = null; } foreach (var module in ProcessingLoader.Instance.ProcessingModules) { if (module is IKinectProcessingModule kinectModule) { if (!ReferenceEquals(null, kinectModule.BodyListener())) { _bodyReader.FrameArrived -= kinectModule.BodyListener(); } if (!ReferenceEquals(null, kinectModule.ColorListener())) { _colorReader.FrameArrived -= kinectModule.ColorListener(); } if (!ReferenceEquals(null, kinectModule.AudioListener())) { _audioBeamReader.FrameArrived -= kinectModule.AudioListener(); } } } _isRecording = false; }
public async Task StartRecording() { if (!GetSensor()) { return; } int detectorCount = _sensor.BodyFrameSource.BodyCount > 0 ? _sensor.BodyFrameSource.BodyCount : 6; for (int i = 0; i < _sensor.BodyFrameSource.BodyCount; ++i) { try { GestureDetector detector = new GestureDetector(i, _sensor); GestureDetector.GestureDetectorList.Add(detector); } catch (Exception ex) { Console.WriteLine("Error at creating the gesture detector: " + ex.Message); } } _bodyReader.FrameArrived += GestureDetector._bodyReader_FrameArrived; foreach (var module in ProcessingLoader.Instance.ProcessingModules) { if (module.IsEnabled) { if (module is IKinectProcessingModule kinectModule) { if (!ReferenceEquals(null, kinectModule.BodyListener())) { _bodyReader.FrameArrived += kinectModule.BodyListener(); } if (!ReferenceEquals(null, kinectModule.ColorListener())) { _colorReader.FrameArrived += kinectModule.ColorListener(); } if (!ReferenceEquals(null, kinectModule.AudioListener())) { _audioBeamReader.FrameArrived += kinectModule.AudioListener(); } if (!ReferenceEquals(null, kinectModule.GestureListener())) { foreach (var detector in GestureDetector.GestureDetectorList) { detector.KinectGestureFrameArrived += kinectModule.GestureListener(); } } } } } if (ReferenceEquals(null, _recorder) && !ReferenceEquals(null, _dataAccessFacade.GetSceneInUseAccess().GetScene())) { string fileName = Path.Combine(_dataAccessFacade.GetGeneralSettings().GetSceneInUseDirectory(), "kinect.dvr"); _recorder = new DVR.Recorder(File.Open(fileName, FileMode.Create), _sensor) { EnableBodyRecorder = true, EnableColorRecorder = true, EnableDepthRecorder = false, EnableInfraredRecorder = false, ColorRecorderCodec = new JpegColorCodec() }; //TODO: revisar estos pixeles //_recorder.ColorRecorderCodec.OutputWidth = 1280; //_recorder.ColorRecorderCodec.OutputHeight = 720; _recorder.Start(); } _isRecording = true; }