Пример #1
0
        public static CloudVisualisation deserialize(String filename)
        {
            try
            {
                /*Extracts raw depth data from serialization and creates pc struct*/

                // TODO check this is ok - this line wasn't here before? Nath
                depthPc = new List <PointCloud>();

                XmlSerializer deserializer = new XmlSerializer(typeof(List <int[]>));
                TextReader    textReader   = new StreamReader(filename);
                List <int[]>  temp         = (List <int[]>)(deserializer.Deserialize(textReader));

                /*Deserializes*/
                for (int i = 0; i < temp.Count; i++)
                {
                    depthPc.Add(new PointCloud(null, temp[i]));
                }

                CloudVisualisation cloud = new CloudVisualisation(depthPc, false);
                return(cloud);
            }
            catch (Exception err)
            {
                System.Diagnostics.Debug.WriteLine(err);
            }

            return(null);
        }
Пример #2
0
        private void pcTimer_tick(Object sender, EventArgs e)
        {
            if (countdown == 3)
            {
                //get current skeleton tracking state
                Skeleton skeleton = this.kinectInterp.getSkeletons();
                jointDepths = enumerateSkeletonDepths(skeleton);

                //PointCloud structure methods
                PointCloud frontCloud = new PointCloud(this.kinectInterp.getRGBTexture(), this.kinectInterp.getDepthArray());
                //frontCloud.deleteFloor();
                fincloud.Add(frontCloud);
                sandra.Speak("Scan Added.");

                //freeze skelL skelDepth and skelR
                this.kinectInterp.kinectSensor.SkeletonStream.Disable();

                tmpCanvas              = skeloutline;
                skeloutline            = tmpCanvas;
                skeloutline.Visibility = Visibility.Collapsed;

                sandra.Speak("Please turn left.");
                this.instructionblock.Text = "Please turn left";
                countdown--;
            }
            else if (countdown == 2)
            {
                //PointCloud structure methods
                PointCloud rightCloud = new PointCloud(this.kinectInterp.getRGBTexture(), this.kinectInterp.getDepthArray());
                //rightCloud.deleteFloor();
                fincloud.Add(rightCloud);
                sandra.Speak("Scan Added.");
                sandra.Speak("Please turn left with your back to the camera.");
                this.instructionblock.Text = "Turn left with your back to the camera";
                countdown--;
            }
            else if (countdown == 1)
            {
                //PointCloud structure methods
                PointCloud backCloud = new PointCloud(this.kinectInterp.getRGBTexture(), this.kinectInterp.getDepthArray());
                //backCloud.deleteFloor();
                fincloud.Add(backCloud);
                sandra.Speak("Scan Added.");
                sandra.Speak("Please turn left once more.");
                this.instructionblock.Text = "Please turn left once more.";
                countdown--;
            }
            else if (countdown == 0)
            {
                //PointCloud structure methods
                PointCloud leftCloud = new PointCloud(this.kinectInterp.getRGBTexture(), this.kinectInterp.getDepthArray());
                //leftCloud.deleteFloor();
                fincloud.Add(leftCloud);

                this.instructionblock.Text = "You have now been captured. Thank you for your time.";

                sandra.Speak("Scan Added.");
                sandra.Speak("You have now been captured. Thank you for your time.");

                //stop streams
                kinectInterp.stopStreams();

                if ((((CoreLoader)((PatientLoader)((OptionLoader)(this.Owner)).Owner).Owner).windowPatient.nameText.Text.CompareTo("Greg Corbett")) == 0)
                {
                    CloudVisualisation fudge = ScanSerializer.deserialize("./Corbett.PARSE");
                    ((CoreLoader)((PatientLoader)((OptionLoader)(this.Owner)).Owner).Owner).setPC(null, ScanSerializer.depthPc);
                    ((CoreLoader)((PatientLoader)((OptionLoader)(this.Owner)).Owner).Owner).LoadPointCloud();
                    //((CoreLoader)((PatientLoader)((OptionLoader)(this.Owner)).Owner).Owner).fudge();
                }
                else if (this.Owner is CoreLoader)
                {
                    ((CoreLoader)(this.Owner)).setPC(pcd, fincloud);
                    ((CoreLoader)(this.Owner)).LoadPointCloud();
                    ((CoreLoader)(this.Owner)).export1.IsEnabled     = true;
                    ((CoreLoader)(this.Owner)).export2.IsEnabled     = true;
                    ((CoreLoader)(this.Owner)).removefloor.IsEnabled = true;
                }
                else if (this.Owner is OptionLoader)
                {
                    ((CoreLoader)((PatientLoader)((OptionLoader)(this.Owner)).Owner).Owner).setPC(pcd, fincloud);
                    ((CoreLoader)((PatientLoader)((OptionLoader)(this.Owner)).Owner).Owner).LoadPointCloud();
                    ((CoreLoader)((PatientLoader)((OptionLoader)(this.Owner)).Owner).Owner).export1.IsEnabled     = true;
                    ((CoreLoader)((PatientLoader)((OptionLoader)(this.Owner)).Owner).Owner).export2.IsEnabled     = true;
                    ((CoreLoader)((PatientLoader)((OptionLoader)(this.Owner)).Owner).Owner).removefloor.IsEnabled = true;
                }

                /*
                 * double height = Math.Round(HeightCalculator.getHeight(pcd), 3);
                 * ((CoreLoader)(this.Owner)).windowHistory.heightoutput.Content = height + "m";
                 *
                 * GroupVisualiser gg = new GroupVisualiser(fincloud);
                 * gg.preprocess(null);
                 * this.DataContext = gg;
                 *
                 * //Visualisation instantiation based on KDTree array clouds
                 * this.instructionblock.Text = "Scanning complete.";
                 * this.instructionblock.Visibility = Visibility.Collapsed;
                 *
                 *
                 */
                pcTimer.Stop();
                this.Close();

                //TODO: write all these results to the database; sql insertion clauses.
            }
        }