Exemplo n.º 1
0
        private void ApplyNeedleCircleFindValueFunction(CogNeedleFindAlgo _CogNeedleFindAlgo, ref CogNeedleFindResult _CogNeedleFindResult)
        {
            if (eTeachStep.ALGO_SET != CurrentTeachStep)
            {
                MessageBox.Show("Not select \"Algorithm Set\" button"); return;
            }
            AlgorithmAreaDisplayRefresh();

            bool _Result = InspNeedleCircleFindProcess.Run(InspectionImage, _CogNeedleFindAlgo, ref _CogNeedleFindResult);

            _CogNeedleFindResult.CenterXReal = (_CogNeedleFindResult.CenterX - (InspectionImage.Width / 2)) * ResolutionX;
            _CogNeedleFindResult.CenterYReal = (_CogNeedleFindResult.CenterY - (InspectionImage.Height / 2)) * ResolutionY;
            _CogNeedleFindResult.OriginXReal = (_CogNeedleFindResult.OriginX - (InspectionImage.Width / 2)) * ResolutionX;
            _CogNeedleFindResult.OriginYReal = (_CogNeedleFindResult.OriginY - (InspectionImage.Height / 2)) * ResolutionY;
            _CogNeedleFindResult.RadiusReal  = _CogNeedleFindResult.Radius * ResolutionX;

            CogCircle _CogCircle = new CogCircle();

            if (_CogNeedleFindResult.Radius <= 0)
            {
                return;
            }
            _CogCircle.SetCenterRadius(_CogNeedleFindResult.CenterX, _CogNeedleFindResult.CenterY, _CogNeedleFindResult.Radius);
            CogPointMarker _CogCenterPoint = new CogPointMarker();

            _CogCenterPoint.SetCenterRotationSize(_CogNeedleFindResult.CenterX, _CogNeedleFindResult.CenterY, 0, 2);
            kpTeachDisplay.DrawStaticShape(_CogCircle, "Circle", CogColorConstants.Green, 3);
            kpTeachDisplay.DrawStaticShape(_CogCenterPoint, "CirclePoint", CogColorConstants.Green);

            string _CenterName = string.Format("X = {0:F2}mm, Y = {1:F2}mm, R = {2:F2}mm", _CogNeedleFindResult.CenterXReal, _CogNeedleFindResult.CenterYReal, _CogNeedleFindResult.RadiusReal);

            kpTeachDisplay.DrawText(_CenterName, _CogNeedleFindResult.CenterX, _CogNeedleFindResult.CenterY + 150, CogColorConstants.Green, 10, CogGraphicLabelAlignmentConstants.BaselineCenter);
        }
