Beispiel #1
0
        public static bool createCircleMetrology(paramCircle param, ref HTuple handle)
        {
            HTuple index;

            try
            {
                if (null != handle && 0 < handle.Length)
                {
                    HOperatorSet.ClearMetrologyModel(handle);
                }
                HOperatorSet.CreateMetrologyModel(out handle);
                HOperatorSet.AddMetrologyObjectCircleMeasure(handle, param.circleRow, param.circleColumn, param.circleRadius, param.MeasureLenght1, param.MeasureLenght2, 1, param.MeasureThreshold, "measure_transition", param.MeasureTransition, out index);
                HOperatorSet.SetMetrologyObjectParam(handle, "all", "num_measures", param.NumMeasures);
                HOperatorSet.SetMetrologyObjectParam(handle, "all", "num_instances", param.NumInstances);
                HOperatorSet.SetMetrologyObjectParam(handle, "all", "min_score", param.MinScore);

                if (0 < handle.Length)
                {
                    return(true);
                }
            }
            catch (HalconException ex)
            {
                string msg = ex.GetErrorMessage();
            }
            return(false);
        }
Beispiel #2
0
        private double ImageAlgorithmII(HObject ho_ResultImage)
        {
            // Local iconic variables

            HObject ho_ResultRegion = null;
            HObject ho_ResultConnectedRegions = null, ho_ResultSelectedRegions = null;
            HObject ho_ResultCircle = null, ho_ResultContour = null;

            // Local control variables

            HTuple hv_Width = null, hv_Height = null;
            HTuple hv_MetrologyHandle = null, hv_CircleRadiusTolerance = null;
            HTuple hv_NewRadius = null;
            HTuple hv_ResultArea = new HTuple(), hv_ResultRow = new HTuple();
            HTuple hv_ResultColumn = new HTuple(), hv_MetrologyCircleIndice = new HTuple();
            HTuple hv_CircleRadiusResult = new HTuple();

            // Initialize local and output iconic variables
            HOperatorSet.GenEmptyObj(out ho_ResultRegion);
            HOperatorSet.GenEmptyObj(out ho_ResultConnectedRegions);
            HOperatorSet.GenEmptyObj(out ho_ResultSelectedRegions);
            HOperatorSet.GenEmptyObj(out ho_ResultCircle);
            HOperatorSet.GenEmptyObj(out ho_ResultContour);

            HOperatorSet.GetImageSize(ho_ResultImage, out hv_Width, out hv_Height);

            //创建测量模型
            HOperatorSet.CreateMetrologyModel(out hv_MetrologyHandle);

            //设置测量对象图像大小
            HOperatorSet.SetMetrologyModelImageSize(hv_MetrologyHandle, hv_Width, hv_Height);
            //
            hv_CircleRadiusTolerance = 100;

            //圆半径
            hv_NewRadius = 324;


            //阈值图像
            ho_ResultRegion.Dispose();
            HOperatorSet.Threshold(ho_ResultImage, out ho_ResultRegion, 0, 60);

            //区域连通处理
            ho_ResultConnectedRegions.Dispose();
            HOperatorSet.Connection(ho_ResultRegion, out ho_ResultConnectedRegions);

            //根据面积和圆度来过滤想要的圆区域
            ho_ResultSelectedRegions.Dispose();
            HOperatorSet.SelectShape(ho_ResultConnectedRegions, out ho_ResultSelectedRegions,
                                     (new HTuple("area")).TupleConcat("roundness"), "and", (new HTuple(250000)).TupleConcat(
                                         0.9), (new HTuple(320000)).TupleConcat(1));

            //获取圆的中心坐标和面积
            HOperatorSet.AreaCenter(ho_ResultSelectedRegions, out hv_ResultArea, out hv_ResultRow, out hv_ResultColumn);


            HOperatorSet.SetColor(WindowID, "green");

            //设置区域的填充模式
            HOperatorSet.SetDraw(WindowID, "margin");

            //显示图像
            HOperatorSet.DispObj(ho_ResultImage, WindowID);

            if (hv_ResultArea.Length != 0)
            {
                //生成圆
                ho_ResultCircle.Dispose();
                HOperatorSet.GenCircle(out ho_ResultCircle, hv_ResultRow, hv_ResultColumn, hv_NewRadius);
                //添加圆到测量模型里
                HOperatorSet.AddMetrologyObjectCircleMeasure(hv_MetrologyHandle, hv_ResultRow,
                                                             hv_ResultColumn, hv_NewRadius, hv_CircleRadiusTolerance, 5, 1.5, 30, (new HTuple("measure_transition")).TupleConcat(
                                                                 "min_score"), (new HTuple("all")).TupleConcat(0.4), out hv_MetrologyCircleIndice);

                //测量并拟合几何形状
                HOperatorSet.ApplyMetrologyModel(ho_ResultImage, hv_MetrologyHandle);

                //获取测量模型里的测量轮廓
                ho_ResultContour.Dispose();
                HOperatorSet.GetMetrologyObjectResultContour(out ho_ResultContour, hv_MetrologyHandle, "all", "all", 1.5);

                //获取测量模型里的测量结果
                HOperatorSet.GetMetrologyObjectResult(hv_MetrologyHandle, hv_MetrologyCircleIndice, "all", "result_type", "radius", out hv_CircleRadiusResult);

                //显示测量轮廓
                HOperatorSet.DispObj(ho_ResultContour, WindowID);

                //设置文字显示位置
                HOperatorSet.SetTposition(WindowID, 0, 0);
                //* 在窗口指定位置输出文字信息
                HOperatorSet.WriteString(WindowID, "圆外径:" + hv_CircleRadiusResult);


                //清除测量模型
                HOperatorSet.ClearMetrologyModel(hv_MetrologyHandle);

                ho_ResultRegion.Dispose();
                ho_ResultConnectedRegions.Dispose();
                ho_ResultSelectedRegions.Dispose();
                ho_ResultCircle.Dispose();
                ho_ResultContour.Dispose();

                return(hv_CircleRadiusResult.D);
            }
            else
            {
                ho_ResultRegion.Dispose();
                ho_ResultConnectedRegions.Dispose();
                ho_ResultSelectedRegions.Dispose();
                ho_ResultCircle.Dispose();
                ho_ResultContour.Dispose();

                return(0);
            }
        }
Beispiel #3
0
    // Main procedure
    private void action()
    {
        // Local iconic variables

        HObject ho_Image, ho_ModelRegion, ho_TemplateImage;
        HObject ho_ModelContours, ho_RectifiedImage = null, ho_Regions = null;
        HObject ho_ConnectedRegions = null, ho_SelectedRegions = null;
        HObject ho_Contours = null, ho_Regions1 = null, ho_RegionLines = null;

        // Local control variables

        HTuple hv_ModelID = new HTuple(), hv_ModelRegionArea = new HTuple();
        HTuple hv_RefRow = new HTuple(), hv_RefColumn = new HTuple();
        HTuple hv_TestImages = new HTuple(), hv_T = new HTuple();
        HTuple hv_Row = new HTuple(), hv_Column = new HTuple();
        HTuple hv_Angle = new HTuple(), hv_Score = new HTuple();
        HTuple hv_I = new HTuple(), hv_RectificationHomMat2D = new HTuple();
        HTuple hv_Row1 = new HTuple(), hv_Column1 = new HTuple();
        HTuple hv_Radius = new HTuple(), hv_MetrologyHandle = new HTuple();
        HTuple hv_Width = new HTuple(), hv_Height = new HTuple();
        HTuple hv_Index = new HTuple(), hv_Row3 = new HTuple();
        HTuple hv_Column3 = new HTuple(), hv_Parameter = new HTuple();
        HTuple hv_Row2 = new HTuple(), hv_Column2 = new HTuple();
        HTuple hv_Radius1 = new HTuple(), hv_MetrologyHandle1 = new HTuple();
        HTuple hv_Index1 = new HTuple(), hv_Parameter1 = new HTuple();
        HTuple hv_SmlC = new HTuple(), hv_SR = new HTuple(), hv_SC = new HTuple();
        HTuple hv_BR = new HTuple(), hv_BC = new HTuple(), hv_Distance = new HTuple();

        // Initialize local and output iconic variables
        HOperatorSet.GenEmptyObj(out ho_Image);
        HOperatorSet.GenEmptyObj(out ho_ModelRegion);
        HOperatorSet.GenEmptyObj(out ho_TemplateImage);
        HOperatorSet.GenEmptyObj(out ho_ModelContours);
        HOperatorSet.GenEmptyObj(out ho_RectifiedImage);
        HOperatorSet.GenEmptyObj(out ho_Regions);
        HOperatorSet.GenEmptyObj(out ho_ConnectedRegions);
        HOperatorSet.GenEmptyObj(out ho_SelectedRegions);
        HOperatorSet.GenEmptyObj(out ho_Contours);
        HOperatorSet.GenEmptyObj(out ho_Regions1);
        HOperatorSet.GenEmptyObj(out ho_RegionLines);
        //
        //Matching 01: ************************************************
        //Matching 01: BEGIN of generated code for model initialization
        //Matching 01: ************************************************
        HOperatorSet.SetSystem("border_shape_models", "false");
        //
        //Matching 01: Obtain the model image
        ho_Image.Dispose();
        HOperatorSet.ReadImage(out ho_Image, "C:/Users/Chanru/Desktop/Class/bd/bd1.png");
        //
        //Matching 01: Build the ROI from basic regions
        ho_ModelRegion.Dispose();
        HOperatorSet.GenRectangle1(out ho_ModelRegion, 445.809, 637.592, 801.311, 1070.62);
        //
        //Matching 01: Reduce the model template
        ho_TemplateImage.Dispose();
        HOperatorSet.ReduceDomain(ho_Image, ho_ModelRegion, out ho_TemplateImage);
        //
        //Matching 01: Create the shape model
        hv_ModelID.Dispose();
        HOperatorSet.CreateShapeModel(ho_TemplateImage, 6, (new HTuple(0)).TupleRad()
                                      , (new HTuple(360)).TupleRad(), (new HTuple(0.4233)).TupleRad(), (new HTuple("point_reduction_medium")).TupleConcat(
                                          "no_pregeneration"), "use_polarity", ((new HTuple(10)).TupleConcat(14)).TupleConcat(
                                          35), 3, out hv_ModelID);
        //
        //Matching 01: Get the model contour for transforming it later into the image
        ho_ModelContours.Dispose();
        HOperatorSet.GetShapeModelContours(out ho_ModelContours, hv_ModelID, 1);
        //
        //Matching 01: Get the reference position
        hv_ModelRegionArea.Dispose(); hv_RefRow.Dispose(); hv_RefColumn.Dispose();
        HOperatorSet.AreaCenter(ho_ModelRegion, out hv_ModelRegionArea, out hv_RefRow,
                                out hv_RefColumn);
        //
        //Matching 01: END of generated code for model initialization
        //Matching 01:  * * * * * * * * * * * * * * * * * * * * * * *
        //Matching 01: BEGIN of generated code for model application
        //
        //Matching 01: Loop over all specified test images
        hv_TestImages.Dispose();
        hv_TestImages    = new HTuple();
        hv_TestImages[0] = "C:/Users/Chanru/Desktop/Class/bd/bd1.png";
        hv_TestImages[1] = "C:/Users/Chanru/Desktop/Class/bd/bd10.png";
        hv_TestImages[2] = "C:/Users/Chanru/Desktop/Class/bd/bd2.png";
        hv_TestImages[3] = "C:/Users/Chanru/Desktop/Class/bd/bd3.png";
        hv_TestImages[4] = "C:/Users/Chanru/Desktop/Class/bd/bd4.png";
        hv_TestImages[5] = "C:/Users/Chanru/Desktop/Class/bd/bd5.png";
        hv_TestImages[6] = "C:/Users/Chanru/Desktop/Class/bd/bd6.png";
        hv_TestImages[7] = "C:/Users/Chanru/Desktop/Class/bd/bd7.png";
        hv_TestImages[8] = "C:/Users/Chanru/Desktop/Class/bd/bd8.png";
        hv_TestImages[9] = "C:/Users/Chanru/Desktop/Class/bd/bd9.png";
        for (hv_T = 0; (int)hv_T <= 9; hv_T = (int)hv_T + 1)
        {
            //
            //Matching 01: Obtain the test image
            ho_Image.Dispose();
            HOperatorSet.ReadImage(out ho_Image, hv_TestImages.TupleSelect(hv_T));
            //
            //Matching 01: Find the model
            hv_Row.Dispose(); hv_Column.Dispose(); hv_Angle.Dispose(); hv_Score.Dispose();
            HOperatorSet.FindShapeModel(ho_Image, hv_ModelID, (new HTuple(0)).TupleRad()
                                        , (new HTuple(360)).TupleRad(), 0.5, 0, 0.5, "least_squares", (new HTuple(6)).TupleConcat(
                                            1), 0.75, out hv_Row, out hv_Column, out hv_Angle, out hv_Score);
            //
            //Matching 01: Code for rectification of the image
            //Matching 01: Calculate an inverse hom_mat2d for each of the matching results
            for (hv_I = 0; (int)hv_I <= (int)((new HTuple(hv_Score.TupleLength())) - 1); hv_I = (int)hv_I + 1)
            {
                hv_RectificationHomMat2D.Dispose();
                HOperatorSet.HomMat2dIdentity(out hv_RectificationHomMat2D);
                {
                    HTuple ExpTmpOutVar_0;
                    HOperatorSet.HomMat2dTranslate(hv_RectificationHomMat2D, hv_RefRow - (hv_Row.TupleSelect(
                                                                                              hv_I)), hv_RefColumn - (hv_Column.TupleSelect(hv_I)), out ExpTmpOutVar_0);
                    hv_RectificationHomMat2D.Dispose();
                    hv_RectificationHomMat2D = ExpTmpOutVar_0;
                }
                {
                    HTuple ExpTmpOutVar_0;
                    HOperatorSet.HomMat2dRotate(hv_RectificationHomMat2D, -(hv_Angle.TupleSelect(
                                                                                hv_I)), hv_RefRow, hv_RefColumn, out ExpTmpOutVar_0);
                    hv_RectificationHomMat2D.Dispose();
                    hv_RectificationHomMat2D = ExpTmpOutVar_0;
                }
                ho_RectifiedImage.Dispose();
                HOperatorSet.AffineTransImage(ho_Image, out ho_RectifiedImage, hv_RectificationHomMat2D,
                                              "constant", "false");
                //
                //Matching 01: Insert your code using the rectified image here

                ho_Regions.Dispose();
                HOperatorSet.Threshold(ho_Image, out ho_Regions, 99, 255);
                ho_ConnectedRegions.Dispose();
                HOperatorSet.Connection(ho_Regions, out ho_ConnectedRegions);
                ho_SelectedRegions.Dispose();
                HOperatorSet.SelectShape(ho_ConnectedRegions, out ho_SelectedRegions, "area",
                                         "and", 150, 800);

                hv_Row1.Dispose(); hv_Column1.Dispose(); hv_Radius.Dispose();
                HOperatorSet.SmallestCircle(ho_SelectedRegions, out hv_Row1, out hv_Column1,
                                            out hv_Radius);
                hv_MetrologyHandle.Dispose();
                HOperatorSet.CreateMetrologyModel(out hv_MetrologyHandle);
                hv_Width.Dispose(); hv_Height.Dispose();
                HOperatorSet.GetImageSize(ho_RectifiedImage, out hv_Width, out hv_Height);
                HOperatorSet.SetMetrologyModelImageSize(hv_MetrologyHandle, hv_Width, hv_Height);
                hv_Index.Dispose();
                HOperatorSet.AddMetrologyObjectCircleMeasure(hv_MetrologyHandle, hv_Row1,
                                                             hv_Column1, hv_Radius, 20, 5, 1, 30, "num_measures", 30, out hv_Index);
                HOperatorSet.ApplyMetrologyModel(ho_RectifiedImage, hv_MetrologyHandle);
                ho_Contours.Dispose(); hv_Row3.Dispose(); hv_Column3.Dispose();
                HOperatorSet.GetMetrologyObjectMeasures(out ho_Contours, hv_MetrologyHandle,
                                                        "all", "all", out hv_Row3, out hv_Column3);
                hv_Parameter.Dispose();
                HOperatorSet.GetMetrologyObjectResult(hv_MetrologyHandle, "all", "all", "result_type",
                                                      "all_param", out hv_Parameter);
                //*********

                ho_Regions1.Dispose();
                HOperatorSet.Threshold(ho_Image, out ho_Regions1, 22, 78);
                hv_Row2.Dispose(); hv_Column2.Dispose(); hv_Radius1.Dispose();
                HOperatorSet.SmallestCircle(ho_Regions1, out hv_Row2, out hv_Column2, out hv_Radius1);
                hv_MetrologyHandle1.Dispose();
                HOperatorSet.CreateMetrologyModel(out hv_MetrologyHandle1);
                HOperatorSet.SetMetrologyModelImageSize(hv_MetrologyHandle1, hv_Width, hv_Height);
                hv_Index1.Dispose();
                HOperatorSet.AddMetrologyObjectCircleMeasure(hv_MetrologyHandle1, hv_Row2,
                                                             hv_Column2, hv_Radius1, 20, 5, 1, 30, new HTuple(), new HTuple(), out hv_Index1);
                HOperatorSet.ApplyMetrologyModel(ho_RectifiedImage, hv_MetrologyHandle1);
                hv_Parameter1.Dispose();
                HOperatorSet.GetMetrologyObjectResult(hv_MetrologyHandle1, "all", "all",
                                                      "result_type", "all_param", out hv_Parameter1);
                //*******

                hv_SmlC.Dispose();
                using (HDevDisposeHelper dh = new HDevDisposeHelper())
                {
                    hv_SmlC = HTuple.TupleGenSequence(
                        0, (new HTuple(hv_Parameter.TupleLength())) - 1, 3);
                }
                hv_SR.Dispose();
                using (HDevDisposeHelper dh = new HDevDisposeHelper())
                {
                    hv_SR = hv_Parameter.TupleSelect(
                        hv_SmlC);
                }
                hv_SC.Dispose();
                using (HDevDisposeHelper dh = new HDevDisposeHelper())
                {
                    hv_SC = hv_Parameter.TupleSelect(
                        hv_SmlC + 1);
                }

                hv_BR.Dispose();
                using (HDevDisposeHelper dh = new HDevDisposeHelper())
                {
                    hv_BR = (hv_SR * 0) + (hv_Parameter1.TupleSelect(
                                               0));
                }
                hv_BC.Dispose();
                using (HDevDisposeHelper dh = new HDevDisposeHelper())
                {
                    hv_BC = (hv_SC * 0) + (hv_Parameter1.TupleSelect(
                                               1));
                }


                hv_Distance.Dispose();
                HOperatorSet.DistancePp(hv_SR, hv_SC, hv_BR, hv_BC, out hv_Distance);

                if (HDevWindowStack.IsOpen())
                {
                    HOperatorSet.DispObj(ho_RectifiedImage, HDevWindowStack.GetActive());
                }
                ho_RegionLines.Dispose();
                HOperatorSet.GenRegionLine(out ho_RegionLines, hv_SR, hv_SC, hv_BR, hv_BC);
                // stop(...); only in hdevelop
            }
        }
        //
        //Matching 01: *******************************************
        //Matching 01: END of generated code for model application
        //Matching 01: *******************************************
        //

        ho_Image.Dispose();
        ho_ModelRegion.Dispose();
        ho_TemplateImage.Dispose();
        ho_ModelContours.Dispose();
        ho_RectifiedImage.Dispose();
        ho_Regions.Dispose();
        ho_ConnectedRegions.Dispose();
        ho_SelectedRegions.Dispose();
        ho_Contours.Dispose();
        ho_Regions1.Dispose();
        ho_RegionLines.Dispose();

        hv_ModelID.Dispose();
        hv_ModelRegionArea.Dispose();
        hv_RefRow.Dispose();
        hv_RefColumn.Dispose();
        hv_TestImages.Dispose();
        hv_T.Dispose();
        hv_Row.Dispose();
        hv_Column.Dispose();
        hv_Angle.Dispose();
        hv_Score.Dispose();
        hv_I.Dispose();
        hv_RectificationHomMat2D.Dispose();
        hv_Row1.Dispose();
        hv_Column1.Dispose();
        hv_Radius.Dispose();
        hv_MetrologyHandle.Dispose();
        hv_Width.Dispose();
        hv_Height.Dispose();
        hv_Index.Dispose();
        hv_Row3.Dispose();
        hv_Column3.Dispose();
        hv_Parameter.Dispose();
        hv_Row2.Dispose();
        hv_Column2.Dispose();
        hv_Radius1.Dispose();
        hv_MetrologyHandle1.Dispose();
        hv_Index1.Dispose();
        hv_Parameter1.Dispose();
        hv_SmlC.Dispose();
        hv_SR.Dispose();
        hv_SC.Dispose();
        hv_BR.Dispose();
        hv_BC.Dispose();
        hv_Distance.Dispose();
    }
Beispiel #4
0
        public bool Find_halcon_circle(ExecuteBuffer _executeBuffer, HWndCtrl hWndCtrl, 模板GVName_halcon Model_result, Dictionary <int, PointName> Point_temp_result, out string result_info, out HTuple Row, out HTuple Column, out HTuple Radius, bool show_info)
        {
            HTuple MetrologyHandle;
            HTuple pic_wid, pic_height;

            Row         = new HTuple();
            Column      = new HTuple();
            Radius      = new HTuple();
            result_info = "";
            HOperatorSet.CreateMetrologyModel(out MetrologyHandle);
            if (!_executeBuffer.imageBuffer.ContainsKey(this.Threshold_image.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("查找圆: 输入图像已经不存在,请重置设置输入图像");
                result_info = " 查找圆: 输入图像已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Threshold_image.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("查找圆: image参数为空或者未赋值");
                result_info = " 查找圆: 输入图像已经不存在,请重置设置输入图像";
                return(false);
            }

            /*
             * if (xrow == null || xcol == null || xradius == null)
             * {
             *  MessageBox.Show("查找圆: 未确定圆位置");
             *  result_info = " 查找圆: 未确定圆位置";
             *  return false;
             * }*/
            HObject imagein = _executeBuffer.imageBuffer[this.Threshold_image.SelectedItem.ToString() + ".img"];

            HOperatorSet.GetImageSize(imagein, out pic_wid, out pic_height);
            HOperatorSet.SetMetrologyModelImageSize(MetrologyHandle, pic_wid, pic_height);
            HTuple Index;

            HTuple trow, tcol, tradius;

            if (this.checkBox_circle.Checked)
            {
                if (xrow == null || xcol == null || xradius == null)
                {
                    MessageBox.Show("查找直线:未确认线位置");
                    result_info = " 查找直线: 未确认线位置";
                    return(false);
                }
                else if (xrow.D == 0 && xcol.D == 0 && xradius.D == 0)
                {
                    MessageBox.Show("查找直线:未确认线位置");
                    result_info = " 查找直线: 未确认线位置";
                    return(false);
                }
                else
                {
                    trow    = xrow;
                    tcol    = xcol;
                    tradius = xradius;
                }
            }
            else
            {
                tradius = Convert.ToDouble(this.textBox_radius.Text);
                if (this.cbb_source1.SelectedIndex == 0)
                {
                    if (Model_result == null)
                    {
                        MessageBox.Show("查找圆:匹配列表为空,请设置");
                        result_info = " 查找圆: 匹配列表为空,请设置";
                        return(false);
                    }
                    if (Model_result.点X.TupleLength() < 1)
                    {
                        MessageBox.Show("查找圆:匹配列表为空,请设置");
                        result_info = " 查找圆: 匹配列表为空,请设置";
                        return(false);
                    }
                    trow = Model_result.点Y[0];
                    tcol = Model_result.点X[0];
                }
                else
                {
                    int number1 = Convert.ToInt32(this.tb_value1.Text);
                    if (!Point_temp_result.ContainsKey(number1))
                    {
                        MessageBox.Show("查找圆:全局列表点无此点,请设置");
                        result_info = " 查找圆: 全局列表无此点,请设置";
                        return(false);
                    }
                    else
                    {
                        trow = Point_temp_result[number1].点Y;
                        tcol = Point_temp_result[number1].点X;
                    }
                }
            }



            HOperatorSet.AddMetrologyObjectCircleMeasure(MetrologyHandle, trow, tcol, tradius, Convert.ToInt32(this.measure_length1.Text.ToString()), Convert.ToInt32(this.measure_length2.Text.ToString()), 1, Convert.ToInt32(this.measure_threshold.Text.ToString()), new HTuple(), new HTuple(), out Index);
            //    HOperatorSet.SetMetrologyObjectParam(MetrologyHandle,"all","measure_transition","negative");
            HOperatorSet.SetMetrologyObjectParam(MetrologyHandle, "all", "measure_transition", this.cbb_transition.SelectedItem.ToString());
            HOperatorSet.SetMetrologyObjectParam(MetrologyHandle, "all", "measure_select", this.cbb_measure_select.SelectedItem.ToString());
            HOperatorSet.SetMetrologyObjectParam(MetrologyHandle, "all", "num_measures", Convert.ToInt32(this.num_measure.Text.ToString()));
            HOperatorSet.SetMetrologyObjectParam(MetrologyHandle, "all", "num_instances", 40);
            HOperatorSet.SetMetrologyObjectParam(MetrologyHandle, "all", "measure_sigma", 1);
            HOperatorSet.SetMetrologyObjectParam(MetrologyHandle, "all", "measure_interpolation", "bicubic");
            //HOperatorSet.SetMetrologyObjectParam(MetrologyHandle,"all","measure_select","all");
            HOperatorSet.SetMetrologyObjectParam(MetrologyHandle, "all", "min_score", 0.4);
            HOperatorSet.ApplyMetrologyModel(imagein, MetrologyHandle);
            HObject Contours, Cross;

            HOperatorSet.GetMetrologyObjectMeasures(out Contours, MetrologyHandle, "all", "all", out Row, out Column);
            HOperatorSet.GenCrossContourXld(out Cross, Row, Column, 6, 0.785398);
            HTuple hv_Parameter = null;

            //得到线的起点和终点坐标并显示出来
            HOperatorSet.GetMetrologyObjectResult(MetrologyHandle, "all", "all", "result_type",
                                                  "all_param", out hv_Parameter);
            if (hv_Parameter.TupleLength() == 0)
            {
                result_info = " 查找圆: 在指定位置,找圆失败";
                MessageBox.Show("未找到圆");
                return(false);
            }
            int Circle_number = hv_Parameter.TupleLength() / 3;

            double[] Row_out    = new double[Circle_number];
            double[] Column_out = new double[Circle_number];
            double[] Radius_out = new double[Circle_number];
            for (int i = 0; i < Circle_number; i++)
            {
                Row_out[i]    = hv_Parameter[i * 3 + 1].D;
                Column_out[i] = hv_Parameter[i * 3].D;
                Radius_out[i] = hv_Parameter[i * 3 + 2].D;
            }
            Row    = (HTuple)Row_out;
            Column = (HTuple)Column_out;
            Radius = (HTuple)Radius_out;

            HObject ho_Contour;

            HOperatorSet.GenEmptyObj(out ho_Contour);
            ho_Contour.Dispose();
            HOperatorSet.GetMetrologyObjectResultContour(out ho_Contour, MetrologyHandle,
                                                         "all", "all", 1.5);


            HOperatorSet.ClearMetrologyModel(MetrologyHandle);
            if (show_info)
            {
                hWndCtrl.changeGraphicSettings(GraphicsContext.GC_COLOR, this.comboBox1.SelectedItem.ToString());
                hWndCtrl.addIconicVar(Cross);
                hWndCtrl.addIconicVar(Contours);
            }
            hWndCtrl.changeGraphicSettings(GraphicsContext.GC_COLOR, this.comboBox1.SelectedItem.ToString());
            hWndCtrl.addIconicVar(ho_Contour);
            hWndCtrl.repaint();
            return(true);
        }