public FormFilterResponse(HSIParameters param, string CameraModel)
 {
     InitializeComponent();
     HSIParam = param;
     labelCameraModelFilter.Text   = $"{CameraModel} , Filter-Range {HSIParam.filterRangeStart}-{HSIParam.filterRangeEnd} nm";
     filterStartGraphics           = HSIParam.filterRangeStart;
     filterEndGraphics             = HSIParam.filterRangeEnd;
     textBox_filterStartInput.Text = filterStartGraphics.ToString();
     textBox_filterEndInput.Text   = filterEndGraphics.ToString();
     box     = new CheckBox[25];
     pen     = new Pen[25];
     color   = new Color[25];
     brush   = new SolidBrush[25];
     box[0]  = checkBox0;
     box[1]  = checkBox1;
     box[2]  = checkBox2;
     box[3]  = checkBox3;
     box[4]  = checkBox4;
     box[5]  = checkBox5;
     box[6]  = checkBox6;
     box[7]  = checkBox7;
     box[8]  = checkBox8;
     box[9]  = checkBox9;
     box[10] = checkBox10;
     box[11] = checkBox11;
     box[12] = checkBox12;
     box[13] = checkBox13;
     box[14] = checkBox14;
     box[15] = checkBox15;
     box[16] = checkBox16;
     box[17] = checkBox17;
     box[18] = checkBox18;
     box[19] = checkBox19;
     box[20] = checkBox20;
     box[21] = checkBox21;
     box[22] = checkBox22;
     box[23] = checkBox23;
     box[24] = checkBox24;
     for (int i = 0; i < 25; i++)
     {
         color[i]     = box[i].BackColor;
         pen[i]       = new Pen(color[i]);
         pen[i].Width = 2f;
         brush[i]     = new SolidBrush(color[i]);
     }
     if (HSIParam.filter_nr_bands < 25)
     {
         for (int j = HSIParam.filter_nr_bands; j < 25; j++)
         {
             box[j].Enabled = false;
             box[j].Visible = false;
         }
     }
     panelCurves.Invalidate();
 }
Exemple #2
0
        private bool readXiSpecCalibrationData(bool ignoreCameraCalib, string fileNameTest)
        {
            bool   flag  = false;
            bool   flag2 = false;
            string val   = "";
            int    num   = 0;

            if (!ignoreCameraCalib)
            {
                flag = false;
                try
                {
                    xiH.GetParam("free_ffs_size", out int val2);
                    ausgabe.AppendText($"free file system size = {val2}\n");
                    xiH.GetParam("used_ffs_size", out val2);
                    ausgabe.AppendText($"used file system size = {val2}\n");
                    xiH.SetParam("ffs_file_name", fileNameCalibrationFile);
                    ausgabe.AppendText($"camera: filename = {fileNameCalibrationFile}");
                    xiH.GetParam("read_file_ffs", out val);
                    num = val.Length;
                    ausgabe.AppendText($" has been read.\nlength = {num} bytes\n");
                    ausgabe.ScrollToCaret();
                }
                catch
                {
                    ausgabe.AppendText($", reading file FAILED\n");
                    ausgabe.AppendText($"--> try to read external calibration data\n");
                    ausgabe.ScrollToCaret();
                    flag = true;
                }
                if (!flag)
                {
                    XmlReader xmlReader = XmlReader.Create(new StringReader(val));
                    while (xmlReader.Read())
                    {
                        if (xmlReader.NodeType == XmlNodeType.Element)
                        {
                            if (xmlReader.Name == "calibrations")
                            {
                                flag2 = true;
                            }
                            break;
                        }
                    }
                    if (flag2)
                    {
                        ausgabe.AppendText($"new XIMEA HSI file system found\n");
                        ausgabe.ScrollToCaret();
                        if (!readInternalFile(out val))
                        {
                            ausgabe.AppendText($"reading INTERNAL xiSpec sensor calibration file FAILED\n");
                            ausgabe.ScrollToCaret();
                            flag = true;
                        }
                    }
                }
            }
            else
            {
                if (fileNameTest != "")
                {
                    externalFileName = fileNameTest;
                }
                flag = true;
            }
            if (flag)
            {
                if (readExternalFile(out val))
                {
                    flag = false;
                }
                else if (ausgabe != null)
                {
                    num = val.Length;
                    ausgabe.AppendText($"reading EXTERNAL xiSpec sensor calibration file FAILED\n");
                    ausgabe.ScrollToCaret();
                }
                if (!flag && ausgabe != null)
                {
                    num = val.Length;
                    ausgabe.AppendText($"EXTERNAL xiSpec sensor calibration file\n\t{externalFileName_used}\nhas been read, length = {num} bytes\n");
                    ausgabe.ScrollToCaret();
                }
            }
            if (!flag)
            {
                HSIParam = new HSIParameters(xi_cameraModel, val, filterrangeStart, filterrangeEnd, ausgabe);
                if (HSIParam.filter_nr_bands < 0)
                {
                    if (ausgabe != null)
                    {
                        ausgabe.AppendText($"Calibration parameter NOT CORRECT\n");
                        ausgabe.ScrollToCaret();
                    }
                    flag = true;
                }
                else if (ausgabe != null)
                {
                    ausgabe.AppendText($"Calibration parameter\n");
                    ausgabe.AppendText($"number of bands = {HSIParam.filter_nr_bands}, {HSIParam.filter_mosaic_pattern_width}x{HSIParam.filter_mosaic_pattern_height} Array\n");
                    ausgabe.AppendText($"active area = {HSIParam.filter_active_area_offset_x},{HSIParam.filter_active_area_offset_y} - {HSIParam.filter_active_area_width},{HSIParam.filter_active_area_height}\n");
                    ausgabe.AppendText($"effective HSI image size = {HSIParam.image_width} x {HSIParam.image_height} Pixel\n");
                    ausgabe.AppendText($"Filter range: {filterrangeStart} - {filterrangeEnd}\n");
                    ausgabe.AppendText($"band-number wavelength\n");
                    for (int i = 0; i < HSIParam.filter_nr_bands; i++)
                    {
                        ausgabe.AppendText($"   peak {i} = {HSIParam.array_wavelengths[i]}\n");
                    }
                    ausgabe.AppendText($"LUT(band number) wavelength\n");
                    for (int j = 0; j < HSIParam.filter_nr_bands; j++)
                    {
                        ausgabe.AppendText($"   {HSIParam.spectrumPos_2_BandNr[j]} : {HSIParam.array_wavelengths[HSIParam.spectrumPos_2_BandNr[j]]} nm\n");
                    }
                    ausgabe.ScrollToCaret();
                }
            }
            if (!flag)
            {
                return(true);
            }
            return(false);
        }