コード例 #1
0
 public static MainInterface getInstance()
 {
     if (__instance == null)
     {
         __instance = new MainInterface();
     }
     return(__instance);
 }
コード例 #2
0
        /// <summary>
        /// Permet d'utiliser le squelette et afficher les vetements
        /// </summary>
        /// <param name="e">Instance vers l'appellant</param>
        public void useSkeleton(MainInterface e)
        {
            this.sensor.SkeletonStream.Enable();
            this.sensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady);
            this.skeletonCollection.Clear();

            this.sensor.DepthStream.Range = DepthRange.Default;
            this.caller = e;
            sensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady);
        }
コード例 #3
0
        /// <summary>
        /// Permet d'utiliser le squelette et afficher les vetements
        /// </summary>
        /// <param name="e">Instance vers l'appellant</param>
        public void useSkeleton(MainInterface e)
        {
            this.sensor.SkeletonStream.Enable();
            this.sensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady);
            this.skeletonCollection.Clear();

            this.sensor.DepthStream.Range = DepthRange.Default;
            this.caller = e;
            sensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(kinect_SkeletonFrameReady);
        }
コード例 #4
0
        /// <summary>
        /// Enable color stream and attach him a target
        /// </summary>
        /// <param name="m">Caller class</param>
        public void useColorStream(MainInterface m)
        {
            this.caller = m;
            this.sensor.ColorStream.Disable();
            if (!this.sensor.ColorStream.IsEnabled)
            {
                this.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution1280x960Fps12);

                this.sensor.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(sensor_ColorFrameReady);
            }
        }
コード例 #5
0
        /// <summary>
        /// Enable color stream and attach him a target
        /// </summary>
        /// <param name="m">Caller class</param>
        public void useColorStream(MainInterface m)
        {
            this.caller = m;
            this.sensor.ColorStream.Disable();
            if (!this.sensor.ColorStream.IsEnabled)
            {
                this.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution1280x960Fps12);


                this.sensor.ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(sensor_ColorFrameReady);
            }
        }
コード例 #6
0
ファイル: Habits.cs プロジェクト: kandran/musee-interactif
        /*  Ancien systeme de selection des vetements (en dur)
        *
        * public static System.Windows.Media.ImageSource getVetementImg(int id)
        {
            BitmapImage bi3 = new BitmapImage();
            bi3.BeginInit();
            switch (id)
            {
                case 1:
                    bi3.UriSource = new Uri("/JagoanFisika;component/Resources/Manteau.png", UriKind.RelativeOrAbsolute);
                    break;
                case 2:
                    bi3.UriSource = new Uri("/JagoanFisika;component/Resources/Robe.png", UriKind.RelativeOrAbsolute);
                    break;
                default:
                    bi3.UriSource = new Uri("/JagoanFisika;component/Resources/Robe.png", UriKind.RelativeOrAbsolute);
                    break;

            }

            bi3.EndInit();
            return bi3;
        }*/
        /// <summary>
        /// Lie les vetements avec le squelette
        /// </summary>
        /// <param name="skeleton">Skelette</param>
        /// <param name="fenetre">Instance vers la classe d'affichage de notre application</param>
        /// <param name="sensor">Entree vers les capteurs de la kinect</param>
        public static void MapJointsWithUIElement(Skeleton skeleton, GestionSensors sensor, MainInterface fenetre)
        {
            // Get the Points in 2D Space to map in UI. for that call the Scale postion method.
            Point mappedPoint = sensor.ScalePosition(skeleton.Joints[JointType.ShoulderCenter].Position);
            Point mappedPoint2 = sensor.ScalePosition(skeleton.Joints[JointType.Head].Position);

            //largeur des epaules
            double largeur = Math.Sqrt(Math.Pow(Math.Abs(sensor.ScalePosition(skeleton.Joints[JointType.ShoulderRight].Position).X - sensor.ScalePosition(skeleton.Joints[JointType.ShoulderLeft].Position).X), 2) + Math.Pow(Math.Abs(sensor.ScalePosition(skeleton.Joints[JointType.ShoulderRight].Position).Y - sensor.ScalePosition(skeleton.Joints[JointType.ShoulderLeft].Position).Y), 2));

            //Vetements
            Image vetement = fenetre.Vetements.Children[0] as Image;
            Image vetementHead = fenetre.Chapeaux.Children[0] as Image;

            //adaptation de la largeur
            if (largeur > 0)
                vetement.Width = largeur * 1.25;
            //  Vetements.Width= largeur;

            //hauteur
            double hauteur = (sensor.ScalePosition(skeleton.Joints[JointType.AnkleLeft].Position).Y - sensor.ScalePosition(skeleton.Joints[JointType.ShoulderCenter].Position).Y)/1.25;

            //adaptation de la hauteur
            if (hauteur > 0)
                vetement.Height = hauteur * 1.25;

            //largeur tete = 1/12 * taille corps
            /*
            double largeurChapeau = sensor.ScalePosition(skeleton.Joints[JointType.Head].Position).Y - sensor.ScalePosition(skeleton.Joints[JointType.FootLeft].Position).Y *  (1 / 6);
            if (largeurChapeau > 0)
                vetementHead.Width = largeurChapeau;*/
            //Fixe les vetements
            vetement.Stretch = Stretch.Fill;
            vetement.Source = fenetre.VetementSelectionne;

            //Fixe les chapeaux
            vetementHead.Stretch = Stretch.Fill;
            vetementHead.Source = fenetre.ChapeauSelectionne;

            //Fixes les elements visuels sur notre canvas
            Canvas.SetLeft(fenetre.Vetements, mappedPoint.X - (fenetre.Vetements.ActualWidth * 0.4));
            Canvas.SetTop(fenetre.Vetements, mappedPoint.Y);

            Canvas.SetLeft(fenetre.Chapeaux, mappedPoint.X - largeur/5);
            Canvas.SetTop(fenetre.Chapeaux, mappedPoint.Y - hauteur/2.3 );
        }
コード例 #7
0
        /// <summary>
        /// Use depth for an img
        /// </summary>
        /// <param name="e">Caller object</param>
        public void useDepth(MainInterface e)
        {
            this.sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
            this.depthWidth = this.sensor.DepthStream.FrameWidth;
            this.depthHeight = this.sensor.DepthStream.FrameHeight;
            int colorWidth = this.sensor.ColorStream.FrameWidth;
            int colorHeight = this.sensor.ColorStream.FrameHeight;
            this.colorToDepthDivisor = colorWidth / this.depthWidth;

            sensor.SkeletonStream.Enable();

            this.colorCoordinates = new ColorImagePoint[this.sensor.DepthStream.FramePixelDataLength];
            this.depthPixels = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength];
            this.playerPixelData = new int[this.sensor.DepthStream.FramePixelDataLength];
            this.colorBitmap = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
            this.caller.colorimageControl2.Source = this.colorBitmap;

            this.caller = e;
            sensor.DepthFrameReady += new EventHandler<DepthImageFrameReadyEventArgs>(sensor_DepthFrameReady);
        }
コード例 #8
0
        /// <summary>
        /// Use depth for an img
        /// </summary>
        /// <param name="e">Caller object</param>
        public void useDepth(MainInterface e)
        {
            this.sensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
            this.depthWidth  = this.sensor.DepthStream.FrameWidth;
            this.depthHeight = this.sensor.DepthStream.FrameHeight;
            int colorWidth  = this.sensor.ColorStream.FrameWidth;
            int colorHeight = this.sensor.ColorStream.FrameHeight;

            this.colorToDepthDivisor = colorWidth / this.depthWidth;

            sensor.SkeletonStream.Enable();

            this.colorCoordinates = new ColorImagePoint[this.sensor.DepthStream.FramePixelDataLength];
            this.depthPixels      = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength];
            this.playerPixelData  = new int[this.sensor.DepthStream.FramePixelDataLength];
            this.colorBitmap      = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
            this.caller.colorimageControl2.Source = this.colorBitmap;


            this.caller             = e;
            sensor.DepthFrameReady += new EventHandler <DepthImageFrameReadyEventArgs>(sensor_DepthFrameReady);
        }
コード例 #9
0
 public static MainInterface getInstance()
 {
     if (__instance == null)
         __instance = new MainInterface();
     return __instance;
 }
