Esempio n. 1
0
 private void GetProductPixelPosBtn_Click(object sender, EventArgs e)  //计算示教产品的像素的坐标,并保存到配置文件
 {
     this.GetProductPixelPosBtn.Enabled   = false;
     this.ProductPixelPosTeachBtn.Enabled = true;
     try
     {
         LocalResult  localResult = new LocalResult();
         LocalManager myLocal     = new LocalManager();
         //1.0设置定位模式
         myLocal.SetLocalModel(LocalPara0.localSetting.localModel);
         //2.0设置定位参数
         myLocal.SetParam(CurImg, LocalPara0);
         //3.执行定位
         myLocal.doLocal();
         localResult = myLocal.GetResult();
         this.LocalPara0.localSetting.TeachImgLocal = new St_VectorAngle(localResult.row, localResult.col, localResult.angle);
         view1.ResetWindow();
         view1.AddImage(CurImg.CopyObj(1, -1));
         view1.SetDraw("blue", "margin");
         view1.AddViewObject(localResult.ShowContour.CopyObj(1, -1));
         view1.Repaint();
         this.ProductPixelPosTbx.Text = "Col:" + localResult.col.ToString("f2") + "   Row:" + localResult.row.ToString("f2") +
                                        "   Angle:" + localResult.angle.ToString("f2");
     }
     catch
     { }
 }
Esempio n. 2
0
 private void StartCaliBtn_Click(object sender, EventArgs e)
 {
     System.Threading.Tasks.Task.Factory.StartNew(new Action(() => {
         try {
             #region
             List <Point2Db> PixelPtList = new List <Point2Db>();//像素点的坐标集合
             LocalPara NowLocalPara      = TeachCaliPara.localPara;
             RectangleF RectFi           = new RectangleF();
             LocalManager MyLocal        = new LocalManager(); //定位类初始化
             LocalResult MyResult        = new LocalResult();
             Point2Db Pt         = new Point2Db();
             HObject CaliContour = new HObject();
             HOperatorSet.GenEmptyObj(out CaliContour);
             if (GrabedImg == null)
             {
                 MessageBox.Show(" 请先加载一张图片");
                 return;
             }
             for (int i = 0; i < TeachCaliPara.ListRectRegion.Count; i++)
             {
                 RectFi = TeachCaliPara.ListRectRegion[i];
                 TeachCaliPara.localPara.localSetting.SearchAreaX  = (int)RectFi.X;
                 TeachCaliPara.localPara.localSetting.SearchAreaY  = (int)RectFi.Y;
                 TeachCaliPara.localPara.localSetting.SearchWidth  = (int)RectFi.Width;
                 TeachCaliPara.localPara.localSetting.SearchHeight = (int)RectFi.Height;
                 MyLocal.SetLocalModel(TeachCaliPara.localPara.localSetting.localModel);
                 MyLocal.SetParam(GrabedImg, TeachCaliPara.localPara);
                 MyLocal.doLocal();
                 MyResult    = MyLocal.GetResult();
                 CaliContour = CaliContour.ConcatObj(MyResult.ShowContour);
                 //GetCaliMarkPts1(GrabedImg, MinGray, MaxGray, MarkR, out ContourU, out ListMarkCenterI);  //找出Mark点
                 HObject CenterContour = new HObject();
                 HOperatorSet.GenCrossContourXld(out CenterContour, MyResult.row, MyResult.col, 50, 0);  //生成找到的圆心轮廓
                 HOperatorSet.ConcatObj(CaliContour, CenterContour, out CaliContour);
                 Pt.Col = MyResult.col;
                 MyVisionBase.AdjImgRow(GrabedImg, ref MyResult.row);
                 Pt.Row = MyResult.row;
                 PixelPtList.Add(Pt);
                 view1.Refresh();
                 view1.AddViewImage(GrabedImg);
                 view1.AddViewObject(CaliContour);
                 view1.Repaint();
             }
             #endregion
             bool IsTrue = true;
             MyVisionBase.VectorToHomMat(PixelPtList, TeachCaliPara.ListPt2D, out TeachCaliPara.HomMat, out IsTrue);
         }
         catch
         { }
     }));
 }
Esempio n. 3
0
        private void btnRecheckTest_Click(object sender, EventArgs e)
        {
            btnRecheckTest.Enabled = false;
            if (!GrabedImg.IsInitialized())
            {
                MessageBox.Show("请先加载图片");
                return;
            }
            Task.Factory.StartNew(new Action(() => {
                HObject DetectContours = new HObject(), BadRegions = new HObject();
                bool IsOK = true;
                St_InspectImageSetting tmpInspectParam = new St_InspectImageSetting(true);
                tmpInspectParam          = InspectImageSetting;
                LocalManager MyLocalCtrl = new LocalManager();
                MyLocalCtrl.SetLocalModel(TeachLocalPara.localSetting.localModel);
                this.TeachLocalPara.LineCirRectInspParam = InspectImageSetting;
                MyLocalCtrl.SetParam(GrabedImg, TeachLocalPara);
                MyLocalCtrl.doLocal();
                LineCircRectRlt MyLineCircRectInspRlt = new LineCircRectRlt();
                MyLineCircRectInspRlt = (LineCircRectRlt)MyLocalCtrl.GetResult();
                this.myView.roiController.reset();
                this.myView.ResetWindow();
                this.myView.AddImage(GrabedImg);
                Thread.Sleep(200);
                this.myView.SetDraw("green");
                this.myView.AddViewObject(MyLineCircRectInspRlt.DetectContour);
                this.myView.AddViewObject(MyLineCircRectInspRlt.ShowContour);
                this.myView.SetDraw("red");
                this.myView.AddViewObject(MyLineCircRectInspRlt.NgContour);
                this.myView.Repaint();
                if (MyLineCircRectInspRlt.IsOk)
                {
                    this.myView.SetString(20, 50, "green", "复检OK");
                }
                else
                {
                    this.myView.SetString(100, 100, "Red", "复检NG");
                }
            }));

            Thread.Sleep(500);
            btnRecheckTest.Enabled = true;
        }
Esempio n. 4
0
        private void TryDebugBtn_Click(object sender, EventArgs e)
        {
            txtFindTime.Clear();
            Stopwatch sw = new Stopwatch();

            sw.Start();
            TeachLoclPara.Blobs = TeachBlobLocaltPara;
            LocalManager LocalCtrl = new LocalManager();

            LocalCtrl.SetLocalModel(TeachLoclPara.localSetting.localModel);
            LocalCtrl.SetParam(GrabedImg, TeachLoclPara);
            LocalCtrl.doLocal();
            sw.Stop();
            LocalResult MyRlt = new LocalResult();

            MyRlt = LocalCtrl.GetResult();
            BlobLocalRlt BlobRlt = (BlobLocalRlt)MyRlt;

            if (GrabedImg != null && GrabedImg.IsInitialized())
            {
                view1.ResetView();
                view1.AddViewImage(GrabedImg);
                view1.SetDraw("blue");
                view1.AddViewObject(MyRlt.ShowContour);
                view1.Repaint();
            }
            if (BlobRlt.ListWid != null && BlobRlt.ListWid.Count > 0)
            {
                double X = BlobRlt.ListCol[0] * TeachLoclPara.Blobs.PixelSize;
                double H = BlobRlt.ListRow[0] * TeachLoclPara.Blobs.PixelSize;
                view1.SetString(100, 150, "red", "坐标X(mm):" + X.ToString() + "     Y(mm):" + H.ToString());
                if (BlobRlt.ListWid.Count > 1)
                {
                    X = BlobRlt.ListWid[1] * TeachLoclPara.Blobs.PixelSize;
                    H = BlobRlt.ListHei[1] * TeachLoclPara.Blobs.PixelSize;
                    view1.SetString(100, 750, "blue", "高度(mm):" + H.ToString());
                }
            }
            txtFindTime.Text = sw.ElapsedMilliseconds.ToString();
        }
Esempio n. 5
0
        /// <summary>
        /// 获取九点标定的九个世界坐标点,九个像素坐标点
        /// </summary>
        /// <param name="StartPt">示教起始点</param>
        /// <param name="EndPt">示教终点</param>
        /// <param name="IsCameraMovingWithAxisX"></param>
        /// <param name="IsCameraMovingWithAxisY"></param>
        /// <param name="PixelPosP"></param>
        /// <param name="MotionPosW"></param>
        /// <returns></returns>
        public bool GetHandEyeCaliPt(Point2Db StartPt, Point2Db EndPt, bool IsCameraMovingWithAxisX, bool IsCameraMovingWithAxisY,
                                     out List <Point2Db> PixelPosP, out List <Point2Db> MotionPosW)
        {
            int StepCount = 3;

            PixelPosP  = new List <Point2Db>();
            MotionPosW = new List <Point2Db>();
            Point2Db      startPt = new Point2Db(Math.Min(StartPt.Col, EndPt.Col), Math.Min(StartPt.Row, EndPt.Row));
            Point2Db      endPt = new Point2Db(Math.Max(StartPt.Col, EndPt.Col), Math.Max(StartPt.Row, EndPt.Row));
            double        recWidth = endPt.Col - startPt.Col;
            double        recHeight = endPt.Row - startPt.Row;
            double        stepX = recWidth / (StepCount - 1);
            double        stepY = recHeight / (StepCount - 1);
            List <double> supposeX = new List <double>(), supposeY = new List <double>();
            List <double> currentX = new List <double>(), currentY = new List <double>();
            LocalManager  MyLocal  = new LocalManager(); //定位类初始化
            LocalResult   MyResult = new LocalResult();

            MyLocal.SetLocalModel(TeachCaliPara.localPara.localSetting.localModel);
            HOperatorSet.GenEmptyObj(out CaliContour);
            for (int row = 0; row <= StepCount - 1; row += 1)
            {
                for (int col = 0; col <= StepCount - 1; col += 1)
                {
                    Point2Db movePt     = new Point2Db();                   //九点标定时,相机移动到一个点,然后开始拍照
                    Point2Db CaliMovePt = new Point2Db();                   //九点标定时的点,坐下角为第一个点,右上角为第九个点
                    if (IsCameraMovingWithAxisX && IsCameraMovingWithAxisY) //相机跟随XY周移动
                    {
                        movePt = new Point2Db(startPt.Col + (StepCount - 1 - col) * stepX, startPt.Row + (StepCount - 1 - row) * stepY);
                    }
                    else if ((IsCameraMovingWithAxisX) && (!IsCameraMovingWithAxisY))    //相机跟随X轴移动
                    {
                        movePt = new Point2Db(startPt.Col + (StepCount - 1 - col) * stepX, startPt.Row + row * stepY);
                    }
                    else if ((!IsCameraMovingWithAxisX) && IsCameraMovingWithAxisY)      //相机跟随Y轴移动
                    {
                        movePt = new Point2Db(startPt.Col + col * stepX, startPt.Row + (StepCount - 1 - row) * stepY);
                    }
                    else if ((!IsCameraMovingWithAxisX) && (!IsCameraMovingWithAxisY))   //相机固定
                    {
                        movePt = new Point2Db(startPt.Col + col * stepX, startPt.Row + row * stepY);
                    }
                    CaliMovePt = new Point2Db(startPt.Col + col * stepX, startPt.Row + row * stepY);
                    // 控制平台移动到目标位置
                    if (!MotionManager.Instance.SetCoordiPos(movePt.Col, movePt.Row, TeachCaliPara.EndCaliPt.angle))
                    {
                        MessageBox.Show("X Y轴运动失败!");
                        return(false);
                    }
                    Thread.Sleep(2000);
                    GrabedImg = new HObject();
                    CameraCtrl.Instance.GrabImg(TeachCaliPara.cam, out GrabedImg);  //相机拍照抓取图片
                    Point2Db Pt = new Point2Db();
                    if (GrabedImg.IsInitialized())
                    {
                        MyLocal.SetParam(GrabedImg, TeachCaliPara.localPara); //设置定位参数
                        MyLocal.doLocal();                                    //执行定位算法
                        MyResult = MyLocal.GetResult();                       //获取定位结果
                        view1.ResetView();
                        CaliContour = CaliContour.ConcatObj(MyResult.ShowContour);
                        view1.AddViewImage(GrabedImg);
                        view1.AddViewObject(MyResult.ShowContour);
                        //GetCaliMarkPts1(GrabedImg, MinGray, MaxGray, MarkR, out ContourU, out ListMarkCenterI);  //找出Mark点
                        HObject CenterContour = new HObject();
                        HOperatorSet.GenCrossContourXld(out CenterContour, MyResult.row, MyResult.col, 50, 0);  //生成找到的圆心轮廓
                        HOperatorSet.ConcatObj(CaliContour, CenterContour, out CaliContour);
                        view1.AddViewObject(CaliContour);
                        view1.Repaint();
                        Pt.Col = MyResult.col;
                        Pt.Row = MyResult.row;
                        PixelPosP.Add(Pt);
                        MotionPosW.Add(CaliMovePt);
                    }
                    else
                    {
                        MessageBox.Show("采集图片失败");
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 6
0
        public virtual void Do()
        {
            //1.打开光源
            FileLib.Logger.Pop("  打开光源:", false, "运行日志");
            foreach (LightPara item in MyVisionPara.camLightPara.lightPara)
            {
                LightCtrlManager.Instance.SetLightValue(item);
            }
            //2.采图
            if (GrabImg != null)
            {
                GrabImg.Dispose();
            }
            FileLib.Logger.Pop("  开始采图:", false, "运行日志");
            CameraCtrl.Instance.SetExpos(MyVisionPara.camLightPara.CamName, MyVisionPara.camLightPara.Exposure);
            //10.获取当前的机械坐标
            double X = 0, Y = 0, Z = 0, Theta = 0;

            if (CaliParaManager.Instance.GetCaliMode(MyVisionPara.localPara.localSetting.CoordiCam) == CaliModelEnum.HandEyeCali)
            {
                MotionManager.Instance.SetCoordi(MyVisionPara.localPara.localSetting.TeachCoordi);
                FileLib.Logger.Pop("当前的坐标系为:" + MyVisionPara.localPara.localSetting.TeachCoordi.ToString(), false, "运行日志");
                MotionManager.Instance.GetCoordiPos(out X, out Y, out Z, out Theta);
                FileLib.Logger.Pop("当前的机械坐标", false, "运行日志");
                FileLib.Logger.Pop("X:" + X.ToString("f4") + "  Y:" + Y.ToString("f4") +
                                   "  Z:" + Z.ToString("f4") + "  Theta:" + Theta.ToString("f4"), false, "运行日志");
            }

            if (CameraCtrl.Instance.GrabImg(MyVisionPara.camLightPara.CamName, out GrabImg))
            {
                LD.Logic.PlcHandle.Instance.WriteValue(LD.Common.PlcDevice.ArtTestCameraGrabed, 1); //拍照OK
                FileLib.Logger.Pop("  采图OK:", false, "运行日志");
            }
            else
            {
                LD.Logic.PlcHandle.Instance.WriteValue(LD.Common.PlcDevice.ArtTestCameraGrabed, 2); //拍照NG
                FileLib.Logger.Pop("  采图NG:", false, "运行日志");
            }
            ViewControl view1 = DisplaySystem.GetViewControl(CameraTest.UpCam1);

            if (MyVisionPara.camLightPara.CamName == CameraEnum.Cam0)
            {
                view1 = DisplaySystem.GetViewControl(CameraTest.UpCam1);
            }
            if (MyVisionPara.camLightPara.CamName == CameraEnum.Cam1)
            {
                view1 = DisplaySystem.GetViewControl(CameraTest.UpCam2);
            }
            if (MyVisionPara.camLightPara.CamName == CameraEnum.Cam2)
            {
                view1 = DisplaySystem.GetViewControl(CameraTest.UpCam3);
            }
            view1.ResetView();
            view1.Refresh();
            view1.AddViewImage(GrabImg);
            view1.Repaint();
            MyVisionBase.SaveImg(GrabImg, "扎针对位图片");
            //3.关闭光源
            LightCtrlManager.Instance.SetAllLightTo0();
            FileLib.Logger.Pop("  关闭光源:", false, "运行日志");
            //4.0设置定位模式
            MyLocal.SetLocalModel(MyVisionPara.localPara.localSetting.localModel);
            //5.0设置定位参数
            MyLocal.SetParam(GrabImg, MyVisionPara.localPara);
            //6.执行定位
            try
            {
                MyLocal.doLocal();
                //7.告诉PLC定位结果完成
                if (MyVisionPara.ProjectVisionItem == ProjectVisionEnum.ProjectVision1)
                {
                    FileLib.Logger.Pop(" 扎针右侧视觉定位完成,先不发给PLC信号,等计算出偏移量后,将信号发给PLC:", false, "运行日志");
                }
                else
                {
                    LD.Logic.PlcHandle.Instance.WriteValue(LD.Common.PlcDevice.ArtTestCamLocalResult, 1); //告诉PLC定位结果OK
                    FileLib.Logger.Pop("  告诉PLC拍照结果OK(告诉PLC定位结果OK):", false, "运行日志");
                }
            }
            catch (Exception e0)
            {
                Logger.PopError1(e0, false, "视觉错误日志");
                LD.Logic.PlcHandle.Instance.WriteValue(LD.Common.PlcDevice.ArtTestCamLocalResult, 2); //告诉PLC定位结果NG
                FileLib.Logger.Pop("  告诉PLC拍照结果OK(告诉PLC定位结果NG):", false, "运行日志");
                MyLocalResult.IsLocalOk = false;
            }


            MyLocalResult = MyLocal.GetResult();
            view1.AddViewObject(MyLocalResult.ShowContour);
            //结合标定坐标计算出产品的实际位置
            //8.获取标定矩阵
            MyHomMat2D HomMat = new MyHomMat2D();

            HomMat = CaliParaManager.Instance.GetHomMAT(MyVisionPara.localPara.localSetting.CoordiCam); //获取示教的标定矩阵
            FileLib.Logger.Pop("  获取示教的标定矩阵:" + MyVisionPara.localPara.localSetting.CoordiCam.ToString(), false, "运行日志");
            FileLib.Logger.Pop(HomMat.ToString(), false, "运行日志");
            HalconDotNet.HTuple HHomMat = new HalconDotNet.HTuple();
            //标定矩阵的转换
            MyVisionBase.MyHomMatToHalcon(HomMat, out HHomMat);
            //9.图像坐标系的原点由左上角变到左下角
            MyVisionBase.AdjImgRow(GrabImg, ref MyLocalResult.row);
            St_VectorAngle PixelVector = new St_VectorAngle(MyLocalResult.row, MyLocalResult.col, MyLocalResult.angle);

            FileLib.Logger.Pop("当前的像素坐标", false, "运行日志");
            FileLib.Logger.Pop("Col:" + MyLocalResult.col.ToString("f4") + "  Row:" + MyLocalResult.row.ToString("f4") +
                               "  Theta:" + MyLocalResult.angle.ToString("f4"), false, "运行日志");

            CaliValue CaliPara = CaliParaManager.Instance.GetCaliValue(MyVisionPara.localPara.localSetting.CoordiCam);

            VectorAngle GrabPos = new VectorAngle(X, Y, Theta);

            //9 计算出当前产品距离旋转中心的坐标
            EyeToHandPos.TransEyeToHandPos(PixelVector, CaliPara, GrabPos, out PosToRot);
            //10计算出示教产品到旋转中心的坐标
            St_VectorAngle TeachPixelPos = new St_VectorAngle(MyLocalResult.TeachRow, MyLocalResult.TeachCol, MyLocalResult.TeachAngle);
            VectorAngle    TeachGrabPos  = new VectorAngle(MyLocalResult.TeachX, MyLocalResult.TeachY, MyLocalResult.TeachTheta);

            MyVisionBase.AdjImgRow(GrabImg, ref TeachPixelPos.Row);
            EyeToHandPos.TransEyeToHandPos(TeachPixelPos, CaliPara, TeachGrabPos, out TeachPosToRot);
            view1.Repaint();
            view1.SetString(100, 100, "red", "PosToRot: " + "   X: " + PosToRot.Col.ToString("f3") + "   Y: " +
                            PosToRot.Row.ToString("f3") + "   Theta: " + PosToRot.Angle.ToString("f3"));
            MyLocalResult.PosToRot      = PosToRot;
            MyLocalResult.TeachPosToRot = TeachPosToRot;
            FileLib.Logger.Pop("示教的产品相对旋转中心的偏移量", false, "运行日志");

            FileLib.Logger.Pop("PosToRot: " + "   X: " + PosToRot.Col.ToString("f3") + "   Y: " +
                               PosToRot.Row.ToString("f3") + "   Theta: " + PosToRot.Angle.ToString("f3"), false, "运行日志");

            FileLib.Logger.Pop("当前的产品相对旋转中心的偏移量", false, "运行日志");
            FileLib.Logger.Pop("PosToRot: " + "   X: " + TeachPosToRot.Col.ToString("f3") + "   Y: " +
                               TeachPosToRot.Row.ToString("f3") + "   Theta: " + TeachPosToRot.Angle.ToString("f3"), false, "运行日志");
            //11.计算出X Y Theta的补偿量,

            ////图像坐标转到机械坐标系
            //MyVisionBase.AffineTransPt(MyLocalResult.col, MyLocalResult.row, HHomMat, out MyLocalResult.x, out MyLocalResult.y);
            ////
            //MyVisionBase.AffineTransPt(MyLocalResult.TeachCol, MyLocalResult.TeachRow, HHomMat, out MyLocalResult.TeachX, out MyLocalResult.TeachY);
        }
Esempio n. 7
0
        private void CaliRotCenterBtn_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("是否示开始旋转中心标定?", "提示", MessageBoxButtons.YesNo);

            if (dr == DialogResult.No)
            {
                return;
            }
            System.Threading.Tasks.Task.Factory.StartNew(new Action(() => {
                ListMarkCenterU      = new List <Point2Db>();
                HObject GrabedImg    = new HObject();
                LocalManager MyLocal = new LocalManager(); //定位类初始化
                LocalResult MyResult = new LocalResult();
                MyLocal.SetLocalModel(TeachCaliPara.localPara.localSetting.localModel);
                HOperatorSet.GenEmptyObj(out FindCenterCont);
                //旋转一个角度拍一次照片,用定位的点拟合圆,计算出0度时标定点到旋转中心的偏移量
                for (int i = 0; i < TeachCaliPara.AngleStep; i++)
                {
                    if (MotionManager.Instance.SetCoordiPos(TeachCaliPara.StartRotPt.x, TeachCaliPara.StartRotPt.y, TeachCaliPara.StartRotPt.angle
                                                            + TeachCaliPara.AngleRange / TeachCaliPara.AngleStep * i))
                    {
                        if (GrabedImg != null)
                        {
                            GrabedImg.Dispose();
                        }
                        CameraCtrl.Instance.GrabImg(TeachCaliPara.cam, out GrabedImg); //采集图像
                        MyResult = new LocalResult();
                        MyLocal.SetParam(GrabedImg, TeachCaliPara.localPara);
                        MyLocal.doLocal();
                        MyResult = MyLocal.GetResult();
                        if (!MyResult.IsLocalOk)
                        {
                            MessageBox.Show("定位失败");
                            return;
                        }
                        view1.ResetView();
                        view1.Refresh();
                        view1.AddViewImage(GrabedImg);
                        view1.AddViewObject(MyResult.ShowContour);
                        view1.Repaint();
                        //view1.Refresh();
                        //this.Refresh();
                        Thread.Sleep(50);
                        Point2Db NowPt = new Point2Db();
                        NowPt.Col      = MyResult.col;
                        NowPt.Row      = MyResult.row;
                        ListMarkCenterU.Add(NowPt);
                        FindCenterCont = FindCenterCont.ConcatObj(MyResult.ShowContour);
                    }
                    else
                    {
                        MessageBox.Show("移动失败");
                        return;
                    }
                }
                #region 零度时候的定位坐标
                Point2Db ZeoroDegreePos = new Point2Db();
                if (MotionManager.Instance.SetCoordiPos(TeachCaliPara.StartRotPt.x, TeachCaliPara.StartRotPt.y, 0.0))
                {
                    if (GrabedImg != null)
                    {
                        GrabedImg.Dispose();
                    }
                    CameraCtrl.Instance.GrabImg(TeachCaliPara.cam, out GrabedImg); //采集图像
                    MyResult = new LocalResult();
                    MyLocal.SetParam(GrabedImg, TeachCaliPara.localPara);
                    MyLocal.doLocal();
                    MyResult = MyLocal.GetResult();
                    if (!MyResult.IsLocalOk)
                    {
                        MessageBox.Show("定位失败");
                        return;
                    }
                    ZeoroDegreePos = new Point2Db(MyResult.col, MyResult.row);
                }
                #endregion
                //通过找到的标定mark中心点集合,拟合出旋转中心
                HTuple CircleRows = new HTuple();
                HTuple CircleCols = new HTuple();
                MyVisionBase.ListPt2dToHTuple(ListMarkCenterU, out CircleRows, out CircleCols);
                HObject CircleContourU = new HObject();
                HTuple CenterRow       = new HTuple(), CenterCol = new HTuple();
                HTuple RotRadius       = new HTuple(), StartPhi = new HTuple(), EndPhi = new HTuple(), FitFlag = new HTuple();
                if (FindCirCenterCbx.SelectedValue.ToString() == "拟合圆")
                {
                    MyVisionBase.PtsToBestCircle1(out CircleContourU, CircleRows, CircleCols, 4, "arc", out CenterRow, out CenterCol,
                                                  out RotRadius, out StartPhi, out EndPhi, out FitFlag);//通过边界点拟合圆
                    RotR         = RotRadius.D;
                    RotCenterRow = CenterRow.D;
                    RotCenterCol = CenterCol.D;
                }
                else if (FindCirCenterCbx.SelectedValue.ToString() == "中垂线找圆心")
                {
                    FindCircleCenter(ListMarkCenterU, out RotCenterRow, out RotCenterCol, out RotR);
                    HOperatorSet.GenCircleContourXld(out CircleContourU, RotCenterRow, RotCenterCol, RotR, 0, Math.PI, "positive", 1);
                }
                HObject PtContour = new HObject();
                HOperatorSet.GenCrossContourXld(out PtContour, CircleRows, CircleCols, 20, 0.6);
                HOperatorSet.ConcatObj(PtContour, CircleContourU, out CircleContourU);
                // MyVisionBase.hDispObj(hWindowControl1.HalconWindow, CircleContourU);
                view1.AddViewObject(CircleContourU);
                view1.Repaint();
                MyVisionBase.HTupleToListPt2d(CircleRows, CircleCols, out ListMarkCenterU);
                //计算0度标定Mark中心到旋转中心的偏移量
                VectorCaliMarkToRot.Row = (CenterRow - ZeoroDegreePos.Row);
                VectorCaliMarkToRot.Col = (CenterCol - ZeoroDegreePos.Col);
                HObject MarkToRotArrow  = new HObject();
                MyVisionBase.GenArrowContourXld(out MarkToRotArrow, ZeoroDegreePos.Row, ZeoroDegreePos.Col, CenterRow, CenterCol, 30, 30);
                view1.AddViewObject(MarkToRotArrow);
                view1.Repaint();
            }));
        }