public List <double> GetLeadGuidePosition(CogBlobResults _BlobResults) { List <double> _GuidePositionList = new List <double>(); if (null == _BlobResults || _BlobResults.GetBlobs().Count <= 0) { return(_GuidePositionList); } for (int iLoopCount = 0; iLoopCount < _BlobResults.GetBlobs().Count; ++iLoopCount) { double _CenterX = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.BoundingBoxPixelAlignedNoExcludeCenterX, iLoopCount); bool _IsNew = true; for (int jLoopCount = 0; jLoopCount < _GuidePositionList.Count; ++jLoopCount) { if (_CenterX > _GuidePositionList[jLoopCount] - 100 && _CenterX < _GuidePositionList[jLoopCount] + 100) { _IsNew = false; break; } } if (true == _IsNew) { double _GuidePosTemp; _GuidePosTemp = _CenterX; _GuidePositionList.Add(_GuidePosTemp); } } _GuidePositionList.Sort(); return(_GuidePositionList); }
private void AssignToolResult(string parent, CogBlobResults blobResults) { CogBlobResultCollection blobResultColl = blobResults.GetBlobs(false); int count = blobResultColl.Count; AddResult(string.Format("{0}.Count", parent), blobResultColl.Count); double areaX = 0.0; double areaY = 0.0; double totalArea = 0.0; for (int i = 0; i < count; i++) { CogBlobResult blobResult = blobResultColl[i]; double x = blobResult.CenterOfMassX; double y = blobResult.CenterOfMassY; double area = blobResult.Area; totalArea += area; areaX += x * area; areaY += y * area; AddResult(string.Format("{0}[{1}].Area", parent, i), area); AddResult(string.Format("{0}[{1}].CenterOfMassX", parent, i), x); AddResult(string.Format("{0}[{1}].CenterOfMassY", parent, i), y); AddResult(string.Format("{0}[{1}].Angle", parent, i), blobResult.Angle); } AddResult(string.Format("{0}[+].Area", parent), totalArea); AddResult(string.Format("{0}[A].CenterOfMassX", parent), totalArea > 0 ? areaX / totalArea : 0.0); AddResult(string.Format("{0}[A].CenterOfMassY", parent), totalArea > 0 ? areaY / totalArea : 0.0); }
public double GetWidthResult(CogBlobResults _BlobResults) { double _Width = 0; double _MaxArea = 0; if (null == _BlobResults || _BlobResults.GetBlobs().Count <= 0) { return(_Width); } for (int iLoopCount = 0; iLoopCount < _BlobResults.GetBlobs().Count; ++iLoopCount) { if (_MaxArea < _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.Area, iLoopCount)) { _MaxArea = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.Area, iLoopCount); _Width = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.BoundingBoxPixelAlignedNoExcludeWidth, iLoopCount); } } return(_Width); }
public bool Run(CogImage8Grey _SrcImage, CogRectangle _InspRegion, CogEllipseAlgo _CogEllipseAlgo, ref CogEllipseResult _CogEllipseResult, double _OffsetX = 0, double _OffsetY = 0, int _NgNumber = 0) { bool _Result = true; #region Caliper Center XY 구하기 -> Blob으로 Center 위치 Search #region GetAutoThresholdValue CogHistogramTool _HistoTool = new CogHistogramTool(); _HistoTool.InputImage = _SrcImage; _HistoTool.Region = _InspRegion; _HistoTool.Run(); int[] _HistoValue = _HistoTool.Result.GetHistogram(); double _TotSize = _InspRegion.Width * _InspRegion.Height; double _ThresholdSum = 0; int _ThresholdValue = 0; for (int iLoopCount = 0; iLoopCount < 256; ++iLoopCount) { _ThresholdSum += iLoopCount * _HistoValue[iLoopCount]; } double _ThresholdSum2 = 0; double _WeightBack = 0, _WeightFore = 0, _VarMax = 0; for (int iLoopCount = 0; iLoopCount < 256; ++iLoopCount) { _WeightBack += _HistoValue[iLoopCount]; if (0 == _WeightBack) { continue; } _WeightFore = _TotSize - _WeightBack; if (0 == _WeightFore) { break; } _ThresholdSum2 += (double)(iLoopCount * _HistoValue[iLoopCount]); double _MeanBack = _ThresholdSum2 / _WeightBack; double _MeanFore = (_ThresholdSum - _ThresholdSum2) / _WeightFore; double _VarBetween = _WeightBack * _WeightFore * Math.Pow((_MeanBack - _MeanFore), 2); if (_VarBetween > _VarMax) { _VarMax = _VarBetween; _ThresholdValue = iLoopCount; } } #endregion #region Blob Search CogBlobTool _BlobTool = new CogBlobTool(); _BlobTool.InputImage = _SrcImage; _BlobTool.Region = _InspRegion; _BlobTool.RunParams.SegmentationParams.Mode = CogBlobSegmentationModeConstants.HardFixedThreshold; _BlobTool.RunParams.SegmentationParams.Polarity = CogBlobSegmentationPolarityConstants.LightBlobs; _BlobTool.RunParams.ConnectivityMode = CogBlobConnectivityModeConstants.GreyScale; _BlobTool.RunParams.ConnectivityCleanup = CogBlobConnectivityCleanupConstants.Fill; _BlobTool.RunParams.SegmentationParams.HardFixedThreshold = _ThresholdValue; _BlobTool.RunParams.ConnectivityMinPixels = 10000; _BlobTool.Run(); CogBlobResults _BlobResults = _BlobTool.Results; double _MaxSize = 0; double _CaliperCenterX = 0; double _CaliperCenterY = 0; if (_BlobResults.GetBlobs().Count > 0) { for (int iLoopCount = 0; iLoopCount < _BlobResults.GetBlobs().Count; ++iLoopCount) { CogBlobResult _BlobResult = _BlobResults.GetBlobByID(iLoopCount); if (_BlobResult.Area > _MaxSize) { _MaxSize = _BlobResult.Area; _CaliperCenterX = _BlobResult.CenterOfMassX; _CaliperCenterY = _BlobResult.CenterOfMassY; } } } else { _CaliperCenterX = _CogEllipseAlgo.ArcCenterX - _OffsetX; _CaliperCenterY = _CogEllipseAlgo.ArcCenterY - _OffsetY; } //CogSerializer.SaveObjectToFile(_BlobTool, string.Format(@"D:\CircleBlob.vpp")); #endregion #endregion SetCaliperDirection(_CogEllipseAlgo.CaliperSearchDirection, _CogEllipseAlgo.CaliperPolarity); SetCaliper(_CogEllipseAlgo.CaliperNumber, _CogEllipseAlgo.CaliperSearchLength, _CogEllipseAlgo.CaliperProjectionLength, _CogEllipseAlgo.CaliperIgnoreNumber); //LJH 2019.05.23 Caliper Center 기준점 변경 //SetEllipticalArc(_CogEllipseAlgo.ArcCenterX - _OffsetX, _CogEllipseAlgo.ArcCenterY - _OffsetY, _CogEllipseAlgo.ArcRadiusX, _CogEllipseAlgo.ArcRadiusY, _CogEllipseAlgo.ArcAngleSpan); SetEllipticalArc(_CaliperCenterX, _CaliperCenterY, _CogEllipseAlgo.ArcRadiusX, _CogEllipseAlgo.ArcRadiusY, _CogEllipseAlgo.ArcAngleSpan); if (true == Inspection(_SrcImage)) { GetResult(); } if (FindEllipseResults != null && FindEllipseResults.Count > 0) { _CogEllipseResult.IsGood = true; } else { _CogEllipseResult.IsGood = false; } if (!_CogEllipseResult.IsGood) { CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, " - Ellipse Find Fail!!", CLogManager.LOG_LEVEL.MID); _CogEllipseResult.CenterX = _CogEllipseAlgo.ArcCenterX; _CogEllipseResult.CenterY = _CogEllipseAlgo.ArcCenterY; _CogEllipseResult.RadiusX = _CogEllipseAlgo.ArcRadiusX; _CogEllipseResult.RadiusY = _CogEllipseAlgo.ArcRadiusY; _CogEllipseResult.OriginX = 0; _CogEllipseResult.OriginY = 0; _CogEllipseResult.Rotation = 0; _CogEllipseResult.NgNumber = _NgNumber; } else { if (FindEllipseResults.GetEllipse() != null) { CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, " - Ellipse Complete", CLogManager.LOG_LEVEL.MID); _CogEllipseResult.PointFoundCount = FindEllipseResults.NumPointsFound; _CogEllipseResult.CenterX = FindEllipseResults.GetEllipse().CenterX; _CogEllipseResult.CenterY = FindEllipseResults.GetEllipse().CenterY; _CogEllipseResult.RadiusX = FindEllipseResults.GetEllipse().RadiusX; _CogEllipseResult.RadiusY = FindEllipseResults.GetEllipse().RadiusY; _CogEllipseResult.OriginX = FindEllipseResults.GetEllipse().CenterX; _CogEllipseResult.OriginY = FindEllipseResults.GetEllipse().CenterY; _CogEllipseResult.Rotation = FindEllipseResults.GetEllipse().Rotation; _CogEllipseResult.NgNumber = _NgNumber; _CogEllipseResult.PointPosXInfo = new double[FindEllipseResults.Count]; _CogEllipseResult.PointPosYInfo = new double[FindEllipseResults.Count]; _CogEllipseResult.PointStatusInfo = new bool[FindEllipseResults.Count]; for (int iLoopCount = 0; iLoopCount < FindEllipseResults.Count; ++iLoopCount) { if (true == FindEllipseResults[iLoopCount].Found) { _CogEllipseResult.PointPosXInfo[iLoopCount] = FindEllipseResults[iLoopCount].X; _CogEllipseResult.PointPosYInfo[iLoopCount] = FindEllipseResults[iLoopCount].Y; } _CogEllipseResult.PointStatusInfo[iLoopCount] = FindEllipseResults[iLoopCount].Used; } _CogEllipseResult.DiameterMinAlgo = _CogEllipseAlgo.DiameterSize - _CogEllipseAlgo.DiameterMinus; _CogEllipseResult.DiameterMaxAlgo = _CogEllipseAlgo.DiameterSize + _CogEllipseAlgo.DiameterPlus; CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, String.Format(" - Center X : {0}, Y : {1}", _CogEllipseResult.CenterX.ToString("F2"), _CogEllipseResult.CenterY.ToString("F2")), CLogManager.LOG_LEVEL.MID); CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, String.Format(" - Radius X : {0}, Y : {1}", _CogEllipseResult.RadiusX.ToString("F2"), _CogEllipseResult.RadiusY.ToString("F2")), CLogManager.LOG_LEVEL.MID); } else { CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, " - Ellipse Find Fail!!", CLogManager.LOG_LEVEL.MID); _CogEllipseResult.CenterX = _CogEllipseAlgo.ArcCenterX; _CogEllipseResult.CenterY = _CogEllipseAlgo.ArcCenterY; _CogEllipseResult.RadiusX = _CogEllipseAlgo.ArcRadiusX; _CogEllipseResult.RadiusY = _CogEllipseAlgo.ArcRadiusY; _CogEllipseResult.OriginX = 0; _CogEllipseResult.OriginY = 0; _CogEllipseResult.NgNumber = _NgNumber; _CogEllipseResult.IsGood = false; } } CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, " - Result : " + _CogEllipseResult.IsGood.ToString(), CLogManager.LOG_LEVEL.MID); return(_Result); }
public CogCompositeShape[] GetGraphicResult() { CogCompositeShape[] _GraphicResult = new CogCompositeShape[BlobResults.GetBlobs().Count]; CogBlobResult _BlobResult = new CogBlobResult(); for (int iLoopCount = 0; iLoopCount < BlobResults.GetBlobs().Count; ++iLoopCount) { BlobResult = BlobResults.GetBlobByID(iLoopCount); _GraphicResult[iLoopCount] = BlobResult.CreateResultGraphics(CogBlobResultGraphicConstants.Boundary); } return(_GraphicResult); }
public bool LeadAlignSE(CogImage8Grey _SrcImage, CogRectangle _InspRegion, CogLeadFormAlgo _CogLeadFormAlgo) { if (LeadFormResult.IsGood != true) { return(true); } CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, "LeadAlign - Start", CLogManager.LOG_LEVEL.MID); if (false == _CogLeadFormAlgo.IsUseAlign) { CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, "LeadAlign Disable - End", CLogManager.LOG_LEVEL.MID); return(true); } bool _Result = true; List <double> _AlignPositionX = new List <double>(); List <double> _AlignPositionY = new List <double>(); List <double> _AlignPositionWidth = new List <double>(); try { System.Diagnostics.Stopwatch _ProcessWatch = new System.Diagnostics.Stopwatch(); _ProcessWatch.Reset(); _ProcessWatch.Start(); SetHardFixedThreshold(_CogLeadFormAlgo.AlignThreshold); SetConnectivityMinimum(500); SetPolarity(true); CogBlobResults _BlobResults = BlobProc.Execute(_SrcImage, _InspRegion); List <double> _GuidePositionX = GetLeadGuidePosition(_BlobResults); #region Caliper Tool Setting => Y좌표 위치 정보 찾기 LeadFormResult.LeadCount = _GuidePositionX.Count; if (_GuidePositionX.Count != _CogLeadFormAlgo.LeadCount) { LeadFormResult.IsGood = false; LeadFormResult.NgType = eNgType.LEAD_CNT; LeadFormResult.SearchArea.SetCenterWidthHeight(_InspRegion.CenterX, _InspRegion.CenterY, _InspRegion.Width, _InspRegion.Height); LeadFormResult.LeadCountStatus = LeadFormResult.LeadCount.ToString(); return(false); } for (int iLoopCount = 0; iLoopCount < _GuidePositionX.Count; ++iLoopCount) { CogRectangleAffine _CaliperRegion = new CogRectangleAffine(); _CaliperRegion.SetCenterLengthsRotationSkew(_GuidePositionX[iLoopCount], _InspRegion.CenterY, _InspRegion.Height, 170, 1.5708, 0); CogCaliperTool _LeadCaliper = new CogCaliperTool(); _LeadCaliper.RunParams.EdgeMode = CogCaliperEdgeModeConstants.SingleEdge; _LeadCaliper.RunParams.Edge0Polarity = CogCaliperPolarityConstants.DarkToLight; _LeadCaliper.RunParams.MaxResults = 2; _LeadCaliper.Region = _CaliperRegion; _LeadCaliper.InputImage = _SrcImage; _LeadCaliper.Run(); if (_LeadCaliper.Results.Count == 1) { _AlignPositionY.Add(_LeadCaliper.Results[0].PositionY); } else if (_LeadCaliper.Results.Count == 2) { _AlignPositionY.Add((_LeadCaliper.Results[0].PositionY < _LeadCaliper.Results[1].PositionY) ? _LeadCaliper.Results[0].PositionY : _LeadCaliper.Results[1].PositionY); } //CogSerializer.SaveObjectToFile(_LeadCaliper, string.Format(@"D:\GuideCaliper{0}.vpp", iLoopCount + 1)); } #endregion #region Blob Tool Setting => X좌표 위치 정보 찾기 for (int iLoopCount = 0; iLoopCount < _GuidePositionX.Count; ++iLoopCount) { SetHardFixedThreshold(_CogLeadFormAlgo.AlignThreshold); SetConnectivityMinimum(500); SetPolarity(true); CogRectangle _BlobRegion = new CogRectangle(); _BlobRegion.SetCenterWidthHeight(_GuidePositionX[iLoopCount], _AlignPositionY[iLoopCount] + 18, 170, 36); _BlobResults = BlobProc.Execute(_SrcImage, _BlobRegion); if (_BlobResults.GetBlobs().Count == 0) { LeadFormResult.IsGood = false; LeadFormResult.NgType = eNgType.LEAD_CNT; LeadFormResult.SearchArea.SetCenterWidthHeight(_InspRegion.CenterX, _InspRegion.CenterY, _InspRegion.Width, _InspRegion.Height); LeadFormResult.LeadCountStatus = "NG"; return(false); } _AlignPositionX.Add(GetCenterXResult(_BlobResults)); _AlignPositionWidth.Add(GetWidthResult(_BlobResults)); } #endregion #region Align XY 좌표 ADD if (_CogLeadFormAlgo.LeadCount == _GuidePositionX.Count) { LeadFormResult.AlignResultDataList.Clear(); for (int iLoopCount = 0; iLoopCount < _GuidePositionX.Count; ++iLoopCount) { LeadFormAlignResultData _AlignResult = new LeadFormAlignResultData(); _AlignResult.CenterX = _AlignPositionX[iLoopCount]; _AlignResult.CenterY = _AlignPositionY[iLoopCount]; _AlignResult.Width = _AlignPositionWidth[iLoopCount]; _AlignResult.Height = _AlignPositionWidth[iLoopCount]; _AlignResult.IsGood = true; LeadFormResult.AlignResultDataList.Add(_AlignResult); } } else { LeadFormResult.IsGood = false; LeadFormResult.NgType = eNgType.LEAD_CNT; LeadFormResult.LeadCountStatus = _GuidePositionX.Count.ToString(); LeadFormResult.SearchArea.SetCenterWidthHeight(_InspRegion.CenterX, _InspRegion.CenterY, _InspRegion.Width, _InspRegion.Height); _Result = false; } #endregion //Lead 간격 조건 검사 LeadFormResult.AlignOffsetDataList.Clear(); PointD _AlignOffset = new PointD(); if (_CogLeadFormAlgo.LeadCount == LeadFormResult.LeadCount) { for (int iLoopCount = 0; iLoopCount < _CogLeadFormAlgo.LeadCount; ++iLoopCount) { double _RealCenterX = LeadFormResult.AlignResultDataList[iLoopCount].CenterX * _CogLeadFormAlgo.ResolutionX; double _RealCenterY = LeadFormResult.AlignResultDataList[iLoopCount].CenterY * _CogLeadFormAlgo.ResolutionY; #region X 축 Skew 확인 //Align Pitch Spec에서 완전히 벗어났는지 확인 if (_RealCenterX > _CogLeadFormAlgo.AlignPositionArray[iLoopCount].X - _CogLeadFormAlgo.AlignPitchSpec && _RealCenterX < _CogLeadFormAlgo.AlignPositionArray[iLoopCount].X + _CogLeadFormAlgo.AlignPitchSpec) { //Align Skew 가능 범위에 들어와 있는지 확인 //Skew 범위 안쪽이면 Skew 여부에 상관없이 GOOD if (_RealCenterX > _CogLeadFormAlgo.AlignPositionArray[iLoopCount].X - _CogLeadFormAlgo.AlignSkewSpec && _RealCenterX < _CogLeadFormAlgo.AlignPositionArray[iLoopCount].X + _CogLeadFormAlgo.AlignSkewSpec) { if (LeadFormResult.NgType == eNgType.GOOD) { LeadFormResult.AlignResultDataList[iLoopCount].IsGood = true; } LeadFormResult.EachLeadStatusArray[iLoopCount].SetSkewResult(eLeadStatus.GOOD); } //Skew 범위 < Position < Pitch Err 범위 //불량 판정 & Skew 가능 에러로 전달 else { LeadFormResult.AlignResultDataList[iLoopCount].IsGood = false; LeadFormResult.IsGood = false; LeadFormResult.EachLeadStatusArray[iLoopCount].SetSkewResult(eLeadStatus.LEAD_SKEW_ENABLE); _Result = false; } } //완전히 벗어나면 Skew 불가능 에러 else { LeadFormResult.AlignResultDataList[iLoopCount].IsGood = false; LeadFormResult.IsGood = false; LeadFormResult.EachLeadStatusArray[iLoopCount].SetSkewResult(eLeadStatus.LEAD_SKEW_DISABLE); _Result = false; } #endregion #region Y 축 Skew 확인 //Align Pitch Spec에서 완전히 벗어났는지 확인 if (_RealCenterY > _CogLeadFormAlgo.AlignPositionArray[iLoopCount].Y - _CogLeadFormAlgo.AlignPitchSpec && _RealCenterY < _CogLeadFormAlgo.AlignPositionArray[iLoopCount].Y + _CogLeadFormAlgo.AlignPitchSpec) { //Align Skew 가능 범위에 들어와 있는지 확인 //Skew 범위 안쪽이면 Skew 여부에 상관없이 GOOD if (_RealCenterY > _CogLeadFormAlgo.AlignPositionArray[iLoopCount].Y - _CogLeadFormAlgo.AlignSkewSpec && _RealCenterY < _CogLeadFormAlgo.AlignPositionArray[iLoopCount].Y + _CogLeadFormAlgo.AlignSkewSpec) { //if (LeadFormResult.NgType == eNgType.GOOD) // LeadFormResult.AlignResultDataList[iLoopCount].IsGood = true; LeadFormResult.EachLeadStatusArray[iLoopCount].SetSkewResult(eLeadStatus.GOOD); } //Skew 범위 < Position < Pitch Err 범위 //불량 판정 & Skew 가능 에러로 전달 else { LeadFormResult.AlignResultDataList[iLoopCount].IsGood = false; LeadFormResult.IsGood = false; LeadFormResult.EachLeadStatusArray[iLoopCount].SetSkewResult(eLeadStatus.LEAD_SKEW_ENABLE); _Result = false; } } else { LeadFormResult.AlignResultDataList[iLoopCount].IsGood = false; LeadFormResult.IsGood = false; LeadFormResult.EachLeadStatusArray[iLoopCount].SetSkewResult(eLeadStatus.LEAD_SKEW_DISABLE); _Result = false; } #endregion _AlignOffset.X = Math.Round(_RealCenterX - _CogLeadFormAlgo.AlignPositionArray[iLoopCount].X, 4); _AlignOffset.Y = Math.Round(_RealCenterY - _CogLeadFormAlgo.AlignPositionArray[iLoopCount].Y, 4); LeadFormResult.AlignOffsetDataList.Add(_AlignOffset); LeadFormResult.EachLeadStatusArray[iLoopCount].SideX = _AlignOffset.X.ToString(); LeadFormResult.EachLeadStatusArray[iLoopCount].SideY = _AlignOffset.Y.ToString(); } } else { LeadFormResult.IsGood = false; LeadFormResult.NgType = eNgType.LEAD_CNT; LeadFormResult.LeadCountStatus = LeadFormResult.LeadCount.ToString(); LeadFormResult.SearchArea.SetCenterWidthHeight(_InspRegion.CenterX, _InspRegion.CenterY, _InspRegion.Width, _InspRegion.Height); _Result = false; } _ProcessWatch.Stop(); string _ProcessTime = String.Format("LeadAlign Time : {0} ms", _ProcessWatch.Elapsed.TotalSeconds.ToString()); CLogManager.AddInspectionLog(CLogManager.LOG_TYPE.INFO, _ProcessTime, CLogManager.LOG_LEVEL.LOW); } catch (Exception ex) { CLogManager.AddSystemLog(CLogManager.LOG_TYPE.ERR, "LeadAlign - Inspection Exception : " + ex.ToString(), CLogManager.LOG_LEVEL.LOW); LeadFormResult.NgType = eNgType.EMPTY; LeadFormResult.IsGood = false; LeadFormResult.LeadBodyStatus = "NG"; LeadFormResult.SearchArea.SetCenterWidthHeight(_InspRegion.CenterX, _InspRegion.CenterY, _InspRegion.Width, _InspRegion.Height); _Result = false; } return(_Result); }
public List <LeadFormAlignResultData> GetAlignResult(CogBlobResults _BlobResults)//, int _LeadCount) { List <LeadFormAlignResultData> _AlignResultDataList = new List <LeadFormAlignResultData>(); if (null == _BlobResults || _BlobResults.GetBlobs().Count <= 0) { return(_AlignResultDataList); } for (int iLoopCount = 0; iLoopCount < _BlobResults.GetBlobs().Count; ++iLoopCount) { double _BlobMinX = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.BoundingBoxPixelAlignedNoExcludeMinX, iLoopCount); double _BlobMaxX = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.BoundingBoxPixelAlignedNoExcludeMaxX, iLoopCount); double _BlobMinY = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.BoundingBoxPixelAlignedNoExcludeMinY, iLoopCount); double _BlobMaxY = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.BoundingBoxPixelAlignedNoExcludeMaxY, iLoopCount); double _Width = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.BoundingBoxPixelAlignedNoExcludeWidth, iLoopCount); double _Height = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.BoundingBoxPixelAlignedNoExcludeHeight, iLoopCount); //사이즈가 너무 큰 경우 걸러내기 if ((_Width < 65 && _Height < 65) && (_Width > 35 && _Height > 35)) { LeadFormAlignResultData _AlignResultDataTemp = new LeadFormAlignResultData(); _AlignResultDataTemp.Area = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.Area, iLoopCount); _AlignResultDataTemp.Width = _Width; _AlignResultDataTemp.Height = _Height; _AlignResultDataTemp.Angle = _BlobResults.GetBlobMeasure(CogBlobMeasureConstants.Angle, iLoopCount); _AlignResultDataTemp.CenterX = (_BlobMaxX + _BlobMinX) / 2; _AlignResultDataTemp.CenterY = (_BlobMaxY + _BlobMinY) / 2; _AlignResultDataList.Add(_AlignResultDataTemp); } } //Y축 정렬 _AlignResultDataList.Sort(delegate(LeadFormAlignResultData _A, LeadFormAlignResultData _B) { if (_A.CenterY > _B.CenterY) { return(1); } else if (_A.CenterY < _B.CenterY) { return(-1); } return(0); }); //Y축 정렬 후 Lead 갯수까지만 자르기 //if (_AlignResultDataList.Count > _LeadCount) //{ // for (int iLoopCount = _AlignResultDataList.Count - 1; iLoopCount > _LeadCount - 1; --iLoopCount) // _AlignResultDataList.RemoveAt(iLoopCount); //} //X축으로 재 정렬 _AlignResultDataList.Sort(delegate(LeadFormAlignResultData _A, LeadFormAlignResultData _B) { if (_A.CenterX > _B.CenterX) { return(1); } else if (_A.CenterX < _B.CenterX) { return(-1); } return(0); }); return(_AlignResultDataList); }