예제 #1
0
 void get_xml_name()
 {
     for (int i = 0; i < 20; i++)
     {
         if (Vision_step[i] == null)
         {
             if (str_name[i] == "Find_model")
             {
                 Vision_step[i] = new UnitFindModel(Vision_step); //str_parm
                 if (!Vision_step[i].LoadConfig(str_parm[i]))
                 {
                     MessageBox.Show("模板载入错误,请选择正确的模板路径");
                 }
             }
             if (str_name[i] == "Find_line")
             {
                 Vision_step[i] = new UnitFindLine(Vision_step); //str_parm
                 if (!Vision_step[i].LoadConfig(str_parm[i]))
                 {
                     MessageBox.Show("找直线,载入参数错误");
                 }
             }
             if (str_name[i] == "Find_circle")
             {
                 Vision_step[i] = new UnitFindCircle(Vision_step); //str_parm
                 if (!Vision_step[i].LoadConfig(str_parm[i]))
                 {
                     MessageBox.Show("找圆,载入参数错误");
                 }
             }
             if (str_name[i] == "IntersectionLL")
             {
                 Vision_step[i] = new UnitIntersectionLL(Vision_step); //str_parm
                 if (!Vision_step[i].LoadConfig(str_parm[i]))
                 {
                     MessageBox.Show("找交点,载入参数错误");
                 }
             }
             if (str_name[i] == "Calib9PointAbs")
             {
                 Vision_step[i] = new UnitCalib9PointAbs(Vision_step); //str_parm
                 if (!Vision_step[i].LoadConfig(str_parm[i]))
                 {
                     MessageBox.Show("9点标定,载入参数错误");
                 }
             }
             if (str_name[i] == "Random")
             {
                 Vision_step[i] = new UnitCalib9PointAbs(Vision_step); //str_parm
                 if (!Vision_step[i].LoadConfig(str_parm[i]))
                 {
                     MessageBox.Show("随机数据,载入参数错误");
                 }
             }
             if (str_name[i] == "ImageFiles")
             {
                 Vision_step[i] = new UnitCalib9PointAbs(Vision_step); //str_parm
                 if (!Vision_step[i].LoadConfig(str_parm[i]))
                 {
                     MessageBox.Show("图像列表,载入参数错误");
                 }
             }
             if (str_name[i] == null)
             {
                 break;
             }
         }
     }
 }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            step_num = treeView1.Nodes.Count;
            //要添加的节点名称为空,即文本框是否为空
            if (string.IsNullOrEmpty(textBox1.Text.Trim()))
            {
                MessageBox.Show("要添加的节点名称不能为空!");
                return;
            }
            //根据不同的选择,添加不同的节点配置
            TreeNode tmp;

            if (comboBox1.Text == "Find_model")
            {
                tmp = new TreeNode(textBox1.Text);
                treeView1.SelectedNode = tmp;
                treeView1.Nodes.Add(tmp);
                treeView1.SelectedNode.Nodes.Add("in_ModelID".Trim());
                treeView1.SelectedNode.Nodes.Add("out_row".Trim());
                treeView1.SelectedNode.Nodes.Add("out_col".Trim());
                treeView1.SelectedNode.Nodes.Add("out_phi".Trim());
                textBox1.Text         = "";
                Vision_step[step_num] = new UnitFindModel(Vision_step);
            }
            if (comboBox1.Text == "Find_line")
            {
                tmp = new TreeNode(textBox1.Text);
                treeView1.SelectedNode = tmp;
                treeView1.Nodes.Add(tmp);
                treeView1.SelectedNode.Nodes.Add("in_roi_row".Trim());
                treeView1.SelectedNode.Nodes.Add("in_roi_col".Trim());
                treeView1.SelectedNode.Nodes.Add("in_roi_phi".Trim());
                treeView1.SelectedNode.Nodes.Add("out_row1".Trim());
                treeView1.SelectedNode.Nodes.Add("out_col1".Trim());
                treeView1.SelectedNode.Nodes.Add("out_row2".Trim());
                treeView1.SelectedNode.Nodes.Add("out_col2".Trim());
                textBox1.Text         = "";
                Vision_step[step_num] = new UnitFindLine(Vision_step);
            }
            if (comboBox1.Text == "Find_circle")
            {
                tmp = new TreeNode(textBox1.Text);
                treeView1.SelectedNode = tmp;
                treeView1.Nodes.Add(tmp);
                treeView1.SelectedNode.Nodes.Add("in_roi_row".Trim());
                treeView1.SelectedNode.Nodes.Add("in_roi_col".Trim());
                treeView1.SelectedNode.Nodes.Add("in_roi_ridius".Trim());
                treeView1.SelectedNode.Nodes.Add("out_row".Trim());
                treeView1.SelectedNode.Nodes.Add("out_col".Trim());;
                treeView1.SelectedNode.Nodes.Add("out_ridius".Trim());
                textBox1.Text         = "";
                Vision_step[step_num] = new UnitFindCircle(Vision_step);
            }
            if (comboBox1.Text == "IntersectionLL")
            {
                tmp = new TreeNode(textBox1.Text);
                treeView1.SelectedNode = tmp;
                treeView1.Nodes.Add(tmp);
                treeView1.SelectedNode.Nodes.Add("in_line1_row1".Trim());
                treeView1.SelectedNode.Nodes.Add("in_line1_col1".Trim());
                treeView1.SelectedNode.Nodes.Add("in_line1_row2".Trim());
                treeView1.SelectedNode.Nodes.Add("in_line1_col2".Trim());
                treeView1.SelectedNode.Nodes.Add("in_line2_row1".Trim());
                treeView1.SelectedNode.Nodes.Add("in_line2_col1".Trim());
                treeView1.SelectedNode.Nodes.Add("in_line2_row2".Trim());
                treeView1.SelectedNode.Nodes.Add("in_line2_col2".Trim());
                treeView1.SelectedNode.Nodes.Add("out_row".Trim());
                treeView1.SelectedNode.Nodes.Add("out_col".Trim());
                textBox1.Text         = "";
                Vision_step[step_num] = new UnitIntersectionLL(Vision_step);
            }
            if (comboBox1.Text == "Calib9PointAbs")
            {
                tmp = new TreeNode(textBox1.Text);
                treeView1.SelectedNode = tmp;
                treeView1.Nodes.Add(tmp);

                //treeView1.SelectedNode.Nodes.Add("in_point_index".Trim());
                treeView1.SelectedNode.Nodes.Add("in_pixel_column".Trim());
                treeView1.SelectedNode.Nodes.Add("in_pixel_row".Trim());
                treeView1.SelectedNode.Nodes.Add("in_world_x".Trim());
                treeView1.SelectedNode.Nodes.Add("in_world_y".Trim());

                treeView1.SelectedNode.Nodes.Add("out_offset_x".Trim());
                treeView1.SelectedNode.Nodes.Add("out_offset_y".Trim());
                treeView1.SelectedNode.Nodes.Add("out_offset_angle".Trim());
                treeView1.SelectedNode.Nodes.Add("out_calib_result".Trim());

                textBox1.Text         = "";
                Vision_step[step_num] = new UnitCalib9PointAbs(Vision_step);
            }
            if (comboBox1.Text == "Random")
            {
                tmp = new TreeNode(textBox1.Text);
                treeView1.SelectedNode = tmp;
                treeView1.Nodes.Add(tmp);

                treeView1.SelectedNode.Nodes.Add("out_row".Trim());
                treeView1.SelectedNode.Nodes.Add("out_column".Trim());

                textBox1.Text         = "";
                Vision_step[step_num] = new UnitRandom(Vision_step);
            }
            if (comboBox1.Text == "ImageFiles")
            {
                tmp = new TreeNode(textBox1.Text);
                treeView1.SelectedNode = tmp;
                treeView1.Nodes.Add(tmp);

                treeView1.SelectedNode.Nodes.Add("out_image_path".Trim());

                textBox1.Text         = "";
                Vision_step[step_num] = new UnitImageFiles(Vision_step);
            }
            //添加根节点
            //treeView1.Nodes.Add(textBox1.Text.Trim());
        }
