private static Random _xrand;// = new Random(DateTime.Now.Second); public static TagType Classify(List <double[]> signalsList) { try { if (ReferenceEquals(null, _svm)) { string internalPath = $"{_dataAccessFacade.GetGeneralSettings().GetDataDirectory()}" + $"modal/Emotion/emotionmodel.svm"; _svm = Serializer.Load <MulticlassSupportVectorMachine <Gaussian> >(path: internalPath); } var featureVector = PreProcess(signalsList, 0.7, EEGEmoProc2ChSettings.Instance.m.Value, EEGEmoProc2ChSettings.Instance.r.Value, EEGEmoProc2ChSettings.Instance.N.Value, 1, 0); Console.WriteLine("preprocesado" + featureVector.ToJsonString()); return((TagType)_svm.Decide(featureVector.ToArray())); } catch (Exception ex) { Console.WriteLine($"error: {ex.Message}"); throw ex; } }
/// <summary> /// Initializes a new instance of the <see cref="GestureDetector"/> class. /// </summary> /// <param name="bodyIndex">Index of the body.</param> /// <param name="kinectSensor">Active sensor to initialize the VisualGestureBuilderFrameSource object with.</param> public GestureDetector(int bodyIndex, KinectSensor kinectSensor) { BodyIndex = bodyIndex; if (ReferenceEquals(null, kinectSensor)) { throw new ArgumentNullException("kinectSensor is null"); } // create the vgb source. The associated body tracking ID will be set when a valid body frame arrives from the sensor. _vgbFrameSource = new VisualGestureBuilderFrameSource(kinectSensor, 0); VgbFrameReader = _vgbFrameSource.OpenReader(); if (!ReferenceEquals(null, VgbFrameReader)) { VgbFrameReader.IsPaused = true; VgbFrameReader.FrameArrived += VgbFrameReader_FrameArrived; } //get all discrete and continuous postures var discretePostures = _dataAccessFacade.GetSubModalAccess().GetAll("Discrete Posture"); var continuousPostures = _dataAccessFacade.GetSubModalAccess().GetAll("Continuous Posture"); //add all the database filenames of each posture to posturePaths list List <string> posturePaths = new List <string>(); foreach (var discrete in discretePostures) { if (!ReferenceEquals(null, discrete.File)) { string internalFilePath = $"{_dataAccessFacade.GetGeneralSettings().GetDataDirectory()}" + $"modal/Discrete Posture/{discrete.File}"; posturePaths.Add(internalFilePath); } } foreach (var continuous in continuousPostures) { if (!ReferenceEquals(null, continuous.File)) { string internalFilePath = $"{_dataAccessFacade.GetGeneralSettings().GetDataDirectory()}" + $"modal/Continuous Posture/{continuous.File}"; posturePaths.Add(internalFilePath); } } //add the database files of the postures to the detector foreach (var posturePath in posturePaths) { Console.WriteLine("Loading VGB Database: '{0}'", posturePath); using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(posturePath)) { _vgbFrameSource.AddGestures(database.AvailableGestures); } } }
public async Task StartRecording() { StartStream(); _filemanage = new Util.FileManage( Path.Combine( _dataAccessFacade.GetGeneralSettings().GetSceneInUseDirectory(), "openbci_" + _person.PersonId + ".csv")); _isRecording = true; foreach (var module in ProcessingLoader.Instance.ProcessingModules) { if (module.IsEnabled) { if (module is IEegProcessingModule eegModule) { EegFrameArrived += eegModule.EegListener(); } if (module is IAccelerometerProcessingModule accModule) { AccelerometerFrameArrived += accModule.AccelerometerListener(); } } } }
public void Play() { if (ReferenceEquals(null, _replay) && !ReferenceEquals(null, _dataAccessFacade.GetSceneInUseAccess().GetScene())) { try { string fileName = _dataAccessFacade.GetGeneralSettings().GetDataDirectory() + "scene/" + _dataAccessFacade.GetSceneInUseAccess().GetScene().SceneId + "/kinect.dvr"; if (File.Exists(fileName)) { Console.WriteLine($"archivo {fileName} existe, a abrirlo"); _replay = new KinectReplay(File.Open(fileName, FileMode.Open, FileAccess.Read)); _replay.PropertyChanged += _replay_PropertyChanged; if (_replay.HasBodyFrames) { _replay.BodyFrameArrived += KinectInput.SkeletonColorVideoViewer._replay_BodyFrameArrived; } if (_replay.HasColorFrames) { _replay.ColorFrameArrived += KinectInput.SkeletonColorVideoViewer._replay_ColorFrameArrived; } _replay.ScrubTo(new TimeSpan(0)); _replay.Start(); } } catch (Exception) { Close(); } } else { _replay.Start(); } }
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; }
public async void StopRecording() { foreach (var personPair in CheckPerson.Instance.PersonsId) { try { _dataAccessFacade.GetIntervalAccess().FromEvent(personPair.Value, "Voice", "Talked", _dataAccessFacade.GetGeneralSettings().GetDefaultMillisecondsThreshold(), 1, "Talked"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { string error = ""; string name = nameTextBox.Text; if (String.IsNullOrEmpty(_safeFileName) && ReferenceEquals(null, _posture)) { error += "\n" + Properties.GestureConfiguration.Error_NoFile; } if (String.IsNullOrEmpty(name)) { error += "\n" + Properties.GestureConfiguration.Error_NoName; } if (_dataAccessFacade.GetSubModalAccess().Exists(PostureCRUD.PostureTypes[TypeCombobox.SelectedIndex], name) && ReferenceEquals(null, _posture)) { error += $"\n{Properties.GestureConfiguration.Error_ThePosture} {name} {Properties.GestureConfiguration.Error_PostureExists}"; } if (!String.IsNullOrEmpty(error)) { MessageBox.Show($"{Properties.GestureConfiguration.Error_ThereAreErrors}{error}", Properties.GestureConfiguration.Error); } else if (ReferenceEquals(null, _posture)) //is adding { string internalFilePath = $"{_dataAccessFacade.GetGeneralSettings().GetDataDirectory()}" + $"modal/{PostureCRUD.PostureTypes[TypeCombobox.SelectedIndex]}/{_safeFileName}"; if (!File.Exists(internalFilePath)) { File.Copy(FileNameTextBox.Text, internalFilePath); } _dataAccessFacade.GetSubModalAccess().Add(PostureCRUD.PostureTypes[TypeCombobox.SelectedIndex], name, DescriptionTextBox.Text, _safeFileName); Close(); } else //editing { var subModal = _dataAccessFacade.GetSubModalAccess().Get(PostureCRUD.PostureTypes[TypeCombobox.SelectedIndex], name); string oldPath = subModal.File; subModal.SubModalTypeId = name; subModal.File = _safeFileName ?? oldPath; subModal.Description = DescriptionTextBox.Text; _dataAccessFacade.GetSubModalAccess().Update(subModal); if (!String.IsNullOrEmpty(_safeFileName)) { string internalFilePath = $"{_dataAccessFacade.GetGeneralSettings().GetModalDirectory(PostureCRUD.PostureTypes[TypeCombobox.SelectedIndex])}/{_safeFileName}"; if (oldPath.Equals(internalFilePath)) { if (File.Exists(oldPath)) { File.Delete(oldPath); } if (!File.Exists(internalFilePath)) { File.Copy(FileNameTextBox.Text, internalFilePath); } } } Close(); } }
public async void StopRecording() { foreach (var personPair in CheckPerson.Instance.PersonsId) { try { _dataAccessFacade.GetIntervalAccess().FromEvent(personPair.Value, "Neck Orientation", "Yaw", _dataAccessFacade.GetGeneralSettings().GetDefaultMillisecondsThreshold(), 0, "Watching public"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } try { _dataAccessFacade.GetIntervalAccess().FromEvent(personPair.Value, "Lean", "Y", _dataAccessFacade.GetGeneralSettings().GetDefaultMillisecondsThreshold(), 0, "Upside"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } try { _dataAccessFacade.GetIntervalAccess().FromEvent(personPair.Value, "Lean", "Y", _dataAccessFacade.GetGeneralSettings().GetDefaultMillisecondsThreshold(), 1, "Straight"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } try { _dataAccessFacade.GetIntervalAccess().FromEvent(personPair.Value, "Lean", "Y", _dataAccessFacade.GetGeneralSettings().GetDefaultMillisecondsThreshold(), 2, "Downside"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } }
public async void StopRecording() { foreach (var personPair in CheckPerson.Instance.PersonsId) { try { _dataAccessFacade.GetIntervalAccess().FromEvent(personPair.Value, "Proxemic", "Events", _dataAccessFacade.GetGeneralSettings().GetDefaultMillisecondsThreshold(), 0, "Intimate"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } try { _dataAccessFacade.GetIntervalAccess().FromEvent(personPair.Value, "Proxemic", "Events", _dataAccessFacade.GetGeneralSettings().GetDefaultMillisecondsThreshold(), 1, "Personal"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } try { _dataAccessFacade.GetIntervalAccess().FromEvent(personPair.Value, "Proxemic", "Events", _dataAccessFacade.GetGeneralSettings().GetDefaultMillisecondsThreshold(), 2, "Social"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } try { _dataAccessFacade.GetIntervalAccess().FromEvent(personPair.Value, "Proxemic", "Events", _dataAccessFacade.GetGeneralSettings().GetDefaultMillisecondsThreshold(), 3, "Public"); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } }