Exemple #1
0
        public void DrawCross(int _StartX, int _StartY, int _LengthX, int _LengthY, string _GroupName, CogColorConstants _Color)
        {
            if (_LengthX == 0 || _LengthY == 0)
            {
                return;
            }

            staticGraphicHor.Color                   = staticGraphicVer.Color = _Color;
            staticGraphicHor.Interactive             = staticGraphicVer.Interactive = false;
            staticGraphicHor.GraphicDOFEnable        = staticGraphicVer.GraphicDOFEnable = CogLineSegmentDOFConstants.BothPoints;
            staticGraphicHor.LineStyle               = staticGraphicVer.LineStyle = CogGraphicLineStyleConstants.Solid;
            staticGraphicHor.LineWidthInScreenPixels = staticGraphicVer.LineWidthInScreenPixels = 1;
            staticGraphicHor.SetStartLengthRotation(_StartX - _LengthX / 2, _StartY, _LengthX, 0);
            staticGraphicVer.SetStartLengthRotation(_StartX, _StartY - _LengthY / 2, _LengthY, 0 + 1.57);

            if (null == _GroupName)
            {
                kCogDisplay.StaticGraphics.Add(staticGraphicHor, "CrossHor");
                kCogDisplay.StaticGraphics.Add(staticGraphicVer, "CrossVer");
            }

            else
            {
                kCogDisplay.StaticGraphics.Add(staticGraphicHor, _GroupName + "Hor");
                kCogDisplay.StaticGraphics.Add(staticGraphicVer, _GroupName + "Ver");
            }
        }
Exemple #2
0
 public void DrawStaticLine(double _StartX, double _StartY, double _Length, double _Rotate, int _Tickness, string _GroupName, CogColorConstants _Color)
 {
     StaticLineSegment.Color                   = _Color;
     StaticLineSegment.Interactive             = false;
     StaticLineSegment.LineStyle               = CogGraphicLineStyleConstants.Solid;
     StaticLineSegment.LineWidthInScreenPixels = _Tickness;
     StaticLineSegment.SetStartLengthRotation(_StartX, _StartY, _Length, _Rotate);
     kCogDisplay.StaticGraphics.Add(StaticLineSegment, _GroupName);
 }
Exemple #3
0
        private void ApplyLineFindValueFunction(CogLineFindAlgo _CogLineFindAlgo, ref CogLineFindResult _CogLineFindResult)
        {
            if (eTeachStep.ALGO_SET != CurrentTeachStep)
            {
                MessageBox.Show("Not select \"Algorithm Set\" button"); return;
            }
            AlgorithmAreaDisplayRefresh();

            CogImage8Grey _DestImage = new CogImage8Grey();
            bool          _Result    = InspLineFindProcess.Run(InspectionImage, ref _DestImage, AlgoRegionRectangle, _CogLineFindAlgo, ref _CogLineFindResult);

            CogLineSegment _CogLine = new CogLineSegment();

            if (_CogLineFindResult.StartX != 0 && _CogLineFindResult.StartY != 0 && _CogLineFindResult.Length != 0)
            {
                _CogLine.SetStartLengthRotation(_CogLineFindResult.StartX, _CogLineFindResult.StartY, _CogLineFindResult.Length, _CogLineFindResult.Rotation);
                kpTeachDisplay.DrawStaticLine(_CogLine, "LineFind", CogColorConstants.Green);
            }
        }
        public bool Run(CogImage8Grey _SrcImage, CogRectangle _InspRegion, CogLeadAlgo _CogLeadAlgo, ref CogLeadResult _CogLeadResult, double _ReferX = -1, double _ReferY = -1)
        {
            bool _Result = true;

            SetHardFixedThreshold(_CogLeadAlgo.ThresholdMin);
            SetConnectivityMinimum((int)_CogLeadAlgo.BlobAreaMin);
            SetPolarity(Convert.ToBoolean(_CogLeadAlgo.ForeGround));

            if (true == Inspection(_SrcImage, _InspRegion))
            {
                GetResult(true);
            }

            if (GetResults().BlobCount > 0)
            {
                _CogLeadResult           = GetResults();
                _CogLeadResult.LeadCount = _CogLeadResult.BlobCount;

                #region Lead Pitch Point Get
                for (int iLoopCount = 0; iLoopCount < _CogLeadResult.BlobCount; ++iLoopCount)
                {
                    #region Lead Bent Check
                    double _Angle = _CogLeadResult.Angle[iLoopCount] * 180 / Math.PI;
                    if (_Angle > 0)
                    {
                        _Angle = 90 - (_CogLeadResult.Angle[iLoopCount] * 180 / Math.PI);
                    }
                    else
                    {
                        _Angle = -(90 + (_CogLeadResult.Angle[iLoopCount] * 180 / Math.PI));
                    }

                    _CogLeadResult.IsLeadBentGood[iLoopCount] = true;
                    if (_CogLeadAlgo.IsLeadBentInspection)
                    {
                        if ((_Angle > _CogLeadAlgo.LeadBentMax) || (_Angle < -_CogLeadAlgo.LeadBentMin))
                        {
                            _CogLeadResult.IsLeadBentGood[iLoopCount] = false;
                            _CogLeadResult.IsGood &= _CogLeadResult.IsLeadBentGood[iLoopCount];
                        }
                    }
                    #endregion Lead Bent Check

                    #region Pitch Point 구하기
                    if (_CogLeadResult.Angle[iLoopCount] > 0)
                    {
                        CogLineSegment _CenterLine = new CogLineSegment();
                        _CenterLine.SetStartLengthRotation(_CogLeadResult.BlobCenterX[iLoopCount], _CogLeadResult.BlobCenterY[iLoopCount], _CogLeadResult.PrincipalWidth[iLoopCount] / 2, (Math.PI) + _CogLeadResult.Angle[iLoopCount]);
                        _CogLeadResult.LeadPitchTopX[iLoopCount] = _CenterLine.EndX;
                        _CogLeadResult.LeadPitchTopY[iLoopCount] = _CenterLine.EndY;

                        _CenterLine.SetStartLengthRotation(_CogLeadResult.BlobCenterX[iLoopCount], _CogLeadResult.BlobCenterY[iLoopCount], _CogLeadResult.PrincipalWidth[iLoopCount] / 2, _CogLeadResult.Angle[iLoopCount]);
                        _CogLeadResult.LeadPitchBottomX[iLoopCount] = _CenterLine.EndX;
                        _CogLeadResult.LeadPitchBottomY[iLoopCount] = _CenterLine.EndY;
                    }

                    else
                    {
                        CogLineSegment _CenterLine = new CogLineSegment();
                        _CenterLine.SetStartLengthRotation(_CogLeadResult.BlobCenterX[iLoopCount], _CogLeadResult.BlobCenterY[iLoopCount], _CogLeadResult.PrincipalWidth[iLoopCount] / 2, _CogLeadResult.Angle[iLoopCount]);
                        _CogLeadResult.LeadPitchTopX[iLoopCount] = _CenterLine.EndX;
                        _CogLeadResult.LeadPitchTopY[iLoopCount] = _CenterLine.EndY;

                        _CenterLine.SetStartLengthRotation(_CogLeadResult.BlobCenterX[iLoopCount], _CogLeadResult.BlobCenterY[iLoopCount], _CogLeadResult.PrincipalWidth[iLoopCount] / 2, (Math.PI) + _CogLeadResult.Angle[iLoopCount]);
                        _CogLeadResult.LeadPitchBottomX[iLoopCount] = _CenterLine.EndX;
                        _CogLeadResult.LeadPitchBottomY[iLoopCount] = _CenterLine.EndY;
                    }
                    #endregion Pitch Point 구하기

                    #region Length 구하기
                    if (_ReferY != -1 && _ReferY != -1)
                    {
                        _CogLeadResult.LeadLength[iLoopCount]       = Math.Abs(_ReferY - _CogLeadResult.LeadPitchTopY[iLoopCount]);
                        _CogLeadResult.LeadLengthStartX[iLoopCount] = _CogLeadResult.LeadPitchTopX[iLoopCount];
                        _CogLeadResult.LeadLengthStartY[iLoopCount] = _ReferY;
                    }
                    #endregion Length 구하기
                }
                #endregion Lead Pitch Point Get

                #region Lead Length Get
                #endregion Lead Length Get

                _CogLeadResult.IsGood &= true;
            }

            else
            {
                _CogLeadResult.IsGood = false;
            }

            return(_Result);
        }