Esempio n. 1
0
        public ViewLoader(String tmp)
        {
            InitializeComponent();
            //Console.WriteLine("Widget width: " + Loadingwidget.ActualWidth);

            this.Loaded += new RoutedEventHandler(ViewLoader_Loaded);

            //start kinectinterpreter
            kinectInterp = new KinectInterpreter(vpcanvas2);

            if (kinectInterp.kinectReady)
            {
                if (tmp == "RGB")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startRGBStream();
                    this.kinectInterp.kinectSensor.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(ColorImageReady);
                }
                else if (tmp == "RGB Isolation")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startRGBStream();
                    kinectInterp.startDepthStream();
                    kinectInterp.startSkeletonStream();
                    this.kinectInterp.kinectSensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(SensorAllFramesReady);
                }
                else if (tmp == "Depth Isolation")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startDepthStream();
                    kinectInterp.startSkeletonStream();
                    this.kinectInterp.kinectSensor.DepthFrameReady += new EventHandler<DepthImageFrameReadyEventArgs>(DepthImageReady);
                    this.kinectInterp.kinectSensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(SkeletonFrameReady);
                }
                else if (tmp == "Skeleton")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startSkeletonStream();
                    this.kinectInterp.kinectSensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(SkeletonFrameReady);
                }
                else if (tmp == "Depth")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startDepthStream();
                    this.kinectInterp.kinectSensor.DepthFrameReady += new EventHandler<DepthImageFrameReadyEventArgs>(DepthImageReady);
                }
                else
                {
                    //not sure if this will break
                    this.Close();
                }
            }
        }
Esempio n. 2
0
        public ViewLoader(String tmp)
        {
            InitializeComponent();
            //Console.WriteLine("Widget width: " + Loadingwidget.ActualWidth);

            this.Loaded += new RoutedEventHandler(ViewLoader_Loaded);

            //start kinectinterpreter
            kinectInterp = new KinectInterpreter(vpcanvas2);

            if (kinectInterp.kinectReady)
            {
                if (tmp == "RGB")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startRGBStream();
                    this.kinectInterp.kinectSensor.ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(ColorImageReady);
                }
                else if (tmp == "RGB Isolation")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startRGBStream();
                    kinectInterp.startDepthStream();
                    kinectInterp.startSkeletonStream();
                    this.kinectInterp.kinectSensor.AllFramesReady += new EventHandler <AllFramesReadyEventArgs>(SensorAllFramesReady);
                }
                else if (tmp == "Depth Isolation")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startDepthStream();
                    kinectInterp.startSkeletonStream();
                    this.kinectInterp.kinectSensor.DepthFrameReady    += new EventHandler <DepthImageFrameReadyEventArgs>(DepthImageReady);
                    this.kinectInterp.kinectSensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(SkeletonFrameReady);
                }
                else if (tmp == "Skeleton")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startSkeletonStream();
                    this.kinectInterp.kinectSensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(SkeletonFrameReady);
                }
                else if (tmp == "Depth")
                {
                    kinectInterp.stopStreams();
                    kinectInterp.startDepthStream();
                    this.kinectInterp.kinectSensor.DepthFrameReady += new EventHandler <DepthImageFrameReadyEventArgs>(DepthImageReady);
                }
                else
                {
                    //not sure if this will break
                    this.Close();
                }
            }
        }
Esempio n. 3
0
        private void ScanLoader_Loaded(object Sender, RoutedEventArgs e)
        {
            if (this.mode == (int)OperationModes.CaptureNewCloud)
            {
                //start scanning procedure
                kinectInterp = new KinectInterpreter(skeloutline);

                if (!this.kinectInterp.isSkeletonEnabled())
                {
                    this.kinectInterp.startSkeletonStream();
                    this.kinectInterp.kinectSensor.SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(SkeletonFrameReady);
                }
            }

            System.Diagnostics.Debug.WriteLine("Scan loader loading complete");
        }
