Beispiel #1
0
        public SignWordPage(SystemStatusCollection systemStatusCollection)
        {
            InitializeComponent();
            this.DataContext = systemStatusCollection;

            systemStatusCollection.ColorBitmap = new WriteableBitmap(640, 480, 96.0, 96.0, PixelFormats.Bgr32, null);

            sensor = systemStatusCollection.CurrentKinectSensor;

            _colorPixels      = new byte[systemStatusCollection.CurrentKinectSensor.ColorStream.FramePixelDataLength];
            _depthPixels      = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength];
            capturedSkeletons = new List <Skeleton> {
                Capacity = 500
            };
            templateModel = LoadSkeleton("sign.txt");
            systemStatusCollection.CurrentKinectSensor.AllFramesReady += AllFrameReady;

            m_timer          = new Timer();
            m_timer.Elapsed += (sender, args) =>
            {
                var timer = sender as Timer;
                if (timer != null)
                {
                    timer.Stop();
                }
                ScoreSign();
            };
            m_timer.Interval = 10000;
            m_timer.Enabled  = true;
        }
Beispiel #2
0
        private void SaveSkeleton(string filename, SignModel data)
        {
            StreamWriter sw = new StreamWriter(filename);

            sw.WriteLine(data.ToString());
            sw.Close();
        }
        public SignWordPage(SystemStatusCollection systemStatusCollection)
        {
            InitializeComponent();
            this.DataContext = systemStatusCollection;

            systemStatusCollection.ColorBitmap = new WriteableBitmap(640, 480, 96.0, 96.0, PixelFormats.Bgr32, null);

            sensor = systemStatusCollection.CurrentKinectSensor;

            _colorPixels = new byte[systemStatusCollection.CurrentKinectSensor.ColorStream.FramePixelDataLength];
            _depthPixels = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength];
            capturedSkeletons = new List<Skeleton> {Capacity = 500};
            templateModel = LoadSkeleton("sign.txt");
            systemStatusCollection.CurrentKinectSensor.AllFramesReady += AllFrameReady;

            m_timer = new Timer();
            m_timer.Elapsed += (sender, args) =>
            {
                var timer = sender as Timer;
                if (timer != null) timer.Stop();
                ScoreSign();
            };
            m_timer.Interval = 10000;
            m_timer.Enabled = true;
        }
Beispiel #4
0
        private SignModel LoadSkeleton(string filename)
        {
            StreamReader sr   = new StreamReader(filename);
            string       line = sr.ReadLine();
            var          sm   = SignModel.CreateFromString(line);

            return(sm);
        }
 public static SignModel CreateFromString(string s)
 {
     string name = s.Split(':')[0];
     var sm = new SignModel();
     sm.Name = name;
     string data = s.Split(':')[1];
     string[] datas = data.Split();
     foreach (var item in datas)
     {
         double v = Convert.ToDouble(item.Split(',')[0]);
         double h = Convert.ToDouble(item.Split(',')[1]);
         sm.H_horizantal.Add(h);
         sm.H_vertical.Add(v);
     }
     return sm;
 }
Beispiel #6
0
        public static SignModel CreateFromString(string s)
        {
            string name = s.Split(':')[0];
            var    sm   = new SignModel();

            sm.Name = name;
            string data = s.Split(':')[1];

            string[] datas = data.Split();
            foreach (var item in datas)
            {
                double v = Convert.ToDouble(item.Split(',')[0]);
                double h = Convert.ToDouble(item.Split(',')[1]);
                sm.H_horizantal.Add(h);
                sm.H_vertical.Add(v);
            }
            return(sm);
        }
Beispiel #7
0
        private double CalculateCost(SignModel sm1, SignModel sm2)
        {
            var seriesVariables = new List <SeriesVariable>();

            seriesVariables.Add(
                new SeriesVariable(
                    sm1.H_horizantal.ToArray(),
                    sm2.H_horizantal.ToArray()));
            seriesVariables.Add(
                new SeriesVariable(
                    sm1.H_vertical.ToArray(),
                    sm2.H_vertical.ToArray()));

            var seriesVariablesArray = seriesVariables.ToArray();

            var dtw = new Dtw(seriesVariablesArray);

            m_dtw = dtw;
            return(dtw.GetCost());
        }
Beispiel #8
0
        private SignModel ProcessSkeleton(string name, List <Skeleton> s)
        {
            var signmodel = new SignModel {
                Name = name
            };

            foreach (var item in s)
            {
                SkeletonPoint rh   = item.Joints[JointType.HandRight].Position;
                SkeletonPoint rs   = item.Joints[JointType.ShoulderRight].Position;
                SkeletonPoint ls   = item.Joints[JointType.ShoulderLeft].Position;
                SkeletonPoint head = item.Joints[JointType.Head].Position;
                SkeletonPoint hip  = item.Joints[JointType.HipCenter].Position;

                float v = (rh.Y - head.Y) / (head.Y - hip.Y);
                float h = (rh.X - rs.X) / (rs.X - ls.X);
                signmodel.H_horizantal.Add(h);
                signmodel.H_vertical.Add(v);
            }
            return(signmodel);
        }
 private void SaveSkeleton(string filename, SignModel data)
 {
     StreamWriter sw = new StreamWriter(filename);
     sw.WriteLine(data.ToString());
     sw.Close();
 }
        private SignModel ProcessSkeleton(string name, List<Skeleton> s)
        {
            var signmodel = new SignModel { Name = name };
            foreach (var item in s)
            {
                SkeletonPoint rh = item.Joints[JointType.HandRight].Position;
                SkeletonPoint rs = item.Joints[JointType.ShoulderRight].Position;
                SkeletonPoint ls = item.Joints[JointType.ShoulderLeft].Position;
                SkeletonPoint head = item.Joints[JointType.Head].Position;
                SkeletonPoint hip = item.Joints[JointType.HipCenter].Position;

                float v = (rh.Y - head.Y) / (head.Y - hip.Y);
                float h = (rh.X - rs.X) / (rs.X - ls.X);
                signmodel.H_horizantal.Add(h);
                signmodel.H_vertical.Add(v);
            }
            return signmodel;
        }
        private double CalculateCost(SignModel sm1, SignModel sm2)
        {
            var seriesVariables = new List<SeriesVariable>();

            seriesVariables.Add(
                    new SeriesVariable(
                        sm1.H_horizantal.ToArray(),
                        sm2.H_horizantal.ToArray()));
            seriesVariables.Add(
                    new SeriesVariable(
                        sm1.H_vertical.ToArray(),
                        sm2.H_vertical.ToArray()));

            var seriesVariablesArray = seriesVariables.ToArray();

            var dtw = new Dtw(seriesVariablesArray);
            m_dtw = dtw;
            return dtw.GetCost();
        }