Exemplo n.º 2
0
        private void ShowSearchArea()
        {
            if (MapDataParam.Info.UnitListCenterX == null || MapDataParam.Info.UnitListCenterY == null)
            {
                return;
            }
            if (MapDataParam.Info.UnitListCenterX.Count == 0 || MapDataParam.Info.UnitListCenterY.Count == 0)
            {
                return;
            }
            if (MapDataParam.Info.UnitListCenterX.Count != MapDataParam.Info.UnitListCenterY.Count)
            {
                return;
            }

            uint _RowCount   = Convert.ToUInt32(numUpDownUnitRowCount.Value);
            uint _ColCount   = Convert.ToUInt32(numUpDownUnitColumnCount.Value);
            int  _TotalCount = MapDataParam.Info.UnitListCenterX.Count;

            if (_TotalCount != (_RowCount * _ColCount))
            {
                MessageBox.Show(string.Format("Total : {0}, Row : {1}, Column : {2}", _TotalCount, _RowCount, _ColCount)); return;
            }
            CenterPoint[] _CenterPointArray = new CenterPoint[_TotalCount];
            for (int iLoopCount = 0; iLoopCount < _TotalCount; ++iLoopCount)
            {
                _CenterPointArray[iLoopCount]   = new CenterPoint();
                _CenterPointArray[iLoopCount].X = MapDataParam.Info.UnitListCenterX[iLoopCount];
                _CenterPointArray[iLoopCount].Y = MapDataParam.Info.UnitListCenterY[iLoopCount];
            }
            CenterPoint[,] _SortedCenterPoint = CenterPointSort((uint)_RowCount, (uint)_ColCount, _CenterPointArray);
            MapDataParam.Info.UnitListCenterX.Clear();
            MapDataParam.Info.UnitListCenterY.Clear();
            for (int iLoopCount = 0; iLoopCount < _RowCount; ++iLoopCount)
            {
                for (int jLoopCount = 0; jLoopCount < _ColCount; ++jLoopCount)
                {
                    MapDataParam.Info.UnitListCenterX.Add(_SortedCenterPoint[iLoopCount, jLoopCount].X);
                    MapDataParam.Info.UnitListCenterY.Add(_SortedCenterPoint[iLoopCount, jLoopCount].Y);
                }
            }

            kpTeachDisplay.ClearDisplay();
            for (int iLoopCount = 0; iLoopCount < MapDataParam.Info.UnitListCenterX.Count; ++iLoopCount)
            {
                CogRectangle _FindPattern = new CogRectangle();
                _FindPattern.SetCenterWidthHeight(MapDataParam.Info.UnitListCenterX[iLoopCount], MapDataParam.Info.UnitListCenterY[iLoopCount],
                                                  MapDataParam.Info.UnitListWidth[iLoopCount], MapDataParam.Info.UnitListHeight[iLoopCount]);
                kpTeachDisplay.DrawStaticShape(_FindPattern, "SearchArea" + (iLoopCount + 1));

                CogPointMarker _OriginPoint = new CogPointMarker();
                _OriginPoint.SetCenterRotationSize(MapDataParam.Info.UnitListCenterX[iLoopCount], MapDataParam.Info.UnitListCenterY[iLoopCount], 0, 2);
                kpTeachDisplay.DrawStaticShape(_OriginPoint, "PatternOrigin" + (iLoopCount + 1), CogColorConstants.Green, 12);

                kpTeachDisplay.DrawText((iLoopCount + 1).ToString(), MapDataParam.Info.UnitListCenterX[iLoopCount], MapDataParam.Info.UnitListCenterY[iLoopCount] - 15, CogColorConstants.Green, 10);
            }

            SelectingRectName = SelectedRectName = "";
            IsDrawPatterns    = true;
        }
Exemplo n.º 3
0
        private void btnUnitPatternAreaSet_Click(object sender, EventArgs e)
        {
            #region Button Status
            btnUnitPatternSearchAreaShow.Enabled  = true;        btnUnitPatternSearchAreaShow.BackColor = Color.SandyBrown;
            btnUnitPatternSearchAreaSet.Enabled   = false;        btnUnitPatternSearchAreaSet.BackColor = Color.Gray;
            btnUnitPatternOriginCenterSet.Enabled = false;      btnUnitPatternOriginCenterSet.BackColor = Color.Gray;
            btnUnitPatternAreaShow.Enabled        = true;              btnUnitPatternAreaShow.BackColor = Color.PaleGreen;
            btnUnitPatternAreaSet.Enabled         = false;              btnUnitPatternAreaSet.BackColor = Color.Gray;
            //btnUnitPatternAreaCancel.Enabled = false;
            #endregion Button Status

            CogRectangle   _PatternRegion = kpTeachDisplay.GetInterActiveRectangle();
            CogPointMarker _PatternOrigin = new CogPointMarker();
            _PatternOrigin.SetCenterRotationSize(_PatternRegion.CenterX, _PatternRegion.CenterY, 0, 2);

            kpTeachDisplay.ClearDisplay("PatternRegion");
            kpTeachDisplay.ClearDisplay("PatternOriginPoint");
            kpTeachDisplay.DrawStaticShape(_PatternRegion, "PatternRegion", CogColorConstants.Green, 2, CogGraphicLineStyleConstants.Dash);
            kpTeachDisplay.DrawStaticShape(_PatternOrigin, "PatternOriginPoint", CogColorConstants.Green, 14);

            MapDataParam.Unit.PatternAreaCenterX = _PatternRegion.CenterX;
            MapDataParam.Unit.PatternAreaCenterY = _PatternRegion.CenterY;
            MapDataParam.Unit.PatternAreaWidth   = _PatternRegion.Width;
            MapDataParam.Unit.PatternAreaHeight  = _PatternRegion.Height;
            MapDataParam.Unit.PatternAreaOriginX = _PatternOrigin.X;
            MapDataParam.Unit.PatternAreaOriginY = _PatternOrigin.Y;

            //Pattern 등록
            CogPMAlignPattern _Pattern = InspPattern.GetPatternReference(OriginImage, _PatternRegion, _PatternOrigin.X, _PatternOrigin.Y);
            kpPatternDisplay.SetDisplayImage((CogImage8Grey)_Pattern.GetTrainedPatternImage());
            MapDataParam.Info.UnitPattern = _Pattern;

            SelectingRectName = SelectedRectName = "";
            IsDrawPatterns    = false;
        }