Esempio n. 4
0
        public CoreLoader()
        {
            //Initialize Component
            InitializeComponent();

            //Initialize Database
            db = new DatabaseEngine();

            //Initialize KinectInterpreter

            sandra        = new SpeechSynthesizer();
            sandra.Rate   = 1;
            sandra.Volume = 100;

            kinectInterp = new KinectInterpreter(vpcanvas2);

            this.checkKinectIsOkay();

            this.kinectmenu.IsEnabled = false;
            this.newscan.IsEnabled    = false;

            //ui initialization
            this.WindowState = WindowState.Maximized;

            //Miscellaneous modelling definitions
            Model     = new GeometryModel3D();
            BaseModel = new GeometryModel3D();

            //Set default working directory
            if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\PARSE"))
            {
                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\PARSE");
            }
            workingDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\PARSE";

            this.resetButtons();
        }
Esempio n. 5
0
        private void ScanLoader_Loaded(object Sender, RoutedEventArgs e)
        {
            if (this.mode == (int)OperationModes.CaptureNewCloud)
            {
                //start scanning procedure
                kinectInterp = new KinectInterpreter(skeloutline);

                if (!this.kinectInterp.isSkeletonEnabled())
                {
                    this.kinectInterp.startSkeletonStream();
                    this.kinectInterp.kinectSensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(SkeletonFrameReady);
                }
            }

            System.Diagnostics.Debug.WriteLine("Scan loader loading complete");
        }
Esempio n. 6
0
        public List<Tuple<double, double, List<List<Point3D>>>> determineLimb(PointCloud pcdexisting, double weight)
        {
            //pull in skeleton measures from a temporary file for corbett.parse for now.
            kinectInterp = new KinectInterpreter(skeloutline);
            Dictionary<String, double[]> jointDepthsStr = new Dictionary<String, double[]>();

            //temporary tuple for results
            Tuple<double, double, List<List<Point3D>>> T = new Tuple<double, double, List<List<Point3D>>>(0,0,null);
            //permanent list of tuples for passing back to coreLoader
            List<Tuple<double, double, List<List<Point3D>>>> limbMeasures = new List<Tuple<double,double,List<List<Point3D>>>>();

            //Test if we have a kinect otherwise we cannot use coordinate mapper.
            if (KinectSensor.KinectSensors.Count > 0)
            {
                //test if we have already enumerated joint depths, if so, this has followed a recent scan.

                if (jointDepths.Count == 0)
                {

                    StreamReader sr = new StreamReader("SKEL.ptemp");
                    String line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        String[] joint = Regex.Split(line, ":");
                        String[] positions = Regex.Split(joint[1], ",");

                        double[] jointPos = { Convert.ToDouble(positions[0]), Convert.ToDouble(positions[1]), Convert.ToDouble(Regex.Split(positions[2], "\n")[0]) };

                        //convert to depth co-ordinate space
                        SkeletonPoint sp = new SkeletonPoint();
                        sp.X = (float)Convert.ToDouble(jointPos[1]);
                        sp.Y = (float)Convert.ToDouble(jointPos[2]);
                        sp.Z = (float)Convert.ToDouble(jointPos[0]);

                        CoordinateMapper cm = new CoordinateMapper(kinectInterp.kinectSensor);
                        DepthImagePoint dm = cm.MapSkeletonPointToDepthPoint(sp, DepthImageFormat.Resolution640x480Fps30);

                        //convert x and y co-ords to arbitrary point cloud space
                        Tuple<double, double, double> convertedPoints = LimbCalculator.convertToPCCoords(dm.X, dm.Y, sp.Z);
                        double[] jointPos2 = { convertedPoints.Item3, convertedPoints.Item1, convertedPoints.Item2 };

                        //place back into jointDepths array in terms of depth space.
                        jointDepthsStr.Add(joint[0], jointPos2);
                    }

                }
                else
                {
                    //we have some live skeleton depths, enumerate into strings
                    foreach(JointType j in jointDepths.Keys) {

                        jointDepthsStr = new Dictionary<String, double[]>();
                        jointDepthsStr.Add(j.ToString(),jointDepths[j]);

                    }

                }

                for (int limbArea = 1; limbArea <= 8; limbArea++)
                {
                    //pass point cloud and correct bounds to Limb Calculator
                    //shoulders is first option in list so pass first.
                    limbMeasures.Add(LimbCalculator.calculateLimbBounds(pcdexisting, jointDepthsStr, limbArea, weight));
                }
            }
            else
            {
                MessageBoxResult result = System.Windows.MessageBox.Show(this, "You need a Kinect to perform this action.",
            "Kinect Sensor Missing", MessageBoxButton.OK, MessageBoxImage.Stop);
            }

            //change colour of point cloud for limb selection mode
            gv.setMaterial();
            this.DataContext = gv;

            return limbMeasures;
        }