예제 #3
0
        void get_tree_name()
        {
            int tree_num = 0;

            foreach (TreeNode node in treeView1.Nodes)
            {
                //递归遍历节点
                IEnumerator ie           = node.Nodes.GetEnumerator();
                int         tree_son_num = 0;
                if (Vision_step[tree_num] == null)
                {
                    if (node.Text == "Find_model")
                    {
                        Vision_step[tree_num] = new UnitFindModel(Vision_step); //str_parm
                        if (!Vision_step[tree_num].LoadConfig(str_parm[tree_num]))
                        {
                            MessageBox.Show("模板载入错误,请选择正确的模板路径");
                        }
                    }
                    if (node.Text == "Find_line")
                    {
                        Vision_step[tree_num] = new UnitFindLine(Vision_step); //str_parm
                        if (!Vision_step[tree_num].LoadConfig(str_parm[tree_num]))
                        {
                            MessageBox.Show("找直线,载入参数错误");
                        }
                    }
                    if (node.Text == "Find_circle")
                    {
                        Vision_step[tree_num] = new UnitFindCircle(Vision_step); //str_parm
                        if (!Vision_step[tree_num].LoadConfig(str_parm[tree_num]))
                        {
                            MessageBox.Show("找圆,载入参数错误");
                        }
                    }
                    if (node.Text == "IntersectionLL")
                    {
                        Vision_step[tree_num] = new UnitIntersectionLL(Vision_step); //str_parm
                        if (!Vision_step[tree_num].LoadConfig(str_parm[tree_num]))
                        {
                            MessageBox.Show("找交点,载入参数错误");
                        }
                    }
                    if (node.Text == "Calib9PointAbs")
                    {
                        Vision_step[tree_num] = new UnitCalib9PointAbs(Vision_step); //str_parm
                        if (!Vision_step[tree_num].LoadConfig(str_parm[tree_num]))
                        {
                            MessageBox.Show("9点标定,载入参数错误");
                        }
                    }
                    if (node.Text == "Random")
                    {
                        Vision_step[tree_num] = new UnitRandom(Vision_step); //str_parm
                        if (!Vision_step[tree_num].LoadConfig(str_parm[tree_num]))
                        {
                            MessageBox.Show("随机数据,载入参数错误");
                        }
                    }
                    if (node.Text == "ImageFiles")
                    {
                        Vision_step[tree_num] = new UnitImageFiles(Vision_step); //str_parm
                        if (!Vision_step[tree_num].LoadConfig(str_parm[tree_num]))
                        {
                            MessageBox.Show("图像列表,载入参数错误");
                        }
                    }
                }
                while (ie.MoveNext())
                {
                    TreeNode ctn = (TreeNode)ie.Current;
                    Vision_step[tree_num].str_in_parm[tree_son_num] = ctn.Text;
                    tree_son_num++;
                }
                tree_num++;
            }
        }