Exemplo n.º 1
0
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();

            DateTime curTime = DateTime.Now;

            //retrieve as an anonymous object type
            Object activeRecord = listBox1.SelectedItems[0];

            //access attributes through reflection
            dynamic d   = activeRecord;
            object  id  = d.Id;
            object  nm  = d.Patientname;
            object  nhs = d.Patientnhsno;

            int patientID = Convert.ToInt32(id);

            db.insertScans(1, patientID, System.IO.Path.Combine(workingDir, patientID + "-" + curTime.ToString("ddMMyyyyHHMM") + ".PARSE"), "", curTime);

            //save scan to .parse file in the working directory
            ScanSerializer.serialize(Path.Combine(workingDir, patientID + "-" + curTime.ToString("ddMMyyyyHHMM") + ".PARSE"), pcdl);

            //confirm save
            MessageBoxResult result = System.Windows.MessageBox.Show(this, "Patient saved to database", "Patient Scan Saved", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemplo n.º 2
0
        /// <summary>
        /// performs scan loading on a thread, child method of load scan.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void loadScanThread(Object sender, DoWorkEventArgs e)
        {
            // Cast object back into BackgroundWorker

            BackgroundWorker B = (BackgroundWorker)sender;

            B.ReportProgress(1, "Background worker running");

            String filename = (string)e.Argument;

            if (filename != null)
            {
                B.ReportProgress(0, "Loading file: " + filename);

                ScanSerializer.deserialize(filename);

                System.Diagnostics.Debug.WriteLine(e.Argument);

                B.ReportProgress(8, "Model deserialised");

                pcdl = ScanSerializer.depthPc;

                System.Diagnostics.Debug.WriteLine(pcdl.Count);

                B.ReportProgress(2, "Model loaded");
            }

            if (pcdl.Count == 0)
            {
                throw new PointCloudException("PCDL is empty");
            }

            /*2)*/
            //instantiate the stitcher
            stitcher = new BoundingBox();
            B.ReportProgress(1);

            //jam points into stitcher
            stitcher.add(pcdl);
            B.ReportProgress(1);

            stitcher.stitch();
            B.ReportProgress(5);

            pcd  = stitcher.getResult();
            pcdl = stitcher.getResultList();
            B.ReportProgress(1, "Point Cloud Stitched (with " + pcdl.Count + " components)");
            if (pcdl.Count == 0)
            {
                throw new PointCloudException("Stitcher returned empty point cloud list");
            }

            // Get the height
            double height = Math.Round(HeightCalculator.getHeight(pcd), 3);

            Dispatcher.BeginInvoke((Action)(() => { int progress = 1; }));
            B.ReportProgress(1);
        }
Exemplo n.º 3
0
        /// <summary>
        /// exports a scan into the infamous .PARSE format
        /// </summary>
        /// <param name="sender">the object</param>
        /// <param name="e">the routed event</param>

        private void ExportScan_Click(object sender, RoutedEventArgs e)
        {
            /*ExportScan serializes the visualisation object, once the pointcloud
             * structure has been implemented, it will serialize the pc object
             * rather than this visualisation. Current issue, cant serialize list
             * objects that contain arrays apparantely.*/

            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.DefaultExt = ".PARSE";
            dlg.Filter     = "PARSE Reference Data (.PARSE)|*.PARSE";

            if (dlg.ShowDialog() == true)
            {
                String filename = dlg.FileName;
                ScanSerializer.serialize(filename, windowScanner.getPointClouds());
                this.export1.IsEnabled = false;
            }
        }
Exemplo n.º 4
0
        private void SaveScan_Click(object sender, RoutedEventArgs e)
        {
            //Test if patientloader is currently active and then attribute the scan to them.
            //Otherwise if this is not the case, we need to manually attribute the scan to
            //a patient.

            DateTime curTime = DateTime.Now;

            if (windowPatient == null)
            {
                windowMeta = new MetaLoader();
                windowMeta.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                windowMeta.Owner = this;

                //save specific actions.
                windowMeta.setWorkingDir(workingDir);
                windowMeta.setPC(pcdl);
                windowMeta.Title = "Attribute scan to whom?";
                windowMeta.button1.Visibility = Visibility.Collapsed;
                windowMeta.button2.Visibility = Visibility.Collapsed;
                windowMeta.button3.Visibility = Visibility.Visible;
                windowMeta.Show();
            }
            else
            {
                int currentPatient = Convert.ToInt32(windowPatient.patientIDExisting.Content);

                //save to db and workingdirectory with appropriate id.

                db.insertScans(1, currentPatient, System.IO.Path.Combine(workingDir, currentPatient + "-" + curTime.ToString("ddMMyyyyHHMM") + ".PARSE"), "", curTime);

                //save scan to .parse file in the working directory
                ScanSerializer.serialize(System.IO.Path.Combine(workingDir, currentPatient + "-" + curTime.ToString("ddMMyyyyHHMM") + ".PARSE"), pcdl);

                MessageBoxResult result = System.Windows.MessageBox.Show(this, "Patient saved to database", "Patient Scan Saved", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 5
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.
            }
        }