Exemplo n.º 4
0
        private void btnUnitPatternOriginCenterSet_Click(object sender, EventArgs e)
        {
            CogRectangle   _PatternRegion = kpTeachDisplay.GetInterActiveRectangle();
            CogPointMarker _PatternOrigin = new CogPointMarker();

            _PatternOrigin.SetCenterRotationSize(_PatternRegion.CenterX, _PatternRegion.CenterY, 0, 2);

            kpTeachDisplay.ClearDisplay("PatternOriginPoint");
            kpTeachDisplay.DrawInterActiveShape(_PatternOrigin, "PatternOriginPoint", CogColorConstants.Green, 14);
        }
Exemplo n.º 5
0
        public CogPointMarker GetInterActivePoint()
        {
            CogPointMarker cogPointMarker = new CogPointMarker();
            double         CenterX, CenterY, Rotate;
            int            Pixel;

            InteractivePointMarker.GetCenterRotationSize(out CenterX, out CenterY, out Rotate, out Pixel);
            cogPointMarker.SetCenterRotationSize(CenterX, CenterY, Rotate, Pixel);
            return(cogPointMarker);
        }
Exemplo n.º 6
0
        private void DrawReferRegionFunction(CogRectangle _ReferRegion, double _OriginX, double _OriginY, CogColorConstants _Color)
        {
            if (eTeachStep.ALGO_SET != CurrentTeachStep)
            {
                MessageBox.Show("Not select \"Algorithm Set\" button"); return;
            }
            AlgorithmAreaDisplayRefresh();

            CogPointMarker _PointMarker = new CogPointMarker();

            _PointMarker.SetCenterRotationSize(_OriginX, _OriginY, 0, 1);

            kpTeachDisplay.DrawInterActiveShape(_ReferRegion, "ReferRegion", _Color);
            kpTeachDisplay.DrawInterActiveShape(_PointMarker, "ReferOriginPoint", _Color, 14);
        }
Exemplo n.º 7
0
        private void ApplyAutoPatternFindValueFunction(CogAutoPatternAlgo _CogAutoPatternAlgo, ref CogAutoPatternResult _CogAutoPatternResult)
        {
            if (eTeachStep.ALGO_SET != CurrentTeachStep)
            {
                MessageBox.Show("Not select \"Algorithm Set\" button"); return;
            }
            AlgorithmAreaDisplayRefresh();

            bool _Result = InspAutoPatternProcess.Run(InspectionImage, AlgoRegionRectangle, _CogAutoPatternAlgo, ref _CogAutoPatternResult);

            if (_CogAutoPatternAlgo.ReferenceInfoList.Count != 0)
            {
                CogRectangle _PatternRect = new CogRectangle();
                _PatternRect.SetCenterWidthHeight(_CogAutoPatternResult.CenterX, _CogAutoPatternResult.CenterY, _CogAutoPatternResult.Width, _CogAutoPatternResult.Height);
                kpTeachDisplay.DrawStaticShape(_PatternRect, "AutoPatternRect" + 1, CogColorConstants.Green);

                CogPointMarker _Point = new CogPointMarker();
                _Point.SetCenterRotationSize(_CogAutoPatternResult.OriginPointX, _CogAutoPatternResult.OriginPointY, 0, 2);
                kpTeachDisplay.DrawStaticShape(_Point, "AutoPatternOrigin" + 1, CogColorConstants.Green, 12);

                string _MatchingName = string.Format($"Rate = {_CogAutoPatternResult.Score:F2}, X = {_CogAutoPatternResult.OriginPointX:F2}, Y = {_CogAutoPatternResult.OriginPointY:F2}");
                kpTeachDisplay.DrawText(_MatchingName, _CogAutoPatternResult.OriginPointX, _CogAutoPatternResult.OriginPointY + 30, CogColorConstants.Green, 10, CogGraphicLabelAlignmentConstants.BaselineCenter);
            }
        }
