Exemple #1
0
        private void kinectSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            if (status != 1)
            {
                return;
            }

            Skeleton[] skeletons = new Skeleton[0];

            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                }
            }

            if (skeletons.Length != 0)
            {
                foreach (Skeleton skel in skeletons)
                {
                    if (skel.TrackingState == SkeletonTrackingState.Tracked)
                    {
                        double[][] vectors = ActionRecognitionUtil.computeVectors(skel);
                        vectorsList.Add(vectors);
                    }
                }
            }
        }
        private void deal1(params MyActionSegmentData[] actions)
        {
            try
            {
                if (actions.Length < 2)
                {
                    return;
                }
                for (int i = 1; i < actions.Length; i++)
                {
                    double[,] similarityMatrix = ActionRecognitionUtil.computeSimilarityMatrix(actions[0], actions[i]);
                    DTWResult     dtwResult = DTWUtil.DTW(similarityMatrix);
                    StringBuilder sb        = new StringBuilder();
                    sb.Append("ActionRecognization\n");
                    sb.Append(actions[0]).Append('\n').Append(actions[i]).Append('\n');
                    sb.Append("result:\n");
                    sb.Append("Similarity:").Append(dtwResult.SumSimilarity).Append(", AvgSimilarity:").Append(dtwResult.AvgSimilarity).Append(", PathLength:").Append(dtwResult.PathLength).Append('\n');
                    sb.Append(dtwResult.PathStr);

                    LogUtil.log(sb.ToString());
                }
            } catch (Exception e)
            {
                LogUtil.log(e.Message);
            }
        }
        private void kinectSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            Skeleton[] skeletons = new Skeleton[0];

            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                }
            }


            using (DrawingContext dc = this.drawingGroup.Open())
            {
                // Draw a transparent background to set the render size
                dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, RenderWidth, RenderHeight));

                if (skeletons.Length != 0)
                {
                    foreach (Skeleton skel in skeletons)
                    {
                        RenderClippedEdges(skel, dc);

                        if (skel.TrackingState == SkeletonTrackingState.Tracked)
                        {
                            this.DrawBonesAndJoints(skel, dc);

                            double[][] vectors = ActionRecognitionUtil.computeVectors(skel);

                            //发送数据
                            messageQueue.offer(vectors);

                            //发送数据2
                            if (sendToSimulation)
                            {
                                vectorSender.send(vectors);
                            }
                        }
                        else if (skel.TrackingState == SkeletonTrackingState.PositionOnly)
                        {
                            dc.DrawEllipse(
                                this.centerPointBrush,
                                null,
                                this.SkeletonPointToScreen(skel.Position),
                                BodyCenterThickness,
                                BodyCenterThickness);
                        }
                    }
                }

                // prevent drawing outside of our render area
                this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, RenderWidth, RenderHeight));
            }
        }
 public double[][] getVectorData()
 {
     return(ActionRecognitionUtil.computeVectors(skeletonDataList[index]));
 }