/// <summary> /// Méthode qui permet d'initialiser tout ce qui concerne kinect /// </summary> private void initKinect() { //La Kinect actuellement raccordée au PC KinectSensor kinectSensor = KinectSensor.GetDefault(); //Commence la lecture des mouvements------------------------------- //Création de la détection des bodies this.bodyReader = kinectSensor.BodyFrameSource.OpenReader(); this.bodyReader.FrameArrived += BodyReader_FrameArrived; //Tableau contenant les corps détectés this.bodies = new Body[bodyReader.BodyFrameSource.BodyCount]; //Tableau contenant les détecteurs de mouvements associés this.bodiesDetectors = new GestureDetector[this.bodies.Count]; //Crée les détecteurs de mouvement correspondants for (int i = 0; i < bodies.Count; i++) { GestureDetector handler = new GestureDetector(this.originalPath + "\\SwitchKinect.gbd"); //On récupère le fichier contenant les mouvements à partir de l'emplacement original handler.GestureFirstDetected += handler_GestureFirstDetected; //Pour chaques corps détectable, on crée un détecteur this.bodiesDetectors[i] = handler; } //---------------- //Détection de la position des mains KinectCoreWindow.GetForCurrentThread().PointerMoved += KinectPowerPoint_PointerMoved; }
/// <summary> /// Initialization code /// </summary> /// <param name="sender">the page</param> /// <param name="e">the loaded event args</param> void KinectPointerPointSample_Loaded(object sender, RoutedEventArgs e) { // Listen to Kinect pointer events KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved; }
void MainPage_Loaded(object sender, RoutedEventArgs e) { //Kinect Handling for drawing - auto using of default kinect sensor KinectCoreWindow kinectCore = KinectCoreWindow.GetForCurrentThread(); kinectCore.PointerMoved += kinectCore_PointerMoved; //Capture les corps pour les états des mains KinectSensor sensor = KinectSensor.GetDefault(); BodyFrameReader bodyReader = sensor.BodyFrameSource.OpenReader(); bodyReader.FrameArrived += bodyReader_FrameArrived; ///Timer qui permet de faire tourner bodyReader en continu. Workaround DispatcherTimer t = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(33) }; t.Tick += (senderTick, args) => { bodyReader.IsPaused = false; Debug.WriteLine(DateTime.Now + " - Setting Paused false --------------------------------------------------"); }; t.Start(); }
void AddEventHandlers() { // NB: these are POINTER events, not MOUSE events, not PEN events, etc. this.drawCanvas.PointerPressed += (s, e) => { this.TrackDown( e.Pointer.PointerId, e.Pointer.PointerDeviceType.ToString(), e.GetCurrentPoint(this.drawCanvas).Position); }; this.drawCanvas.PointerReleased += (s, e) => { this.TrackUp(e.Pointer.PointerId); }; this.drawCanvas.PointerMoved += (s, e) => { this.TrackMove( e.Pointer.PointerId, e.GetCurrentPoint(this.drawCanvas).Position, ((int)e.Pointer.PointerDeviceType + 1) * 3); }; this.drawCanvas.PointerExited += (s, e) => { this.TrackUp(e.Pointer.PointerId); }; var window = KinectCoreWindow.GetForCurrentThread(); window.PointerMoved += (s, e) => { if (this.drawCanvas.IsGripping) { var canvasPosition = new Point() { X = e.CurrentPoint.Position.X * this.drawCanvas.ActualWidth, Y = e.CurrentPoint.Position.Y * this.drawCanvas.ActualHeight }; this.TrackDown( e.CurrentPoint.PointerId, e.CurrentPoint.PointerDevice.PointerDeviceType.ToString(), canvasPosition); this.TrackMove( e.CurrentPoint.PointerId, canvasPosition, ((int)e.CurrentPoint.PointerDevice.PointerDeviceType) * 3); } else { this.TrackUp(e.CurrentPoint.PointerId); } }; window.PointerExited += (s, e) => { this.TrackUp(e.CurrentPoint.PointerId); }; }
public MainWindow() { var settings = new CefSettings(); settings.CefCommandLineArgs.Add("disable-gpu", "1"); Cef.Initialize(settings); InitializeComponent(); this.PreviewKeyDown += new KeyEventHandler(HandleEsc); sensor = KinectSensor.GetDefault(); //Mouse.OverrideCursor = Cursors.None; if (sensor != null) { sensor.Open(); reader = sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body); reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived; //Initialize gestureController gestureController = new GestureController(); gestureController.Start(); gestureController.GestureRecognized += gestureController_GestureRecognized; //Initialize spyGlassController mouseController = new MouseController((int)SystemParameters.PrimaryScreenWidth / 2, (int)SystemParameters.PrimaryScreenHeight / 2); //961,600 for Display / 829,586 for local testing playersController = new PlayersController(); playersController.BodyEntered += UserReporter_BodyEntered; playersController.BodyLeft += UserReporter_BodyLeft; playersController.Start(); KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved; string folder = System.IO.Directory.GetCurrentDirectory().ToString(); for (int i = 0; i < folder.Length; i++) { if (folder[i] == '\\') { base_folder += '\\'; base_folder += '\\'; } else { base_folder += folder[i]; } } base_folder += "\\Images"; Console.WriteLine(base_folder); } }
internal HandInScreenEngagementModel(int engagedPeopleAllowed, InputPointerManager inputPointerManager) { this.EngagedPeopleAllowed = engagedPeopleAllowed; this.inputPointerManager = inputPointerManager; var kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += this.kinectCoreWindow_PointerMoved; this.handsToEngage = new List <BodyHandPair>(); this.pointerPoints = new List <KinectPointerPoint>(); }
/// <summary> /// Uninitialization code /// </summary> /// <param name="sender">the page</param> /// <param name="e">the unloaded event args</param> private void KinectPointerPointSample_Unloaded(object sender, RoutedEventArgs e) { // Unsubscribe from mouse/pen/touch pointer events var coreWindow = CoreWindow.GetForCurrentThread(); coreWindow.PointerMoved -= coreWindow_PointerMoved; // Unsubscribe from Kinect pointer events var kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved -= kinectCoreWindow_PointerMoved; }
/// <summary> /// Evénement déclenché lorsque la page a été chargée /// </summary> /// <param name="sender">L'objet déclenchant</param> /// <param name="e">Les arguments de l'événement</param> void MainPage_Loaded(object sender, RoutedEventArgs e) { //Récupération des objets Kinect nécessaires au programme this.kinect = KinectSensor.GetDefault(); this.kinectCore = KinectCoreWindow.GetForCurrentThread(); //On traite les évévenements permettant de faire bouger le curseur this.kinectCore.PointerMoved += kinectCore_PointerMoved; //On ouvre Kinect (Kinect s'allume) this.kinect.Open(); }
/// <summary> /// Execute start up tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void MainWindow_Loaded(object sender, RoutedEventArgs e) { // Listen to kinect pointer events KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved; // Listen to body frames arrival if (this.bodyFrameReader != null) { this.bodyFrameReader.FrameArrived += this.Reader_FrameArrived; } }
private void Grid_Loaded(object sender, RoutedEventArgs e) { if (sensor != null) { sensor.Open(); } reader.MultiSourceFrameArrived += reader_MultiSourceFrameArrived; var kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += this.kinectCoreWindow_PointerMoved; }
/// <summary> /// Initialise tout ce qui est relatif à Kinect /// </summary> private void InitializeKinect() { //Récupère le détecteur kinect et l'ouvre KinectSensor kinect = KinectSensor.GetDefault(); kinect.Open(); //Pointeur kinect this.kinectCore = KinectCoreWindow.GetForCurrentThread(); kinectCore.PointerMoved += MainWindow_PointerMoved; //Détection des corps kinect.BodyFrameSource.OpenReader().FrameArrived += BodyReader_BodyFrameArrived; }
void MainPage_Loaded(object sender, RoutedEventArgs e) { drawBrush = whiteBrush; //Création de kinect this.kinect = KinectSensor.GetDefault(); this.kinectCore = KinectCoreWindow.GetForCurrentThread(); kinectCore.PointerEntered += kinectCore_PointerEntered; kinectCore.PointerMoved += kinectCore_PointerMoved; this.kinect.Open(); }
/// <summary> /// Initializes the kinect sensor /// </summary> private static void InitilizeKinect() { kinectSensor = KinectSensor.GetDefault(); bodyFrameReader = kinectSensor.BodyFrameSource.OpenReader(); bodyFrameReader.FrameArrived += Reader_FrameArrived; KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += KinectCoreWindow_PointerMoved; kinectSensor.Open(); #if DEBUG time.Start(); #endif }
/// <summary> /// Inicializa los parametros de la Ventana que contiene el canvas de imagenes y se definen los valores para el cursor y la deteccion de posicion del mismo respecto a la ventana. /// </summary> private void IniciatizeControls() { InitializeComponent(); WindowState = WindowState.Maximized; WindowStyle = WindowStyle.None; ventana.Background = Brushes.Black; ventana.Height = System.Windows.SystemParameters.PrimaryScreenHeight; ventana.Width = System.Windows.SystemParameters.PrimaryScreenWidth; HeightScreen = (int)ventana.Height; WidthScreen = (int)ventana.Width; imgHandLeft = new Image(); imgHandLeft.Source = new BitmapImage(Utilities.LoadUriFromResource("Cursores/manoLeft.png")); imgHandLeft.Width = 32; imgHandLeft.Height = 32; imgHandRight = new Image(); imgHandRight.Source = new BitmapImage(Utilities.LoadUriFromResource("Cursores/manoRight.png")); imgHandRight.Width = 32; imgHandRight.Height = 32; mainScreen.Children.Add(imgHandLeft); mainScreen.Children.Add(imgHandRight); sensor = KinectSensor.GetDefault(); sensor.Open(); sensor.IsAvailableChanged += AvailableChanged; this.coordinateMapper = sensor.CoordinateMapper; //para detectar si se fue el id trackeado reader = sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Body | FrameSourceTypes.BodyIndex | FrameSourceTypes.Color | FrameSourceTypes.Depth); reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived; //se llama cuando se mueven las manos de un body trackeado KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved; //vista360.Children.Clear(); //Limpia por completo el canvas que contiene las imagenes }
/// <summary> /// Initialization code /// </summary> /// <param name="sender">the page</param> /// <param name="e">the loaded event args</param> private void KinectPointerPointSample_Loaded(object sender, RoutedEventArgs e) { // Listen to mouse/pen/touch pointer events var coreWindow = CoreWindow.GetForCurrentThread(); coreWindow.PointerMoved += coreWindow_PointerMoved; // Listen to Kinect pointer events KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved; // Initialize brushes blackBrush = new SolidColorBrush(ColorHelper.FromArgb(128, 0, 0, 0)); yellowBrush = new SolidColorBrush(ColorHelper.FromArgb(255, 245, 255, 000)); greenBrush = new SolidColorBrush(ColorHelper.FromArgb(255, 0, 255, 0)); // Default to showing Kinect pointer inof this.kinect.IsChecked = true; // show Kinect data initially, not mouse/touch. }
private void IniciatizeControls() { InitializeComponent(); WindowState = WindowState.Maximized; WindowStyle = WindowStyle.None; mainWindow.Height = System.Windows.SystemParameters.PrimaryScreenHeight; mainWindow.Width = System.Windows.SystemParameters.PrimaryScreenWidth; imgHandLeft = new Image(); imgHandLeft.Source = new BitmapImage(Utilities.LoadUriFromResource("Cursores/manoLeft.png")); imgHandLeft.Width = 32; imgHandLeft.Height = 32; imgHandRight = new Image(); imgHandRight.Source = new BitmapImage(Utilities.LoadUriFromResource("Cursores/manoRight.png")); imgHandRight.Width = 32; imgHandRight.Height = 32; mainScreen.Children.Add(imgHandLeft); mainScreen.Children.Add(imgHandRight); IsSidePage = SectionsPages.OUT; PageActual = 1; PagesActives = new BitmapImage[2]; FirstExecution = true; sensor = KinectSensor.GetDefault(); sensor.Open(); this.coordinateMapper = sensor.CoordinateMapper; //se llama cuando se mueven las manos de un body trackeado KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved; reader = sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Body | FrameSourceTypes.BodyIndex | FrameSourceTypes.Color | FrameSourceTypes.Depth); reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived; }
private void initGesture() { KinectSensor kinectSensor = KinectSensor.GetDefault(); this.gestureSource = new VisualGestureBuilderFrameSource(kinectSensor, 0); //Commence la lecture des mouvements------------------------------ //Création de la base de donnée des mouvements et ajout des mouvements à la source des mouvements this.gestures = new VisualGestureBuilderDatabase("SwitchKinect.gbd"); this.gestureSource.AddGestures(gestures.AvailableGestures); //TODO déploiement automatique du dll AdaBoostTech.dll (détection de mouvement), utiliser DLLImport ? //Création de la détection des bodies this.bodyReader = kinectSensor.BodyFrameSource.OpenReader(); this.bodyReader.FrameArrived += BodyReader_FrameArrived; //Tableau contenant les corps détectés this.bodies = new Body[bodyReader.BodyFrameSource.BodyCount]; //Tableau contenant les détecteurs de mouvements associés this.bodiesDetectors = new GestureDetector[this.bodies.Count]; //Crée les détecteurs de mouvement correspondants for (int i = 0; i < bodies.Count; i++) { GestureDetector handler = new GestureDetector("SwitchKinect.gbd"); handler.GestureFirstDetected += handler_GestureFirstDetected; //Pour chaques corps détectable, on crée un détecteur this.bodiesDetectors[i] = handler; } //---------------- //Détection de la position des mains KinectCoreWindow.GetForCurrentThread().PointerMoved += ThisAddIn_PointerMoved; }
void MainPage_Loaded(object sender, RoutedEventArgs e) { drawBrush = blueBrush; //Création de kinect this.kinect = KinectSensor.GetDefault(); this.kinectCore = KinectCoreWindow.GetForCurrentThread(); kinectCore.PointerEntered += kinectCore_PointerEntered; kinectCore.PointerMoved += kinectCore_PointerMoved; this.kinect.Open(); //Bouton de couleur this.btnColorChoice.Background = drawBrush; this.btnColorChoice.Width = this.btnColorChoice.ActualHeight; byte[] bytColor = BitConverter.GetBytes(0xFFFFEE); Debug.WriteLine(bytColor[2]); //SocketIO ---- TEST pour joé #region connectJoe socketIO = IO.Socket("http://127.0.0.1:1337"); socketIO.On(Socket.EVENT_CONNECT, () => { Debug.WriteLine("Connected to NodeJS Server"); socketIO.On("srvCanvasClick", (data) => { Debug.WriteLine(data); }); }); #endregion }
public windowTemplate() { InitializeComponent(); if (Extensions.fondoTemplate == null) { Extensions.fondoTemplate = new ImageBrush(Extensions.LoadBitmapFromResource("Fondos/1.jpg")); } if (Extensions.iconoTemplate == null) { Extensions.iconoTemplate = Extensions.LoadBitmapFromResource("Iconos/hojas.png"); } altoLogo = Extensions.iconoTemplate.PixelHeight / 2; anchoLogo = Extensions.iconoTemplate.PixelWidth / 2; WindowState = WindowState.Maximized; WindowStyle = WindowStyle.None; sensor = KinectSensor.GetDefault(); sensor.Open(); sensor.IsAvailableChanged += AvailableChanged; mainWindow.Height = System.Windows.SystemParameters.PrimaryScreenHeight; mainWindow.Width = System.Windows.SystemParameters.PrimaryScreenWidth; //para detectar si se fue el id trackeado reader = sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Body | FrameSourceTypes.BodyIndex | FrameSourceTypes.Color | FrameSourceTypes.Depth); reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived; //se llama cuando se mueven las manos de un body trackeado KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved; iconos = new Image[cantidadIconos]; manoIcoPointer = new Image[2]; vientoActivado = new Boolean[2]; timeMano = new double[2]; posInicialMano = new Point[2]; //this.Background = new ImageBrush(Extensions.LoadBitmapFromResource("fondo.jpg")); this.Background = Extensions.fondoTemplate; anchoRes = mainWindow.Width; altoRes = mainWindow.Height; if (cantidadIconos <= 200) { cuadColum = 2; cuadFila = 2; } //BitmapImage bmp = Extensions.LoadBitmapFromResource("firefox.png"); BitmapImage bmp = Extensions.iconoTemplate; int cant = 0; Random randomX; Random randomY; int columnaDesde = 0; int columnaHasta = cuadColum; int filaDesde = 0; int filaHasta = cuadFila; double anchoCuadricula = anchoRes / columnaHasta; double altoCuadricula = altoRes / filaHasta; int timestamp = Int32.Parse(DateTime.UtcNow.ToString("ffff", CultureInfo.InvariantCulture)); randomX = new Random(timestamp); randomY = new Random(timestamp * 2); Random zIndexRand = new Random(timestamp * 3); int cantXCuadrado = (int)(cantidadIconos / (cuadColum * cuadFila)); //texto.Content = cantXCuadrado; for (int i = columnaDesde; i < columnaHasta; i++) { for (int j = filaDesde; j < filaHasta; j++) { for (int k = 0; k < cantXCuadrado; k++) { int intRandX = randomX.Next((int)anchoCuadricula); int x = intRandX - (int)(anchoCuadricula / 2); int y = randomY.Next((int)altoCuadricula) - (int)(altoCuadricula / 2); Image imagen = new Image(); imagen.Source = bmp; imagen.Width = anchoLogo; imagen.Height = altoLogo; //imagen.Margin = new Thickness(i * anchoCuadricula + (anchoCuadricula/2) + x, j * altoCuadricula + (altoCuadricula/2) + y, 0, 0); Canvas.SetLeft(imagen, i * anchoCuadricula + (anchoCuadricula / 2) + x); Canvas.SetTop(imagen, j * altoCuadricula + (altoCuadricula / 2) + y); iconos[cant] = imagen; cant++; ventanaIco.Children.Add(imagen); Grid.SetZIndex(imagen, zIndexRand.Next(cantidadIconos)); } } } BitmapImage manoLeftBmp = Extensions.LoadBitmapFromResource("Cursores/manoLeft.png"); BitmapImage manoRightBmp = Extensions.LoadBitmapFromResource("Cursores/manoRight.png"); manoLeft = new Image(); manoLeft.Source = manoLeftBmp; manoLeft.Width = 32; manoLeft.Height = 32; manoRight = new Image(); manoRight.Source = manoRightBmp; manoRight.Width = 32; manoRight.Height = 32; mainScreen.Children.Add(manoLeft); mainScreen.Children.Add(manoRight); Grid.SetZIndex(mainScreen, 1000000); //Grid.SetZIndex(texto, 10); //Grid.SetZIndex(texto, 2000000); //Grid.SetZIndex(circle, 2000000); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindow"/> class. /// </summary> public MainWindow() { this.InitializeComponent(); navService = NavigationService.GetNavigationService(this); staticNavService = navService; KinectRegion.SetKinectRegion(this, kinectRegion); App app = ((App)Application.Current); app.KinectRegion = kinectRegion; // Use the default sensor this.kinectRegion.KinectSensor = KinectSensor.GetDefault(); this.kinectSensor = KinectSensor.GetDefault(); //// open the reader for the color frames this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader(); // wire handler for frame arrival this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived; // create the colorFrameDescription from the ColorFrameSource using Bgra format FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra); // create the bitmap to display this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); // open the sensor this.kinectSensor.Open(); //// Add in display content var mainGridDataSource = DataSource.GetGroup("Group-1"); itemsControl.ItemsSource = mainGridDataSource; //Starts timer for clock SetClockTimer(); //Set bongo timers SetBongoGetTimer(); SetSwapTimer(); //Sets the scrolling bottom bar text event StartBottomBar(); //Sets timers and weather data SetWeatherTimer(); SetCSEventsTimer(); GetInitalApiData(); GetSlides(); SetSlideSwapTimer(); var window = KinectCoreWindow.GetForCurrentThread(); window.PointerEntered += OnKinectPointerEntered; window.PointerExited += OnKinectPointerExited; SetPageTimer(); }
public DrawingWindow() { this.kinectSensor = KinectSensor.GetDefault(); this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader(); this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived; // create the colorFrameDescription from the ColorFrameSource using Bgra format FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra); this.coordinateMapper = this.kinectSensor.CoordinateMapper; this.displayWidth = colorFrameDescription.Width; this.displayHeight = colorFrameDescription.Height; // create the bitmap to display this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); bodyFrameReader.FrameArrived += Reader_BodyFrameArrived; this.bodyCount = this.kinectSensor.BodyFrameSource.BodyCount; this.bodies = new Body[this.bodyCount]; //this.faceFrameSources = new FaceFrameSource[this.bodyCount]; //this.faceFrameReaders = new FaceFrameReader[this.bodyCount]; FaceFrameFeatures faceFrameFeatures = FaceFrameFeatures.BoundingBoxInColorSpace | FaceFrameFeatures.PointsInColorSpace | FaceFrameFeatures.RotationOrientation | FaceFrameFeatures.FaceEngagement | FaceFrameFeatures.Glasses | FaceFrameFeatures.Happy | FaceFrameFeatures.LeftEyeClosed | FaceFrameFeatures.RightEyeClosed | FaceFrameFeatures.LookingAway | FaceFrameFeatures.MouthMoved | FaceFrameFeatures.MouthOpen; this.faceFrameSources = new FaceFrameSource[this.bodyCount]; this.faceFrameReaders = new FaceFrameReader[this.bodyCount]; for (int i = 0; i < this.bodyCount; i++) { // create the face frame source with the required face frame features and an initial tracking Id of 0 this.faceFrameSources[i] = new FaceFrameSource(this.kinectSensor, 0, faceFrameFeatures); // open the corresponding reader this.faceFrameReaders[i] = this.faceFrameSources[i].OpenReader(); } // allocate storage to store face frame results for each face in the FOV this.faceFrameResults = new FaceFrameResult[this.bodyCount]; this.previousResults = new FaceFrameResult[this.bodyCount]; //this.Cursor = Cursors.None; this.kinectSensor.Open(); KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += drawArea_PointerMove; // use the window object as the view model in this simple example this.DataContext = this; // KinectRegion.SetKinectRegion(this, kinectRegion); engagement = new EngagementManager(kinectSensor); // App app = ((App)Application.Current); // app.KinectRegion = kinectRegion; this.engagement = new EngagementManager(kinectSensor); InitializeComponent(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { KinectCoreWindow kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved; }
/// <summary> /// Invoqué lorsque l'application est lancée normalement par l'utilisateur final. D'autres points d'entrée /// seront utilisés par exemple au moment du lancement de l'application pour l'ouverture d'un fichier spécifique. /// </summary> /// <param name="e">Détails concernant la requête et le processus de lancement.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Ne répétez pas l'initialisation de l'application lorsque la fenêtre comporte déjà du contenu, // assurez-vous juste que la fenêtre est active if (rootFrame == null) { // Créez un Frame utilisable comme contexte de navigation et naviguez jusqu'à la première page rootFrame = new Frame(); // Définir la page par défaut rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: chargez l'état de l'application précédemment suspendue } // Placez le frame dans la fenêtre active Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // Quand la pile de navigation n'est pas restaurée, accédez à la première page, // puis configurez la nouvelle page en transmettant les informations requises en tant que // paramètre rootFrame.Navigate(typeof(MainPage), e.Arguments); } //Ajout de l'intégration kinect----------- #region kinectImplementation // KinectSensor.GetDefault().Open(); //Ajout de la région kinect kinectRegion = new KinectRegion(); //Création de la région kinect cliquable à la main kinectRegion.Content = rootFrame; //La région kinect contient toute les pages principales de l'application => On peut utiliser kinect sur toute les pages par défaut //Ajout d'une grille pour le viewer et la région kinect Grid mainGrid = new Grid(); mainGrid.Children.Add(kinectRegion); Window.Current.Content = mainGrid; //La région kinect est la partie principale de la fenêtre //Ajout du kinectViewer pour pouvoir se voir KinectUserViewer kinectViewer = new KinectUserViewer() { Width = 150, Height = 130, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Right }; mainGrid.Children.Add(kinectViewer); //Ajout du kinectCore pour plus de fonctionnalité kinectCore = KinectCoreWindow.GetForCurrentThread(); #endregion // Vérifiez que la fenêtre actuelle est active Window.Current.Activate(); }