Exemplo n.º 8
0
        private void ApplyMultiPatternValueFunction(CogMultiPatternAlgo _CogMultiPatternAlgo, ref CogMultiPatternResult _CogMultiPatternResult)
        {
            if (eTeachStep.ALGO_SET != CurrentTeachStep)
            {
                MessageBox.Show("Not select \"Algorithm Set\" button"); return;
            }
            AlgorithmAreaDisplayRefresh();

            bool _Result = InspMultiPatternProcess.Run(InspectionImage, AlgoRegionRectangle, _CogMultiPatternAlgo, ref _CogMultiPatternResult);

            for (int iLoopCount = 0; iLoopCount < _CogMultiPatternResult.FindCount; ++iLoopCount)
            {
                CogRectangle _PatternRect = new CogRectangle();
                _PatternRect.SetCenterWidthHeight(_CogMultiPatternResult.CenterX[iLoopCount], _CogMultiPatternResult.CenterY[iLoopCount], _CogMultiPatternResult.Width[iLoopCount], _CogMultiPatternResult.Height[iLoopCount]);
                kpTeachDisplay.DrawStaticShape(_PatternRect, "PatternRect" + (iLoopCount + 1), CogColorConstants.Green);

                CogPointMarker _Point = new CogPointMarker();
                _Point.SetCenterRotationSize(_CogMultiPatternResult.OriginPointX[iLoopCount], _CogMultiPatternResult.OriginPointY[iLoopCount], 0, 2);
                kpTeachDisplay.DrawStaticShape(_Point, "PatternOrigin" + (iLoopCount + 1), CogColorConstants.Green, 12);

                string _MatchingName = string.Format($"Rate = {_CogMultiPatternResult.Score[iLoopCount]:F2}, X = {_CogMultiPatternResult.OriginPointX[iLoopCount]:F2}, Y = {_CogMultiPatternResult.OriginPointY[iLoopCount]:F2}");
                kpTeachDisplay.DrawText(_MatchingName, _CogMultiPatternResult.OriginPointX[iLoopCount], _CogMultiPatternResult.OriginPointY[iLoopCount] + 30, CogColorConstants.Green, 10, CogGraphicLabelAlignmentConstants.BaselineCenter);
            }
        }
        private void btnFindCenter_Click(object sender, EventArgs e)
        {
            try
            {
                CogFitCircleTool fitCircle = new CogFitCircleTool();
                fitCircle.InputImage          = this.cogRecordDisplay1.Image;
                fitCircle.RunParams.NumPoints = 0;
                for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                {
                    double x = double.Parse(this.dataGridView1.Rows[i].Cells[0].Value.ToString());
                    double y = double.Parse(this.dataGridView1.Rows[i].Cells[1].Value.ToString());
                    fitCircle.RunParams.AddPoint(x, y);
                }
                fitCircle.Run();
                circleX = Math.Round(fitCircle.Result.GetCircle().CenterX, 3);
                circleY = Math.Round(fitCircle.Result.GetCircle().CenterY, 3);
                double circleRadius = Math.Round(fitCircle.Result.GetCircle().Radius, 3);
                fitCircle.Result.GetCircle().Color = CogColorConstants.Green;
                CogPointMarker ptr = new CogPointMarker();
                ptr.Color = CogColorConstants.Green;
                ptr.SetCenterRotationSize(circleX, circleY, 0, 60);
                this.cogRecordDisplay1.StaticGraphics.Add(fitCircle.Result.GetCircle(), "");
                this.cogRecordDisplay1.StaticGraphics.Add(ptr, "");

                txtResultX.Text      = circleX.ToString("f3");
                txtResultY.Text      = circleY.ToString("f3");
                txtResultRadius.Text = circleRadius.ToString("f3");
            }
            catch (Exception ex)
            {
                MessageBox.Show("计算旋转中心失败");
                txtResultX.Text      = string.Empty;
                txtResultY.Text      = string.Empty;
                txtResultRadius.Text = string.Empty;
            }
        }
