private void b_depth_Click(object sender, EventArgs e)
        {
            int th, tht;

            //Generate Calibration Data
            _theightc.GenerateCalibrationData(new DepthImage(_deptharray, _width, _height), _calibrationPoints,
                                              out th, out tht);

            DepthMapPreprocessor dmp = new DepthMapPreprocessor();
            DepthCorrectionMap dcm = dmp.CreateDepthCorrectionMap(new DepthImage(_deptharray, _width, _height), th);

            //Set tableHeightTolerance to 25, as there was a depth CorrectionMap created
            tht = 25;

            //If there are border-cutoffs, use them
            try
            {
                if (txt_bottom.Text != "")
                    dcm.CutOffBOttom = Convert.ToInt32(txt_bottom.Text);
                if (txt_left.Text != "")
                    dcm.CutOffLeft = Convert.ToInt32(txt_left.Text);
                if (txt_r.Text != "")
                    dcm.CutOffRight = Convert.ToInt32(txt_r.Text);
                if (txt_top.Text != "")
                    dcm.CutOffTop = Convert.ToInt32(txt_bottom.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Ungültige werte beim Border CutOff!", "Fehler");
                return;
            }

            SettingsManager.PreprocessingSet.DefaultCorrectionMap = dcm;
            _theightc.SetCalibrationData(th, tht);

            //Save the CorrectionMap
            if (!SettingsManager.SaveSettings())
            {
                MessageBox.Show("Depth map created and applied, but settings couldn't be saved!", "Warning!");
            }
            else
            {
                MessageBox.Show("DepthMap Data Created and saved. Calibration is now finished.", "Success!");
            }
        }
        private void b_calibrate_Click(object sender, RoutedEventArgs e)
        {
            //margins
            int top = (int)s_cutoff_top.Value;
            int left = (int) s_cutoff_left.Value;
            int right = (int) s_cutoff_right.Value;
            int bottom = (int) s_cutoff_down.Value;

            //calibrate
            if (points.Count == 0)
            {
                MessageBox.Show("Es muss mindestens ein kalibrationspunkt vorhanden sein!", "Fehler!");
                return;
            }

            int distance;
            int tolerance;

            _theightc.GenerateCalibrationData(_dimage, points, out distance, out tolerance);
            _theightc.SetCalibrationData(distance, 25);

            DepthMapPreprocessor dmp = new DepthMapPreprocessor();

            SettingsManager.PreprocessingSet.DefaultCorrectionMap = dmp.CreateDepthCorrectionMap(_dimage, distance);
            SettingsManager.PreprocessingSet.DefaultCorrectionMap.CutOffBOttom = bottom;
            SettingsManager.PreprocessingSet.DefaultCorrectionMap.CutOffLeft = left;
            SettingsManager.PreprocessingSet.DefaultCorrectionMap.CutOffRight = right;
            SettingsManager.PreprocessingSet.DefaultCorrectionMap.CutOffTop = top;

            if (SettingsManager.SaveSettings())
            {
                MessageBox.Show("Kalibration erfolgreich ausgeführt, Einstellungen gespeichert", "Erfolg");
            }
            else
            {
                MessageBox.Show("Kalibration ausgeführt, Einstellungen konnten aber niht gespeichert werden.", "Achtung");
            }

            this.Close();
        }