예제 #1
0
        public Gesture AddNewGesture()
        {
            if (!CanAddNewGesture)
            {
                return(null); //do not add a new gesture if any currently edited gesture doesn't contain enough data to be allowed to save
            }
            if (EditorVisible)
            {
                SaveGesture(); //CanAddNewGesture has already checked if CanSaveGesture when EditorVisible
            }
            // Clear the initial state store
            ExGesture = null;

            // Make the new gesture and name it properly
            Gesture g = MakeNewGesture();

            g.Name = GlblRes.NewGesture;
            while (GestureCollection.Where(x => x.Name.StartsWith(g.Name)).Count() > 0)
            {
                g.Name += " " + Convert.ToString(GestureCollection.Where(x => x.Name.StartsWith(g.Name)).Count() + 1);
            }

            // Add the new gesture to the Gesture Collection
            GestureCollection.Add(g);

            // Go
            TheWorkspace.DataContext = g;
            ShowEditor();

            return(g);
        }
예제 #2
0
 /// <summary>
 /// De-highlight frames on visualizer grids
 /// </summary>
 /// <param name="g">Gesture</param>
 private void DeHighlightFrames_Visualizer(Gesture g)
 {
     //Model3DGroup modelGroup_3D = (Model3DGroup)HotspotCellsModelVisual3D_Hit_Visualizer.Content; //this seems to be unused
     CollisionHighlights_3D.Children[GestureCollection.IndexOf(g)]    = new Model3DGroup(); //TODO: maybe there is a bug here and wanted to use modelGroup_3D instead?
     CollisionHighlights_Front.Children[GestureCollection.IndexOf(g)] = new Model3DGroup(); //TODO: maybe reuse the "new Model3DGroup()" instead of creating 3 of those?
     CollisionHighlights_Side.Children[GestureCollection.IndexOf(g)]  = new Model3DGroup();
 }
