コード例 #1
0
        private void comboBox_Correction_Type_SelectedIndexChanged(object sender, EventArgs e)
        {
            m_CorrectionType = comboBox_Correction_Type.SelectedIndex == 0 ? SapFlatField.ScanCorrectionType.Field : SapFlatField.ScanCorrectionType.Line;

            textBox_Line_Avg.Enabled    = m_CorrectionType == SapFlatField.ScanCorrectionType.Line;
            textBox_Vert_Offset.Enabled = m_CorrectionType == SapFlatField.ScanCorrectionType.Line;
            comboBox_Video_Type.Enabled = m_CorrectionType == SapFlatField.ScanCorrectionType.Field;
        }
コード例 #2
0
        private void FlatFieldDlg_Load(object sender, EventArgs e)
        {
            if (m_pBuffer == null || !m_pBuffer.Initialized)
            {
                MessageBox.Show("Invalid buffer object");
                this.Close();
                return;
            }

            if (m_pFlatField == null)
            {
                MessageBox.Show("Invalid flat-field object");
                this.Close();
                return;
            }

            String str;
            bool   isOffLine = (m_pXfer == null);

            str = String.Format("Step 1: {0} a Dark image", isOffLine ? "Load": "Acquire");
            label_darkImage1.Text = str;

            str = String.Format("{0} a Dark Image", isOffLine ? "Load": "Acquire");
            button_Acq_Dark.Text = str;

            str = String.Format("Step 2: {0} a non-saturated bright image", isOffLine ? "Load": "Acquire");
            label_brightImage1.Text = str;

            str = String.Format("{0} Bright Image", isOffLine ? "Load": "Acquire");
            button_Acq_Bright.Text = str;

            // Calculate recommended values for dark and bright images
            int maxPixelValue = (int)Math.Pow(2.0, m_pBuffer.PixelDepth);

            m_RecommendedDark   = (int)(maxPixelValue * SapDefFlatFieldAvgFactorBlack);
            m_RecommendedBright = (int)(maxPixelValue * SapDefFlatFieldAvgFactorWhite);

            // Adjust the recommended dark value according to the hardware limit for offset coefficients
            int offsetMax = m_pFlatField.OffsetMax;

            if (m_RecommendedDark > offsetMax)
            {
                m_RecommendedDark = offsetMax;
            }

            str = String.Format("(recommended average pixel\nvalue below {0})", m_RecommendedDark);
            label_darkImage2.Text = str;

            str = String.Format("(recommended average pixel\nvalue around {0})", m_RecommendedBright);
            label_brightImage2.Text = str;

            // Adjust maximum black deviation from the adjusted recommended dark value
            if (m_pFlatField.DeviationMaxBlack > m_RecommendedDark)
            {
                m_pFlatField.DeviationMaxBlack = m_RecommendedDark;
            }

            // Query correction type, video type, number of lines to average (line scan),
            // vertical offset, gain divisor, maximum deviation, and calibration index
            // for the dark image from flat field object
            m_CorrectionType         = m_pFlatField.CorrectionType;
            m_VideoType              = m_pFlatField.AcqVideoType;
            textBox_Line_Avg.Text    = m_pFlatField.NumLinesAverage.ToString();
            textBox_Vert_Offset.Text = m_pFlatField.VerticalOffset.ToString();
            textBox_Max_Dev.Text     = m_pFlatField.DeviationMaxBlack.ToString();
            //m_CalibrationIndex = m_pFlatField->GetIndex();
            textBox_Frame_Avg.Text = DefNumFramesAverage.ToString();
            ClippedCoefsDefects_checkbox.Checked = m_pFlatField.ClippedGainOffsetDefects ? true : false;

            // Set correction type
            comboBox_Correction_Type.Items.Add("Flat Field");
            comboBox_Correction_Type.Items.Add("Flat Line");
            comboBox_Correction_Type.SelectedIndex = m_CorrectionType == SapFlatField.ScanCorrectionType.Field ? 0 : 1;

            // Set video type
            comboBox_Video_Type.Items.Add("Monochrome");
            comboBox_Video_Type.Items.Add("Bayer");
            comboBox_Video_Type.SelectedIndex = m_VideoType != SapAcquisition.VideoType.Bayer ? 0: 1;


            ///////////////////////////////////////////////////
            //Multi flat-field not implemented in .NET/////////
            //////////////////////////////////////////////////
            // Set calibration index
            // String indexStr;

            //for (int index = 0; index < m_pFlatFieldGetNumFlatField(); index++)
            //{
            //   indexStr.Format("%d", index);
            //   m_CalibrationIndexCtrl.AddString( indexStr);
            //}

            comboBox_Calibration_Index.Items.Add(0);
            comboBox_Calibration_Index.SelectedIndex = 0;


            if (m_pFlatField.AcqDevice != null)
            {
                SapFeature feature = new SapFeature(m_pFlatField.AcqDevice.Location);
                feature.Create();

                Boolean status = false;
                String  deviceModel;

                //for all Genies except Genie TS, do not try to do a file access
                status = m_pFlatField.AcqDevice.IsFeatureAvailable("DeviceModelName");
                if (status)
                {
                    m_pFlatField.AcqDevice.GetFeatureValue("DeviceModelName", out deviceModel);
                    if (deviceModel.Contains("Genie") && !deviceModel.Contains("TS"))
                    {
                        //device is a Genie but not Genie TS

                        m_isGenie = true;
                        button_Save_and_Upload.Text         = "Save";
                        comboBox_FlatField_Selector.Visible = false;
                        label_flatField.Visible             = false;
                        goto nextPart;
                    }
                }

                for (int i = 0; i < m_pFlatField.AcqDevice.FileCount; i++)
                {
                    if (m_pFlatField.AcqDevice.FileNames[i].Contains("FlatField"))
                    {
                        String featureName = "##FileSelector." + m_pFlatField.AcqDevice.FileNames[i];

                        if (!m_pFlatField.AcqDevice.FileNames[i].Contains("0"))
                        {
                            if (m_pFlatField.AcqDevice.GetFeatureInfo(featureName, feature))
                            {
                                comboBox_FlatField_Selector.Items.Add(feature.DisplayName);
                            }
                            else
                            {
                                comboBox_FlatField_Selector.Items.Add(m_pFlatField.AcqDevice.FileNames[i]);
                            }
                            flatFieldIndexes[m_UserFlatFieldCount++] = i;
                            // comboBox_FlatField_Selector.items (m_UserFlatFieldCount++, i);
                        }
                    }
                }

                comboBox_FlatField_Selector.SelectedIndex = 0;
                feature.Destroy();
                saveLabel.Text = "Save Calibration offset and gain files";
            }
            else
            {
                button_Save_and_Upload.Text         = "Save";
                comboBox_FlatField_Selector.Visible = false;
                label_flatField.Visible             = false;
            }
nextPart:
            // Enable/disable controls according to current properties
            // Changing the correction type (flat-field vs flat-line) is only relevant when operating
            // offline, that is, when this information is not available from the acquisition hardware.
            bool isOnline = (m_pXfer != null && m_pXfer.Initialized);

            comboBox_Correction_Type.Enabled = !isOnline && m_VideoType != SapAcquisition.VideoType.Bayer;
            comboBox_Video_Type.Enabled      = m_pXfer == null;

            textBox_Frame_Avg.Enabled   = m_pXfer != null;
            textBox_Line_Avg.Enabled    = m_CorrectionType == SapFlatField.ScanCorrectionType.Line;
            textBox_Vert_Offset.Enabled = m_CorrectionType == SapFlatField.ScanCorrectionType.Line;
            textBox_Max_Dev.Enabled     = true;

            //Multi flat-field not implemented in .NET
            comboBox_Calibration_Index.Enabled = false; //m_pFlatField->GetNumFlatField() > 1);

            button_Acq_Dark.Enabled             = true;
            button_Acq_Bright.Enabled           = false;
            button_OK.Enabled                   = false;
            button_Save_and_Upload.Enabled      = false;
            comboBox_FlatField_Selector.Enabled = false;
        }