Esempio n. 7
0
        public List <Tuple <double, double, List <List <Point3D> > > > determineLimb(PointCloud pcdexisting, double weight)
        {
            //pull in skeleton measures from a temporary file for corbett.parse for now.
            kinectInterp = new KinectInterpreter(skeloutline);
            Dictionary <String, double[]> jointDepthsStr = new Dictionary <String, double[]>();


            //temporary tuple for results
            Tuple <double, double, List <List <Point3D> > > T = new Tuple <double, double, List <List <Point3D> > >(0, 0, null);
            //permanent list of tuples for passing back to coreLoader
            List <Tuple <double, double, List <List <Point3D> > > > limbMeasures = new List <Tuple <double, double, List <List <Point3D> > > >();

            //Test if we have a kinect otherwise we cannot use coordinate mapper.
            if (KinectSensor.KinectSensors.Count > 0)
            {
                //test if we have already enumerated joint depths, if so, this has followed a recent scan.

                if (jointDepths.Count == 0)
                {
                    StreamReader sr = new StreamReader("SKEL.ptemp");
                    String       line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        String[] joint     = Regex.Split(line, ":");
                        String[] positions = Regex.Split(joint[1], ",");

                        double[] jointPos = { Convert.ToDouble(positions[0]), Convert.ToDouble(positions[1]), Convert.ToDouble(Regex.Split(positions[2], "\n")[0]) };

                        //convert to depth co-ordinate space
                        SkeletonPoint sp = new SkeletonPoint();
                        sp.X = (float)Convert.ToDouble(jointPos[1]);
                        sp.Y = (float)Convert.ToDouble(jointPos[2]);
                        sp.Z = (float)Convert.ToDouble(jointPos[0]);

                        CoordinateMapper cm = new CoordinateMapper(kinectInterp.kinectSensor);
                        DepthImagePoint  dm = cm.MapSkeletonPointToDepthPoint(sp, DepthImageFormat.Resolution640x480Fps30);

                        //convert x and y co-ords to arbitrary point cloud space
                        Tuple <double, double, double> convertedPoints = LimbCalculator.convertToPCCoords(dm.X, dm.Y, sp.Z);
                        double[] jointPos2 = { convertedPoints.Item3, convertedPoints.Item1, convertedPoints.Item2 };

                        //place back into jointDepths array in terms of depth space.
                        jointDepthsStr.Add(joint[0], jointPos2);
                    }
                }
                else
                {
                    //we have some live skeleton depths, enumerate into strings
                    foreach (JointType j in jointDepths.Keys)
                    {
                        jointDepthsStr = new Dictionary <String, double[]>();
                        jointDepthsStr.Add(j.ToString(), jointDepths[j]);
                    }
                }

                for (int limbArea = 1; limbArea <= 8; limbArea++)
                {
                    //pass point cloud and correct bounds to Limb Calculator
                    //shoulders is first option in list so pass first.
                    limbMeasures.Add(LimbCalculator.calculateLimbBounds(pcdexisting, jointDepthsStr, limbArea, weight));
                }
            }
            else
            {
                MessageBoxResult result = System.Windows.MessageBox.Show(this, "You need a Kinect to perform this action.",
                                                                         "Kinect Sensor Missing", MessageBoxButton.OK, MessageBoxImage.Stop);
            }

            //change colour of point cloud for limb selection mode
            gv.setMaterial();
            this.DataContext = gv;

            return(limbMeasures);
        }