예제 #3
0
 public GestureCollectionEnumerator(GestureCollection collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
        private void DeHighlightFrames_Editor(Gesture g)
        {
            // De-highlight frame on grids
            Model3DGroup modelGroup_3D = (Model3DGroup)HotspotCellsModelVisual3D_Hit_Visualizer.Content;

            CollisionHighlights_3D.Children[GestureCollection.IndexOf(g)] = new Model3DGroup();
        }
예제 #5
0
 public GestureCollection(GestureCollection other) : this(EfficioRuntimePINVOKE.new_GestureCollection__SWIG_1(GestureCollection.getCPtr(other)), true)
 {
     if (EfficioRuntimePINVOKE.SWIGPendingException.Pending)
     {
         throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #6
0
        /// <summary>
        /// Highlight frames on visualizer grids
        /// </summary>
        /// <param name="g">Gesture</param>
        /// <param name="fs">Gesture Frames</param>
        private void HighlightFrames_Visualizer(Gesture g, List <GestureFrame> fs)
        {
            Model3DGroup modelGroup = GetHighlightModel3D(g, fs);

            CollisionHighlights_3D.Children[GestureCollection.IndexOf(g)]    = modelGroup;
            CollisionHighlights_Front.Children[GestureCollection.IndexOf(g)] = modelGroup;
            CollisionHighlights_Side.Children[GestureCollection.IndexOf(g)]  = modelGroup;
        }
예제 #7
0
 public void SetRange(int index, GestureCollection values)
 {
     EfficioRuntimePINVOKE.GestureCollection_SetRange(swigCPtr, index, GestureCollection.getCPtr(values));
     if (EfficioRuntimePINVOKE.SWIGPendingException.Pending)
     {
         throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve();
     }
 }
예제 #8
0
 public void DeleteGesture(Gesture g)
 {
     if (MessageBox.Show(string.Format(GlblRes.DeleteGestureFromCollectionConfirmation, g.Name),
                         GlblRes.DeleteGestureFromCollection, MessageBoxButton.YesNo)
         == MessageBoxResult.Yes)
     {
         GestureCollection.Remove(g);
     }
 }
예제 #9
0
    // Convert an XML representation back into a set of training data
    public void FromXML(string xml)
    {
        XmlSerializer deserializer = new XmlSerializer(typeof(GestureCollection));
        TextReader    tR           = new StringReader(xml);

        gc = (GestureCollection)deserializer.Deserialize(tR);
        tR.Close();

        // trigger training for this gesture with the new data
        Update();
    }
예제 #10
0
        public static GestureCollection Repeat(Gesture value, int count)
        {
            global::System.IntPtr cPtr = EfficioRuntimePINVOKE.GestureCollection_Repeat(Gesture.getCPtr(value), count);
            GestureCollection     ret  = (cPtr == global::System.IntPtr.Zero) ? null : new GestureCollection(cPtr, true);

            if (EfficioRuntimePINVOKE.SWIGPendingException.Pending)
            {
                throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #11
0
        public GestureCollection GetRange(int index, int count)
        {
            global::System.IntPtr cPtr = EfficioRuntimePINVOKE.GestureCollection_GetRange(swigCPtr, index, count);
            GestureCollection     ret  = (cPtr == global::System.IntPtr.Zero) ? null : new GestureCollection(cPtr, true);

            if (EfficioRuntimePINVOKE.SWIGPendingException.Pending)
            {
                throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #12
0
        private void AddNewFrameButton_Click(object sender, RoutedEventArgs e)
        {
            Gesture g = (Gesture)TheWorkspace.DataContext;

            // Add the frame to the Gesture object
            g.Frames.Add(MakeNewGestureFrame());
            // Extend CollisionTimes to keep track of collisions
            CollisionTimes[GestureCollection.IndexOf(g)].Add(new DateTime());
            // Select the newly added frame on the timeline
            FramesListBox.SelectedIndex = FramesListBox.Items.Count - 1;
            SyncEditorGrids();
        }
예제 #13
0
 public void CreateNewGestureCollection(object parameter)
 {
     if (MessageBox.Show("Do you really want to discard the current gesture collection and create a new one?",
                         "Create New Gesture Collection",
                         MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         while (GestureCollection.Count > 0)
         {
             GestureCollection.RemoveAt(0);
         }
     }
 }
예제 #14
0
        public void DeleteGestureButton_Click(object sender, RoutedEventArgs e)
        {
            Button  b = (Button)sender;
            Gesture g = (Gesture)b.DataContext;

            if (MessageBox.Show("Do you really want to delete the gesture \"" + g.Name + "\" from the collection?",
                                "Delete Gesture from Collection",
                                MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                GestureCollection.Remove(g);
            }
        }
예제 #15
0
        public void CreateNewGestureCollection()
        {
            if (MessageBox.Show(GlblRes.DiscardGestureCollectionConfirmation,
                                GlblRes.CreateNewGestureCollection, MessageBoxButton.YesNo)
                == MessageBoxResult.Yes)
            {
                GestureCollection.Clear();
            }

            if (GestureCollectionLoaded != null)
            {
                GestureCollectionLoaded(this, EventArgs.Empty);
            }
        }
예제 #16
0
        /// <summary>
        /// Undo changes done to gesture (or if it was a new one discard it)
        /// </summary>
        public void DiscardGesture()
        {
            Gesture g = (Gesture)TheWorkspace.DataContext;

            if (ExGesture == null)                                           // If the gesture is a new gesture...
            {
                GestureCollection.Remove(g);                                 //...remove it from the Gesture Collection
            }
            else                                                             // else if the gesture is an existing gesture being edited...
            {
                GestureCollection[GestureCollection.IndexOf(g)] = ExGesture; //...restore it to its initial state
            }
            CloseEditor();
        }
예제 #17
0
        public void AddNewFrame()
        {
            Gesture g = (Gesture)TheWorkspace.DataContext;

            if (g == null)
            {
                return;
            }

            g.Frames.Add(MakeNewGestureFrame());                              // Add the frame to the Gesture object
            CollisionTimes[GestureCollection.IndexOf(g)].Add(new DateTime()); // Extend CollisionTimes to keep track of collisions
            FramesListBox.SelectedIndex = FramesListBox.Items.Count - 1;      // Select the newly added frame on the timeline

            SyncEditorGrids();
        }
예제 #18
0
        private static void InterestsChanged(BindableObject bo, GestureCollection oldvalue, GestureCollection newvalue)
        {
            var view = bo as View;
            if (view == null)
                throw new InvalidBindableException(bo, typeof(View));

            var gcv = FindContentViewParent(view,false);
            if (gcv == null)
            {
                PendingInterestParameters.Add(new PendingInterestParams { View = view, Interests = newvalue });
                view.PropertyChanged += ViewPropertyChanged;

            }
            else
                gcv.RegisterInterests(view,newvalue);            
        }
예제 #19
0
        public void DiscardGesture(object parameter)
        {
            Gesture g = (Gesture)TheWorkspace.DataContext;

            // If the gesture is a new gesture, remove that m**********r from the Gesture Collection
            if (ExGesture == null)
            {
                GestureCollection.Remove(g);
            }
            // If the gesture is an existing gesture being edited, restore the m**********r to its initial state
            else
            {
                GestureCollection[GestureCollection.IndexOf(g)] = ExGesture;
            }
            // Go go go
            KillEditor();
        }
예제 #20
0
        public void AddNewGesture(object parameter)
        {
            // Clear the initial state store
            ExGesture = null;
            // Make the new gesture and name it properly
            Gesture g = MakeNewGesture();

            g.Name = "New Gesture";
            while (GestureCollection.Where(x => x.Name.StartsWith(g.Name)).Count() > 0)
            {
                g.Name += " " + Convert.ToString(GestureCollection.Where(x => x.Name.StartsWith(g.Name)).Count() + 1);
            }
            // Add the new gesture to the Gesture Collection
            GestureCollection.Add(g);
            // Go go go
            TheWorkspace.DataContext = g;
            LaunchEditor();
        }
예제 #21
0
        public void LoadGestureCollection(object parameter)
        {
            // Conjure file explorer
            OpenFileDialog openDialog = new OpenFileDialog();

            // F*****g around with file formats
            openDialog.Filter = "Hotspotizer Gesture files (*.hsjson)|*.hsjson";
            // Read and load if dialog returns OK
            if (openDialog.ShowDialog() == true)
            {
                string json = File.ReadAllText(openDialog.FileName);
                // DeserializeObject() does not appear to correctly deserialize Gesture objects
                // Below is a kinda-dirty solution around that
                List <Gesture> sourceList = JsonConvert.DeserializeObject <List <Gesture> >(json);
                while (GestureCollection.Count > 0)
                {
                    GestureCollection.RemoveAt(0);
                }
                foreach (Gesture sourceGesture in sourceList)
                {
                    Gesture targetGesture = new Gesture();
                    targetGesture.Name    = sourceGesture.Name;
                    targetGesture.Command = new ObservableCollection <Key>(sourceGesture.Command);
                    targetGesture.Hold    = sourceGesture.Hold;
                    targetGesture.Joint   = sourceGesture.Joint;
                    while (targetGesture.Frames.Count > 0)
                    {
                        targetGesture.Frames.RemoveAt(0);
                    }
                    foreach (GestureFrame sourceFrame in sourceGesture.Frames)
                    {
                        GestureFrame targetFrame = new GestureFrame();
                        for (int i = 0; i < 400; i++)
                        {
                            targetFrame.FrontCells[i] = sourceFrame.FrontCells[i];
                            targetFrame.SideCells[i]  = sourceFrame.SideCells[i];
                        }
                        targetGesture.Frames.Add(targetFrame);
                    }
                    GestureCollection.Add(targetGesture);
                }
            }
        }
예제 #22
0
        private static void InterestsChanged(BindableObject bo, GestureCollection oldvalue, GestureCollection newvalue)
        {
            var view = bo as View;
            //if (view == null)
            //  throw new InvalidBindableException(bo, typeof(View));

            var gcv = FindContentViewParent(view, false);

            if (gcv == null)
            {
                PendingInterestParameters.Add(new PendingInterestParams {
                    View = view, Interests = newvalue
                });
                view.PropertyChanged += ViewPropertyChanged;
            }
            else
            {
                gcv.RegisterInterests(view, newvalue);
            }
        }
예제 #23
0
        public void LoadGestureCollection(string filename)
        {
            string json = File.ReadAllText(filename);
            // DeserializeObject() does not appear to correctly deserialize Gesture objects
            // Below is a kinda-dirty solution around that
            List <Gesture> sourceList = JsonConvert.DeserializeObject <List <Gesture> >(json);

            GestureCollection.Clear();

            foreach (Gesture sourceGesture in sourceList)
            {
                RemoveNoneKeys(sourceGesture.Command); //Seems somewhere at the serialization or deserialization Key.None creeps in, so remove it

                //copy sourceGesture to targetGesture //TODO: check why this copying is needed
                Gesture targetGesture = new Gesture()
                {
                    Name    = sourceGesture.Name,
                    Command = new ObservableCollection <Key>(sourceGesture.Command),
                    Hold    = sourceGesture.Hold,
                    Joint   = sourceGesture.Joint
                };
                //copy the frames too (note: this is not the same as DeepCopyGestureFrame)
                foreach (GestureFrame sourceFrame in sourceGesture.Frames)
                {
                    GestureFrame targetFrame = new GestureFrame();
                    for (int i = 0; i < 400; i++)
                    {
                        targetFrame.FrontCells[i] = sourceFrame.FrontCells[i];
                        targetFrame.SideCells[i]  = sourceFrame.SideCells[i];
                    }
                    targetGesture.Frames.Add(targetFrame);
                }

                GestureCollection.Add(targetGesture);

                if (GestureCollectionLoaded != null)
                {
                    GestureCollectionLoaded(this, EventArgs.Empty);
                }
            }
        }
예제 #24
0
        private void HighlightFrames_Visualizer(Gesture g, List <GestureFrame> fs)
        {
            Model3DGroup modelGroup = new Model3DGroup();
            // Create material
            SolidColorBrush materialBrush = new SolidColorBrush()
            {
                Color   = Colors.White,
                Opacity = 0.3
            };
            EmissiveMaterial material = new EmissiveMaterial(materialBrush);

            foreach (GestureFrame f in fs)
            {
                foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                {
                    int fcIndex = Array.IndexOf(f.FrontCells, fc);
                    foreach (GestureFrameCell sc in f.SideCells.Where(
                                 sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                    {
                        // Init mesh
                        MeshBuilder meshBuilder = new MeshBuilder(false, false);
                        // Make cube and add to mesh
                        double  y          = (fc.LeftCM + fc.RightCM) / 2;
                        double  z          = (fc.TopCM + fc.BottomCM) / 2;
                        double  x          = (sc.LeftCM + sc.RightCM) / 2;
                        Point3D cubeCenter = new Point3D(x, y, z);
                        meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                        // Create and freeze mesh
                        var mesh = meshBuilder.ToMesh(true);
                        // Create models
                        modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                    }
                }
            }
            CollisionHighlights_3D.Children[GestureCollection.IndexOf(g)]    = modelGroup;
            CollisionHighlights_Front.Children[GestureCollection.IndexOf(g)] = modelGroup;
            CollisionHighlights_Side.Children[GestureCollection.IndexOf(g)]  = modelGroup;
        }
예제 #25
0
 /// <summary>
 /// ctor guarenttess that <see cref="Interests"/> is not null
 /// </summary>
 public Gestures()
 {
     Interests= new GestureCollection();
 }
예제 #26
0
 protected CommandDefinition()
 {
     Gestures = new GestureCollection();
     Gestures.CollectionChanged += Gestures_GestursChanged;
     KeyGestures = new List <MultiKeyGesture>();
 }
예제 #27
0
        public void ShowVisualizer() //TODO: make method smaller (refactor into multiple methods)
        {
            CollisionTimes            = new List <List <DateTime> >();
            CollisionStates           = new List <JointCollisionStates[]>();
            CollisionHighlights_3D    = new Model3DGroup();
            CollisionHighlights_Front = new Model3DGroup();
            CollisionHighlights_Side  = new Model3DGroup();

            foreach (Gesture g in GestureCollection)
            {
                CollisionTimes.Add(new List <DateTime>());
                foreach (GestureFrame f in g.Frames)
                {
                    CollisionTimes.Last().Add(new DateTime());
                }
                CollisionStates.Add(new JointCollisionStates[2] {
                    JointCollisionStates.OutThere, JointCollisionStates.OutThere
                });
                CollisionHighlights_3D.Children.Add(new Model3DGroup());
                CollisionHighlights_Front.Children.Add(new Model3DGroup());
                CollisionHighlights_Side.Children.Add(new Model3DGroup());
            }

            HotspotCellsModelVisual3D_Hit_Visualizer.Content = CollisionHighlights_3D;

            // Mark gesture cells in 3D Grid
            Model3DGroup modelGroup = new Model3DGroup();

            foreach (Gesture g in GestureCollection)
            {
                foreach (GestureFrame f in g.Frames)
                {
                    // Create material
                    SolidColorBrush materialBrush = new SolidColorBrush()
                    {
                        Color   = Visualizer_GestureColors[GestureCollection.IndexOf(g) % Visualizer_GestureColors.Length].Color,
                        Opacity = 0.1 + ((double)(g.Frames.IndexOf(f) + 1) / (double)g.Frames.Count) * 0.6
                    };
                    DiffuseMaterial material = new DiffuseMaterial(materialBrush);

                    foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                    {
                        int fcIndex = Array.IndexOf(f.FrontCells, fc);
                        foreach (GestureFrameCell sc in f.SideCells.Where(
                                     sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                        {
                            // Init mesh
                            MeshBuilder meshBuilder = new MeshBuilder(false, false);
                            // Make cube and add to mesh
                            double  y          = (fc.LeftCM + fc.RightCM) / 2;
                            double  z          = (fc.TopCM + fc.BottomCM) / 2;
                            double  x          = (sc.LeftCM + sc.RightCM) / 2;
                            Point3D cubeCenter = new Point3D(x, y, z);
                            meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                            // Create and freeze mesh
                            var mesh = meshBuilder.ToMesh(true);
                            // Create models
                            modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                        }
                    }
                }
                HotspotCellsModelVisual3D_Visualizer.Content = modelGroup;
            }

            VisualizerVisible = true;

            EnableKinect_Visualizer();
            DisableKeyboardControl_Visualizer(); //we don't want to consume emulated keyboard events
        }
예제 #28
0
        /// <summary>
        /// Sync 3D Viewport with grids
        /// </summary>
        private void SyncEditorGrids_3D(Gesture g) //TODO: split into smaller methods
        {
            // Init 3D stuff
            Model3DGroup modelGroup = new Model3DGroup();

            foreach (GestureFrame f in g.Frames)
            {
                // Create material
                SolidColorBrush materialBrush = new SolidColorBrush()
                {
                    Color   = Colors.DarkSlateBlue,
                    Opacity = 0.1 + ((double)(g.Frames.IndexOf(f) + 1) / (double)g.Frames.Count) * 0.8
                };
                DiffuseMaterial material = new DiffuseMaterial(materialBrush);

                foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                {
                    int fcIndex = Array.IndexOf(f.FrontCells, fc);
                    foreach (GestureFrameCell sc in f.SideCells.Where(
                                 sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                    {
                        // Init mesh
                        MeshBuilder meshBuilder = new MeshBuilder(false, false);
                        // Make cube and add to mesh
                        double  y          = (fc.LeftCM + fc.RightCM) / 2;
                        double  z          = (fc.TopCM + fc.BottomCM) / 2;
                        double  x          = (sc.LeftCM + sc.RightCM) / 2;
                        Point3D cubeCenter = new Point3D(x, y, z);
                        meshBuilder.AddBox(cubeCenter, 15, 15, 15);

                        // Create and freeze mesh
                        var mesh = meshBuilder.ToMesh(true);

                        // Create model
                        modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                    }
                }
            }

            // Suggest other gestures too
            foreach (Gesture gg in GestureCollection)
            {
                foreach (GestureFrame f in gg.Frames)
                {
                    // Create material
                    SolidColorBrush materialBrush = new SolidColorBrush()
                    {
                        Color   = Visualizer_GestureColors[GestureCollection.IndexOf(gg) % Visualizer_GestureColors.Length].Color,
                        Opacity = ((double)(gg.Frames.IndexOf(f) + 1) / (double)gg.Frames.Count) * 0.09
                    };
                    DiffuseMaterial material = new DiffuseMaterial(materialBrush);

                    foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                    {
                        int fcIndex = Array.IndexOf(f.FrontCells, fc);
                        foreach (GestureFrameCell sc in f.SideCells.Where(
                                     sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                        {
                            // Init mesh
                            MeshBuilder meshBuilder = new MeshBuilder(false, false);

                            // Make cube and add to mesh
                            double  y          = (fc.LeftCM + fc.RightCM) / 2;
                            double  z          = (fc.TopCM + fc.BottomCM) / 2;
                            double  x          = (sc.LeftCM + sc.RightCM) / 2;
                            Point3D cubeCenter = new Point3D(x, y, z);
                            meshBuilder.AddBox(cubeCenter, 15, 15, 15);

                            // Create and freeze mesh
                            var mesh = meshBuilder.ToMesh(true);

                            // Create model
                            modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                        }
                    }
                }
            }

            HotspotCellsModelVisual3D_Editor.Content = modelGroup;
        }
예제 #29
0
 private void SyncEditorGrids()
 {
     try {
         Gesture g = (Gesture)TheWorkspace.DataContext;
         // Enable/disable rows on SideViewGrid according to selection on FrontViewGrid
         GestureFrame       sf  = (GestureFrame)FramesListBox.SelectedItem;
         GestureFrameCell[] fcs = (GestureFrameCell[])FVGrid.ItemsSource;
         GestureFrameCell[] scs = (GestureFrameCell[])SVGrid.ItemsSource;
         // 'If' overcomes FVGrid_SelectionChanged firing before everything else and syncing SVGrid to a different Frame's FVGrid
         if (Object.ReferenceEquals(sf.FrontCells, fcs) && Object.ReferenceEquals(sf.SideCells, scs))
         {
             IList      frontViewGrid_selectedCells = (IList)FVGrid.SelectedItems;
             List <int> frontViewGrid_selectedRows  = new List <int>();
             foreach (GestureFrameCell c in frontViewGrid_selectedCells)
             {
                 frontViewGrid_selectedRows.Add((int)(c.IndexInFrame / 20));
             }
             for (int i = 0; i < 400; i++)
             {
                 ListBoxItem sideViewGridItemContainer = (ListBoxItem)SVGrid.ItemContainerGenerator.ContainerFromIndex(i);
                 if (frontViewGrid_selectedRows.Contains((int)(i / 20)))
                 {
                     sideViewGridItemContainer.IsEnabled = true;
                 }
                 else
                 {
                     sideViewGridItemContainer.IsEnabled = false;
                     GestureFrame f = (GestureFrame)SVGrid.DataContext;
                     f.SideCells[i].IsHotspot = false;
                 }
             }
         }
         // Put hints for the current gesture's existing hotspots below both 2D grids
         FVHints.Children.Clear();
         SVHints.Children.Clear();
         for (int i = 0; i < 400; i++)
         {
             FVHints.Children.Add(new Border()
             {
                 Background = Brushes.Transparent, BorderBrush = Brushes.Transparent
             });
             SVHints.Children.Add(new Border()
             {
                 Background = Brushes.Transparent, BorderBrush = Brushes.Transparent
             });
         }
         foreach (GestureFrame f in g.Frames)
         {
             foreach (GestureFrameCell c in f.FrontCells.Where(c => c.IsHotspot))
             {
                 Border b = (Border)FVHints.Children[c.IndexInFrame];
                 b.Background = new SolidColorBrush()
                 {
                     Color = Colors.SlateBlue, Opacity = 0.2
                 };
             }
             foreach (GestureFrameCell c in f.SideCells.Where(c => c.IsHotspot))
             {
                 Border b = (Border)SVHints.Children[c.IndexInFrame];
                 b.Background = new SolidColorBrush()
                 {
                     Color = Colors.SlateBlue, Opacity = 0.2
                 };
             }
         }
         // Also sync 3D Viewport with grids
         // Init 3D stuff
         Model3DGroup modelGroup = new Model3DGroup();
         foreach (GestureFrame f in g.Frames)
         {
             // Create material
             SolidColorBrush materialBrush = new SolidColorBrush()
             {
                 Color   = Colors.DarkSlateBlue,
                 Opacity = 0.1 + ((double)(g.Frames.IndexOf(f) + 1) / (double)g.Frames.Count) * 0.8
             };
             DiffuseMaterial material = new DiffuseMaterial(materialBrush);
             foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
             {
                 int fcIndex = Array.IndexOf(f.FrontCells, fc);
                 foreach (GestureFrameCell sc in f.SideCells.Where(
                              sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                 {
                     // Init mesh
                     MeshBuilder meshBuilder = new MeshBuilder(false, false);
                     // Make cube and add to mesh
                     double  y          = (fc.LeftCM + fc.RightCM) / 2;
                     double  z          = (fc.TopCM + fc.BottomCM) / 2;
                     double  x          = (sc.LeftCM + sc.RightCM) / 2;
                     Point3D cubeCenter = new Point3D(x, y, z);
                     meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                     // Create and freeze mesh
                     var mesh = meshBuilder.ToMesh(true);
                     // Create model
                     modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                 }
             }
         }
         // Suggest other gestures too
         foreach (Gesture gg in GestureCollection)
         {
             foreach (GestureFrame f in gg.Frames)
             {
                 // Create material
                 SolidColorBrush materialBrush = new SolidColorBrush()
                 {
                     Color   = Visualizer_GestureColors[GestureCollection.IndexOf(gg) % Visualizer_GestureColors.Length].Color,
                     Opacity = ((double)(gg.Frames.IndexOf(f) + 1) / (double)gg.Frames.Count) * 0.09
                 };
                 DiffuseMaterial material = new DiffuseMaterial(materialBrush);
                 foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                 {
                     int fcIndex = Array.IndexOf(f.FrontCells, fc);
                     foreach (GestureFrameCell sc in f.SideCells.Where(
                                  sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                     {
                         // Init mesh
                         MeshBuilder meshBuilder = new MeshBuilder(false, false);
                         // Make cube and add to mesh
                         double  y          = (fc.LeftCM + fc.RightCM) / 2;
                         double  z          = (fc.TopCM + fc.BottomCM) / 2;
                         double  x          = (sc.LeftCM + sc.RightCM) / 2;
                         Point3D cubeCenter = new Point3D(x, y, z);
                         meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                         // Create and freeze mesh
                         var mesh = meshBuilder.ToMesh(true);
                         // Create model
                         modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                     }
                 }
             }
         }
         HotspotCellsModelVisual3D_Editor.Content = modelGroup;
     }
     catch (NullReferenceException) { return; }
 }
예제 #30
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GestureCollection obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
예제 #31
0
 /// <summary>
 /// ctor guarenttess that <see cref="Interests"/> is not null
 /// </summary>
 public Gestures()
 {
     Interests = new GestureCollection();
 }
예제 #32
0
        public void Play(object parameter)
        {
            CollisionTimes            = new List <List <DateTime> >();
            CollisionStates           = new List <JointCollisionStates[]>();
            CollisionHighlights_3D    = new Model3DGroup();
            CollisionHighlights_Front = new Model3DGroup();
            CollisionHighlights_Side  = new Model3DGroup();
            foreach (Gesture g in GestureCollection)
            {
                CollisionTimes.Add(new List <DateTime>());
                foreach (GestureFrame f in g.Frames)
                {
                    CollisionTimes.Last().Add(new DateTime());
                }
                CollisionStates.Add(new JointCollisionStates[2] {
                    JointCollisionStates.OutThere, JointCollisionStates.OutThere
                });
                CollisionHighlights_3D.Children.Add(new Model3DGroup());
                CollisionHighlights_Front.Children.Add(new Model3DGroup());
                CollisionHighlights_Side.Children.Add(new Model3DGroup());
            }
            HotspotCellsModelVisual3D_Hit_Visualizer.Content = CollisionHighlights_3D;
            // Mark gesture cells in 3D Grid
            Model3DGroup modelGroup = new Model3DGroup();

            foreach (Gesture g in GestureCollection)
            {
                foreach (GestureFrame f in g.Frames)
                {
                    // Create material
                    SolidColorBrush materialBrush = new SolidColorBrush()
                    {
                        Color   = Visualizer_GestureColors[GestureCollection.IndexOf(g) % Visualizer_GestureColors.Length].Color,
                        Opacity = 0.1 + ((double)(g.Frames.IndexOf(f) + 1) / (double)g.Frames.Count) * 0.6
                    };
                    DiffuseMaterial material = new DiffuseMaterial(materialBrush);
                    foreach (GestureFrameCell fc in f.FrontCells.Where(fc => fc.IsHotspot == true))
                    {
                        int fcIndex = Array.IndexOf(f.FrontCells, fc);
                        foreach (GestureFrameCell sc in f.SideCells.Where(
                                     sc => sc.IsHotspot == true && (int)(Array.IndexOf(f.SideCells, sc) / 20) == (int)(fcIndex / 20)))
                        {
                            // Init mesh
                            MeshBuilder meshBuilder = new MeshBuilder(false, false);
                            // Make cube and add to mesh
                            double  y          = (fc.LeftCM + fc.RightCM) / 2;
                            double  z          = (fc.TopCM + fc.BottomCM) / 2;
                            double  x          = (sc.LeftCM + sc.RightCM) / 2;
                            Point3D cubeCenter = new Point3D(x, y, z);
                            meshBuilder.AddBox(cubeCenter, 15, 15, 15);
                            // Create and freeze mesh
                            var mesh = meshBuilder.ToMesh(true);
                            // Create models
                            modelGroup.Children.Add(new GeometryModel3D(mesh, material));
                        }
                    }
                }
                HotspotCellsModelVisual3D_Visualizer.Content = modelGroup;
            }
            // Show visualizer
            TheEditor.Visibility     = Visibility.Hidden;
            TheVisualizer.Visibility = Visibility.Visible;
            EditorOverlay.Visibility = Visibility.Hidden;
            // Hide Manager
            ManagerOverlay.Visibility = Visibility.Visible;
            // Enable Kinect
            if (kinect != null)
            {
                kinect.SkeletonStream.Enable();
                kinect.SkeletonFrameReady += SkeletonFrameReady_Draw3D_Visualizer;
                kinect.SkeletonFrameReady += SkeletonFrameReady_Detect_Visualizer;
                kinect.Start();
            }
            // Kill keyboard control
            EventLogic.RemoveRoutedEventHandlers(ViewPort3D_Visualizer.CameraController, HelixToolkit.Wpf.CameraController.KeyDownEvent);
        }