Exemplo n.º 1
0
        private void ReconstructDepthData(ReconstructionSensor sensor)
        {
            try
            {
                if (null != this.volume && !this.savingMesh)
                {
                    this.Dispatcher.BeginInvoke(
                        (Action)(() =>
                            {
                                this.statusBarText.Text = Properties.Resources.ReconstructFrame
                                                          + this.processedFrameCount.ToString(CultureInfo.CurrentCulture);
                            }));

                    // Process and display depth data
                    this.PreProcessDepthData(sensor);

                    // We would do camera tracking here if required...
                   

                    // Lock the volume operations
                    lock (this.reconstructionLock)
                    {
                        // Integrate the frame to volume
                        if (!this.PauseIntegration)
                        {
                            // Map color to depth if we want to integrate color too
                            if (sensor.CaptureColor && null != sensor.MappedColorFrame)
                            {
                                // Pre-process color
                                sensor.MapColorToDepth();

                                Dispatcher.BeginInvoke(
                                    (Action)
                                    (() =>
                                     this.volume.IntegrateFrame(
                                         sensor.DepthFloatFrame,
                                         sensor.MappedColorFrame,
                                         this.integrationWeight,
                                         FusionDepthProcessor.DefaultColorIntegrationOfAllAngles,
                                         sensor.ReconCamera.WorldToCameraMatrix4)));

                                // Flag that we have captured color
                                this.colorCaptured = true;

                            }
                            else if (this.tracking)
                            {
                                if (first)
                                {
                                    float centreDepth = this.depthFloatFrameDepthPixels[this.depthHeight * this.depthWidth / 2];
                                    if (centreDepth > 0.0)
                                    {
                                    //    Dispatcher.BeginInvoke(
                                    //(Action)
                                    //(() =>
                                    //    sensor.ReconSensorControl.AxisDistance = centreDepth
                                    //    ));
                                    }
                                    first = false;
                                }
                                Dispatcher.BeginInvoke(
                                    (Action)
                                    (() =>
                                        doDepthStuff(sensor)
                                ));
                            }
                            else
                            {
                                first = true;
                                // Just integrate depth
                                Dispatcher.BeginInvoke(
                                    (Action)
                                    (() =>
                                        this.volume.IntegrateFrame(
                                            sensor.DepthFloatFrame, this.integrationWeight, sensor.ReconCamera.WorldToCameraMatrix4)));

                            }
                        }
                    }
                    if (this.processedFrameCount % 2 == 0)
                    {
                        Dispatcher.BeginInvoke((Action)(() => this.RenderReconstruction(this.useCameraViewInReconstruction ? sensor : null)));
                    }
                }
            }
            catch (InvalidOperationException ex)
            {
                this.ShowStatusMessage(ex.Message);
            }
        }