Exemplo n.º 10
0
        private void ApplyLeadInspValueFunction(CogLeadAlgo _CogLeadAlgo, ref CogLeadResult _CogLeadResult, bool _IsDisplay = true)
        {
            if (eTeachStep.ALGO_SET != CurrentTeachStep)
            {
                MessageBox.Show("Not select \"Algorithm Set\" button"); return;
            }
            if (_IsDisplay)
            {
                AlgorithmAreaDisplayRefresh();
            }

            bool _Result = InspLeadProcess.Run(InspectionImage, AlgoRegionRectangle, _CogLeadAlgo, ref _CogLeadResult);

            #region Result Display
            if (_IsDisplay)
            {
                for (int iLoopCount = 0; iLoopCount < _CogLeadResult.BlobCount; ++iLoopCount)
                {
                    //Blob Boundary
                    CogRectangleAffine _BlobRectAffine = new CogRectangleAffine();
                    _BlobRectAffine.SetCenterLengthsRotationSkew(_CogLeadResult.BlobCenterX[iLoopCount], _CogLeadResult.BlobCenterY[iLoopCount], _CogLeadResult.PrincipalWidth[iLoopCount], _CogLeadResult.PrincipalHeight[iLoopCount], _CogLeadResult.Angle[iLoopCount], 0);
                    kpTeachDisplay.DrawStaticShape(_BlobRectAffine, "BlobRectAffine" + (iLoopCount + 1), CogColorConstants.Green);
                    kpTeachDisplay.DrawBlobResult(_CogLeadResult.ResultGraphic[iLoopCount], "BlobRectGra" + (iLoopCount + 1));

                    CogLineSegment _CenterLine = new CogLineSegment();
                    kpTeachDisplay.DrawStaticLine(_CogLeadResult.BlobCenterX[iLoopCount], _CogLeadResult.BlobCenterY[iLoopCount], _CogLeadResult.PrincipalWidth[iLoopCount] / 2 + 20, _CogLeadResult.Angle[iLoopCount], 2, "CenterLine+_" + (iLoopCount + 1), CogColorConstants.Cyan);
                    kpTeachDisplay.DrawStaticLine(_CogLeadResult.BlobCenterX[iLoopCount], _CogLeadResult.BlobCenterY[iLoopCount], _CogLeadResult.PrincipalWidth[iLoopCount] / 2 + 20, (Math.PI) + _CogLeadResult.Angle[iLoopCount], 2, "CenterLine-_" + (iLoopCount + 1), CogColorConstants.Cyan);

                    CogPointMarker _PitchPoint = new CogPointMarker();
                    _PitchPoint.SetCenterRotationSize(_CogLeadResult.LeadPitchTopX[iLoopCount], _CogLeadResult.LeadPitchTopY[iLoopCount], 0, 1);
                    kpTeachDisplay.DrawStaticShape(_PitchPoint, "PointStart" + (iLoopCount + 1), CogColorConstants.Yellow, 2);
                    _PitchPoint.SetCenterRotationSize(_CogLeadResult.LeadPitchBottomX[iLoopCount], _CogLeadResult.LeadPitchBottomY[iLoopCount], 0, 1);
                    kpTeachDisplay.DrawStaticShape(_PitchPoint, "PointEnd" + (iLoopCount + 1), CogColorConstants.Orange, 2);
                }
            }
            #endregion Result Display

            #region Pitch Average 측정
            try
            {
                double[] _LeadPitchX = new double[_CogLeadResult.BlobCount];
                Array.Copy(_CogLeadResult.LeadPitchTopX, _LeadPitchX, _CogLeadResult.BlobCount);
                Array.Sort(_LeadPitchX);

                double[] _LeadPitches = new double[_CogLeadResult.BlobCount - 1];
                for (int iLoopCount = 0; iLoopCount < _CogLeadResult.BlobCount - 1; ++iLoopCount)
                {
                    _LeadPitches[iLoopCount] = _LeadPitchX[iLoopCount + 1] - _LeadPitchX[iLoopCount];
                }

                Array.Sort(_LeadPitches);
                double _Gab = _LeadPitches[4];
                int    _Index = 1;
                double _PitchSum = _LeadPitches[4], _PitchArray = 0;
                for (int iLoopCount = 5; iLoopCount < _CogLeadResult.BlobCount - 1; ++iLoopCount)
                {
                    if (_Gab + 20 < _LeadPitches[iLoopCount])
                    {
                        break;
                    }
                    _PitchSum += _LeadPitches[iLoopCount];
                    _Index++;
                }

                _PitchArray = _PitchSum / _Index;
                _CogLeadResult.LeadPitchAvg = _PitchArray;
            }

            catch
            {
                _CogLeadResult.LeadPitchAvg = 0;
                CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.ERR, "ApplyLeadInspValueFunction Exception", CLogManager.LOG_LEVEL.LOW);
            }
            #endregion Pitch Average 측정

            #region Lead Angle Average 측정
            try
            {
                double[] _LeadAngles = new double[_CogLeadResult.BlobCount];
                Array.Copy(_CogLeadResult.Angle, _LeadAngles, _CogLeadResult.BlobCount);
                Array.Sort(_LeadAngles);

                int    _Index = 0;
                double _AngleSum = 0, _AngleAvg = 0;
                for (int iLoopCount = 5; iLoopCount < _CogLeadResult.BlobCount - 5; ++iLoopCount)
                {
                    _AngleSum += _CogLeadResult.Angle[iLoopCount];
                    _Index++;
                }
                _AngleAvg = _AngleSum / _Index;
                _CogLeadResult.LeadAngleAvg = _AngleAvg;
            }

            catch
            {
                _CogLeadResult.LeadAngleAvg = 0;
                CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.ERR, "ApplyLeadInspValueFunction Exception", CLogManager.LOG_LEVEL.LOW);
            }
            #endregion Lead Angle Average 측정
        }
