예제 #1
0
 private static void ResultColIsNullOrEmpty(ResultCol resultCol)
 {
     return(!resultCol.PropertiesLoaded.Any() && resultCol == null);
 }
예제 #2
0
 public void ClearResult()
 {
     ResultRow.Clear();
     ResultCol.Clear();
     ResultAngle.Clear();
 }
예제 #3
0
        public void Run(SoftwareRunState softwareRunState)
        {
            HTuple HMeasureHandle = new HTuple();
            HTuple resultRow, resultCol;

            if (inputImage == null)
            {
                if (softwareRunState == SoftwareRunState.Debug)
                {
                    FormCaliper.Instance.TextBoxMessageDisp("图像为空", System.Drawing.Color.Red);
                }
                toolRunStatu = ToolRunStatu.Not_Input_Image;
                return;
            }
            try
            {
                UpdateImage();
                if (inputPose != null)
                {
                    HTuple Row   = inputPose.X - templatePose.X;
                    HTuple Col   = inputPose.Y - templatePose.Y;
                    HTuple angle = inputPose.U - templatePose.U;

                    HTuple _homMat2D;
                    HOperatorSet.HomMat2dIdentity(out _homMat2D);
                    HOperatorSet.HomMat2dRotate(_homMat2D, (HTuple)(angle), (HTuple)templatePose.X, (HTuple)templatePose.Y, out _homMat2D);
                    HOperatorSet.HomMat2dTranslate(_homMat2D, (HTuple)(Row), (HTuple)(Col), out _homMat2D);

                    //对预期线的起始点做放射变换
                    HOperatorSet.AffineTransPixel(_homMat2D, (HTuple)expectRecStartRow, (HTuple)expectRecStartColumn, out newExpectRecStartRow, out newExpectRecStartColumn);
                }
                else
                {
                    newExpectRecStartRow    = expectRecStartRow;
                    newExpectRecStartColumn = expectRecStartColumn;
                }
                HTuple width, height, AmplitudeThreshold, distance;
                HOperatorSet.GetImageSize(inputImage, out width, out height);
                HOperatorSet.GenMeasureRectangle2(expectRecStartRow, expectRecStartColumn, expectAngle, length1, length2, width, height, "nearest_neighbor", out HMeasureHandle);
                HOperatorSet.MeasurePos(inputImage, HMeasureHandle, sigma, threshold, polarity, edgeSelect, out resultRow, out resultCol, out AmplitudeThreshold, out distance);
                if (resultRow.Length != 0)
                {
                    ResulttRow = resultRow;
                    ResultCol  = resultCol;
                }

                //把点显示出来
                HOperatorSet.GenCrossContourXld(out crossDisp, ResulttRow, ResultCol, new HTuple(60), new HTuple(0));
                if (softwareRunState == SoftwareRunState.Debug)
                {
                    DispMainWindow(FormCaliper.Instance.myHwindow);
                    FormCaliper.Instance.tbx_resultStartRow.Text = ResulttRow.ToString();
                    FormCaliper.Instance.tbx_resultStartCol.Text = ResultCol.ToString();
                    FormCaliper.Instance.TextBoxMessageDisp("运行成功", System.Drawing.Color.Green);
                }
                // 参数传递
                ParamsTrans();
                toolRunStatu = ToolRunStatu.Succeed;
            }
            catch (Exception ex)
            {
                toolRunStatu = ToolRunStatu.Not_Succeed;
                if (softwareRunState == SoftwareRunState.Debug)
                {
                    FormCaliper.Instance.TextBoxMessageDisp("工具运行异常" + ex.Message, System.Drawing.Color.Red);
                }
            }
            finally
            {
                //homMat2DArrow.Dispose();
                //arrow.Dispose();
                //arrowTrans.Dispose();
            }
        }
예제 #4
0
 public VisionShapParam()
 {
     ResultRow.Clear();
     ResultCol.Clear();
     ResultAngle.Clear();
 }