コード例 #10
0
        /*  Ancien systeme de selection des vetements (en dur)
         *
         * public static System.Windows.Media.ImageSource getVetementImg(int id)
         * {
         *   BitmapImage bi3 = new BitmapImage();
         *   bi3.BeginInit();
         *   switch (id)
         *   {
         *       case 1:
         *           bi3.UriSource = new Uri("/JagoanFisika;component/Resources/Manteau.png", UriKind.RelativeOrAbsolute);
         *           break;
         *       case 2:
         *           bi3.UriSource = new Uri("/JagoanFisika;component/Resources/Robe.png", UriKind.RelativeOrAbsolute);
         *           break;
         *       default:
         *           bi3.UriSource = new Uri("/JagoanFisika;component/Resources/Robe.png", UriKind.RelativeOrAbsolute);
         *           break;
         *
         *   }
         *
         *   bi3.EndInit();
         *   return bi3;
         * }*/



        /// <summary>
        /// Lie les vetements avec le squelette
        /// </summary>
        /// <param name="skeleton">Skelette</param>
        /// <param name="fenetre">Instance vers la classe d'affichage de notre application</param>
        /// <param name="sensor">Entree vers les capteurs de la kinect</param>
        public static void MapJointsWithUIElement(Skeleton skeleton, GestionSensors sensor, MainInterface fenetre)
        {
            // Get the Points in 2D Space to map in UI. for that call the Scale postion method.
            Point mappedPoint  = sensor.ScalePosition(skeleton.Joints[JointType.ShoulderCenter].Position);
            Point mappedPoint2 = sensor.ScalePosition(skeleton.Joints[JointType.Head].Position);

            //largeur des epaules
            double largeur = Math.Sqrt(Math.Pow(Math.Abs(sensor.ScalePosition(skeleton.Joints[JointType.ShoulderRight].Position).X - sensor.ScalePosition(skeleton.Joints[JointType.ShoulderLeft].Position).X), 2) + Math.Pow(Math.Abs(sensor.ScalePosition(skeleton.Joints[JointType.ShoulderRight].Position).Y - sensor.ScalePosition(skeleton.Joints[JointType.ShoulderLeft].Position).Y), 2));

            //Vetements
            Image vetement     = fenetre.Vetements.Children[0] as Image;
            Image vetementHead = fenetre.Chapeaux.Children[0] as Image;

            //adaptation de la largeur
            if (largeur > 0)
            {
                vetement.Width = largeur * 1.25;
            }
            //  Vetements.Width= largeur;

            //hauteur
            double hauteur = (sensor.ScalePosition(skeleton.Joints[JointType.AnkleLeft].Position).Y - sensor.ScalePosition(skeleton.Joints[JointType.ShoulderCenter].Position).Y) / 1.25;

            //adaptation de la hauteur
            if (hauteur > 0)
            {
                vetement.Height = hauteur * 1.25;
            }

            //largeur tete = 1/12 * taille corps

            /*
             * double largeurChapeau = sensor.ScalePosition(skeleton.Joints[JointType.Head].Position).Y - sensor.ScalePosition(skeleton.Joints[JointType.FootLeft].Position).Y *  (1 / 6);
             * if (largeurChapeau > 0)
             *  vetementHead.Width = largeurChapeau;*/
            //Fixe les vetements
            vetement.Stretch = Stretch.Fill;
            vetement.Source  = fenetre.VetementSelectionne;

            //Fixe les chapeaux
            vetementHead.Stretch = Stretch.Fill;
            vetementHead.Source  = fenetre.ChapeauSelectionne;



            //Fixes les elements visuels sur notre canvas
            Canvas.SetLeft(fenetre.Vetements, mappedPoint.X - (fenetre.Vetements.ActualWidth * 0.4));
            Canvas.SetTop(fenetre.Vetements, mappedPoint.Y);

            Canvas.SetLeft(fenetre.Chapeaux, mappedPoint.X - largeur / 5);
            Canvas.SetTop(fenetre.Chapeaux, mappedPoint.Y - hauteur / 2.3);
        }
コード例 #11
0
 /// <summary>
 /// Clic sur le bouton demarrer, on lance l'interface principale
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Demarrer_Click(object sender, RoutedEventArgs e)
 {
     Switcher.Switch(MainInterface.getInstance());
 }