Exemplo n.º 11
0
        private void btnFindSearchArea_Click(object sender, EventArgs e)
        {
            double _OffsetX = MapDataParam.Unit.PatternAreaOriginX - MapDataParam.Unit.PatternAreaCenterX;
            double _OffsetY = MapDataParam.Unit.PatternAreaOriginY - MapDataParam.Unit.PatternAreaCenterY;

            InspPattern.SetPatternReference(MapDataParam.Info.UnitPattern);
            InspPattern.SetMatchingParameter(MapDataParam.Info.FindCount, MapDataParam.Info.FindScore);

            if (false == InspPattern.Run(OriginImage))
            {
                MessageBox.Show("Pattern Not Found"); return;
            }

            CogPMAlignResults _PatternResult = InspPattern.GetResults();

            if (null == _PatternResult)
            {
                return;
            }

            MapDataParam.Info.UnitListCenterX.Clear();
            MapDataParam.Info.UnitListCenterY.Clear();
            MapDataParam.Info.UnitListWidth.Clear();
            MapDataParam.Info.UnitListHeight.Clear();
            if (_PatternResult.Count > 0)
            {
                double[] _OriginX, _OriginY, _CenterX, _CenterY, _Width, _Height;
                _OriginX = new double[_PatternResult.Count];
                _OriginY = new double[_PatternResult.Count];
                _CenterX = new double[_PatternResult.Count];
                _CenterY = new double[_PatternResult.Count];
                _Width   = new double[_PatternResult.Count];
                _Height  = new double[_PatternResult.Count];

                uint          _RowCount         = Convert.ToUInt32(numUpDownUnitRowCount.Value);
                uint          _ColCount         = Convert.ToUInt32(numUpDownUnitColumnCount.Value);
                CenterPoint[] _CenterPointArray = new CenterPoint[_RowCount * _ColCount];
                for (int iLoopCount = 0; iLoopCount < _PatternResult.Count; ++iLoopCount)
                {
                    _OriginX[iLoopCount] = _PatternResult[iLoopCount].GetPose().TranslationX;
                    _OriginY[iLoopCount] = _PatternResult[iLoopCount].GetPose().TranslationY;
                    _CenterX[iLoopCount] = _PatternResult[iLoopCount].GetPose().TranslationX - _OffsetX;
                    _CenterY[iLoopCount] = _PatternResult[iLoopCount].GetPose().TranslationY - _OffsetY;
                    _Width[iLoopCount]   = _PatternResult.GetTrainArea().Width;
                    _Height[iLoopCount]  = _PatternResult.GetTrainArea().Height;

                    CogRectangle _FindPattern = new CogRectangle();
                    _FindPattern.SetCenterWidthHeight(_CenterX[iLoopCount], _CenterY[iLoopCount], MapDataParam.Unit.SearchAreaWidth, MapDataParam.Unit.SearchAreaHeight);
                    kpTeachDisplay.DrawStaticShape(_FindPattern, "SearchArea" + (iLoopCount + 1));

                    CogPointMarker _OriginPoint = new CogPointMarker();
                    _OriginPoint.SetCenterRotationSize(_OriginX[iLoopCount], _OriginY[iLoopCount], 0, 2);
                    kpTeachDisplay.DrawStaticShape(_OriginPoint, "PatternOrigin" + (iLoopCount + 1), CogColorConstants.Green, 12);

                    MapDataParam.Info.UnitListCenterX.Add(_CenterX[iLoopCount]);
                    MapDataParam.Info.UnitListCenterY.Add(_CenterY[iLoopCount]);
                    MapDataParam.Info.UnitListWidth.Add(_Width[iLoopCount]);
                    MapDataParam.Info.UnitListHeight.Add(_Height[iLoopCount]);

                    if (_CenterPointArray.Length > iLoopCount)
                    {
                        _CenterPointArray[iLoopCount]   = new CenterPoint();
                        _CenterPointArray[iLoopCount].X = _CenterX[iLoopCount];
                        _CenterPointArray[iLoopCount].Y = _CenterY[iLoopCount];
                    }
                }

                if ((_RowCount * _ColCount) != _PatternResult.Count)
                {
                    MessageBox.Show("Unit 개수와 Find Result 개수가 맞지 않습니다.");
                    return;
                }

                else
                {
                    CenterPoint[,] _SortedCenterPoint = CenterPointSort(_RowCount, _ColCount, _CenterPointArray);

                    MapDataParam.Info.UnitListCenterX.Clear();
                    MapDataParam.Info.UnitListCenterY.Clear();
                    for (int iLoopCount = 0; iLoopCount < _RowCount; ++iLoopCount)
                    {
                        for (int jLoopCount = 0; jLoopCount < _ColCount; ++jLoopCount)
                        {
                            MapDataParam.Info.UnitListCenterX.Add(_SortedCenterPoint[iLoopCount, jLoopCount].X);
                            MapDataParam.Info.UnitListCenterY.Add(_SortedCenterPoint[iLoopCount, jLoopCount].Y);
                        }
                    }

                    SelectingRectName = SelectedRectName = "";
                    IsDrawPatterns    = true;
                    MessageBox.Show("Pattern Find Complete");
                }
            }
        }