Beispiel #1
0
        public bool RunCaliper(ADisplay aDisplay, bool bViewTxt, bool bShowRegion, double dX, double dY)
        {
            if (Run(aDisplay) > 0)
            {
                ViewResult(aDisplay, bShowRegion);

                m_stResult.bResult = true;

                m_stResult.dEdge0PositionX = Edge0PositionX;
                m_stResult.dEdge0PositionY = Edge0PositionY;
                m_stResult.dEdge0Contrast  = Edge0Contrast;
                m_stResult.dEdge1PositionX = Edge1PositionX;
                m_stResult.dEdge1PositionY = Edge1PositionY;
                m_stResult.dEdge1Contrast  = Edge1Contrast;
                m_stResult.dWidth          = Width;

                if (bViewTxt)
                {
                    aDisplay.AddTxt(dX, dY, "Caliper:OK(" + Math.Round(m_stResult.dEdge0Contrast, 2).ToString() + ")", CogColorConstants.Green);
                }
            }
            else
            {
                ShowRegion(aDisplay);

                m_stResult.bResult = false;

                if (bViewTxt)
                {
                    aDisplay.AddTxt(dX, dY, "Caliper:NG", CogColorConstants.Red);
                }
            }

            return(m_stResult.bResult);
        }
Beispiel #2
0
        public bool GrabRegion(ADisplay aDisplay)
        {
            try
            {
                aDisplay.ClearOverlay();

                ICogGraphicInteractive icogGraphInteractive = null;
                CogRectangleAffine     cogRectangleAffine   = m_cogCaliperTool.Region;

                if (cogRectangleAffine == null)
                {
                    cogRectangleAffine = new CogRectangleAffine();
                    cogRectangleAffine.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5);
                }

                icogGraphInteractive = cogRectangleAffine as ICogGraphicInteractive;

                if (icogGraphInteractive != null)
                {
                    icogGraphInteractive.GraphicDOFEnableBase = CogGraphicDOFConstants.All;
                    icogGraphInteractive.Interactive          = true;
                    icogGraphInteractive.TipText = "Region of Interest";
                    aDisplay.AddOverlay(icogGraphInteractive, "");
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #3
0
        // 2015.06.15
        public void ViewResult2(ADisplay aDisplay, bool isShowRegion)
        {
            if (m_cogCaliperTool == null)
            {
                return;
            }

            // 2015.02.09
            if (isShowRegion)
            {
                ShowRegion(aDisplay);
            }

            int nFindCount = m_cogCaliperTool.Results.Count;

            if (nFindCount > 0)
            {
                CogCaliperResults cogCaliperResults = new CogCaliperResults();
                cogCaliperResults = m_cogCaliperTool.Results;

                if (cogCaliperResults != null && cogCaliperResults.Count >= 1)
                {
                    CogCaliperResult caliperResult = new CogCaliperResult();
                    caliperResult = cogCaliperResults[0];

                    CogCompositeShape compositeShape = new CogCompositeShape();

                    compositeShape = caliperResult.CreateResultGraphics((CogCaliperResultGraphicConstants)(1 + 2));
                    aDisplay.AddOverlay((ICogGraphicInteractive)compositeShape, "");
                }
            }
        }
Beispiel #4
0
        public void ShowRegion(ADisplay aDisplay)
        {
            // 2015.06.15
            if (m_cogCaliperTool == null)
            {
                return;
            }

            // 2017.05.08
            if (m_cogCaliperTool.Region == null)
            {
                return;
            }

            // 2014.07.02
            ICogRegion             icogRegion           = m_cogCaliperTool.Region.Copy(CogCopyShapeConstants.GeometryOnly);
            ICogGraphicInteractive icogGraphInteractive = icogRegion as ICogGraphicInteractive;

            if (icogGraphInteractive != null)
            {
                icogGraphInteractive.GraphicDOFEnableBase = CogGraphicDOFConstants.None;
                icogGraphInteractive.Interactive          = false;
                icogGraphInteractive.Color = CogColorConstants.DarkGreen;
                aDisplay.AddOverlay(icogGraphInteractive, "");
            }
        }
        public bool Calibrate(ADisplay aDisplay, bool isShowDistorted)
        {
            if (m_bGrabed == true)
            {
                try
                {
                    SetCalibCheckerboardParam();

                    m_cogCalibCheckerboardTool.Calibration.Calibrate();
                    m_bCalibrated        = m_cogCalibCheckerboardTool.Calibration.Calibrated;
                    m_dCaibratedOriginX  = m_cogCalibCheckerboardTool.Calibration.CalibratedOriginX;
                    m_dCaibratedOriginY  = m_cogCalibCheckerboardTool.Calibration.CalibratedOriginY;
                    m_dCaibratedRotation = m_cogCalibCheckerboardTool.Calibration.CalibratedXAxisRotation;

                    if (m_bCalibrated)
                    {
                        ShowCalibratedPoints(aDisplay, isShowDistorted, false);
                    }
                }
                catch
                {
                    MessageBox.Show("Calibration Error!");
                    m_bCalibrated = false;
                    return(false);
                }
            }

            return(m_bCalibrated);
        }
Beispiel #6
0
        public bool RunBlob(ADisplay aDisplay, bool bViewTxt, bool bShowCenter, bool bShowRegion, double dX, double dY)
        {
            if (Run(aDisplay) > 0)
            {
                ViewResult(aDisplay, bShowCenter, bShowRegion);

                m_stResult.bResult = true;
                m_stResult.nCount  = m_nFindCount;
                if (bViewTxt)
                {
                    aDisplay.AddTxt(dX, dY, "Blob:find" + m_nFindCount.ToString(), CogColorConstants.Green);
                }
            }
            else
            {
                ShowRegion(aDisplay);

                m_stResult.bResult = false;
                m_stResult.nCount  = 0;
                if (bViewTxt)
                {
                    aDisplay.AddTxt(dX, dY, "Blob:NG", CogColorConstants.Red);
                }
            }

            return(m_stResult.bResult);
        }
        public void GetAxesParam(ADisplay aDisplay, bool isShowDistorted)
        {
            double                 dOriginX, dOriginY;
            ICogTransform2D        transform2D;
            CogTransform2DLinear   transform2DLinear = null;
            ICogGraphicInteractive axes = aDisplay.GetInteractiveGraphics("Calibrated Origin");

            if (axes != null)
            {
                CogCoordinateAxes coordinateAxes = axes as CogCoordinateAxes;

                dOriginX = coordinateAxes.OriginX;
                dOriginY = coordinateAxes.OriginY;
                TransUncalibrated2CalibratedCoord(dOriginX, dOriginY, out m_dOriginX, out m_dOriginY);

                if (isShowDistorted == true)
                {
                    transform2D       = m_cogCalibCheckerboardTool.Calibration.OwnedWarpParams.GetOutputImageRootFromCalibratedTransform();
                    transform2DLinear = transform2D.LinearTransform(dOriginX, dOriginY).Invert();
                    m_dRotation       = transform2DLinear.MapAngle(m_cogCoordinateAxes.Rotation) + m_dCaibratedRotation;
                }
                else
                {
                    transform2D       = m_cogCalibCheckerboardTool.Calibration.GetComputedUncalibratedFromCalibratedTransform();
                    transform2DLinear = transform2D.LinearTransform(m_dOriginX, m_dOriginY).Invert();
                    m_dRotation       = transform2DLinear.MapAngle(coordinateAxes.Rotation) + m_dCaibratedRotation;
                }
            }
        }
Beispiel #8
0
        public void Run(ADisplay aDisplay)
        {
            if (m_bCalibrated == true)
            {
                aDisplay.ClearOverlay();
                m_cogCalibNPointToNPointTool.InputImage = aDisplay.Image;

                // 2015.04.08
                m_bRan = false;

                m_cogCalibNPointToNPointTool.Run();

                // 2015.04.08
                WaitRanEvent();

                aDisplay.Display.Image = m_cogCalibNPointToNPointTool.OutputImage;
                aDisplay.Display.Fit(true);

                m_cogCoordinateAxes.OriginX  = 0;
                m_cogCoordinateAxes.OriginY  = 0;
                m_cogCoordinateAxes.Rotation = 0;
                m_cogCoordinateAxes.Skew     = 0;

                m_cogCoordinateAxes.GraphicDOFEnable = CogCoordinateAxesDOFConstants.None;
                m_cogCoordinateAxes.Interactive      = false;
                m_cogCoordinateAxes.Color            = CogColorConstants.Green;
                m_cogCoordinateAxes.XAxisLabel.Color = CogColorConstants.Green;
                m_cogCoordinateAxes.YAxisLabel.Color = CogColorConstants.Green;
                m_cogCoordinateAxes.TipText          = "";
                aDisplay.AddOverlay(m_cogCoordinateAxes as ICogGraphicInteractive, "");
            }
        }
Beispiel #9
0
        public void ShowCalibratedPoints(ADisplay aDisplay, bool bMove)
        {
            try
            {
                aDisplay.ClearAll();
                aDisplay.Display.Image = m_cogCalibNPointToNPointTool.CalibrationImage;
                aDisplay.Display.Fit(true);

                for (int i = 0; i < 3; i++)
                {
                    m_pcogPointMaker[i].GraphicType = CogPointMarkerGraphicTypeConstants.Crosshair;
                    m_pcogPointMaker[i].Color       = CogColorConstants.Magenta;
                    m_pcogPointMaker[i].X           = m_cogCalibNPointToNPointTool.Calibration.GetUncalibratedPointX(i);
                    m_pcogPointMaker[i].Y           = m_cogCalibNPointToNPointTool.Calibration.GetUncalibratedPointY(i);
                    if (bMove)
                    {
                        m_pcogPointMaker[i].GraphicDOFEnable = CogPointMarkerDOFConstants.Position;
                    }
                    else
                    {
                        m_pcogPointMaker[i].GraphicDOFEnable = CogPointMarkerDOFConstants.None;
                    }

                    m_pcogPointMaker[i].Interactive = true;
                    m_pcogPointMaker[i].TipText     = "Uncalibrated Point " + i.ToString();

                    aDisplay.AddOverlay(m_pcogPointMaker[i] as ICogGraphicInteractive, "");
                }
            }
            catch { }
        }
Beispiel #10
0
        public void ViewResult(ADisplay displayInput, bool isShowRegion)
        {
            // 2015.02.09
            if (isShowRegion)
            {
                ShowRegion(displayInput);
            }

            if (m_isRun)
            {
                CogHistogramResult histResult = new CogHistogramResult();
                histResult = m_cogHistogramTool.Result;

                if (histResult != null)
                {
                    // 2015.02.09

                    /*
                     * if (isShowRegion)
                     * {
                     *  ShowRegion(displayInput);
                     * }
                     */
                }
            }
        }
Beispiel #11
0
        public bool Calibrate(ADisplay aDisplay)
        {
            if (m_bGrabed == true)
            {
                try
                {
                    SetCalibNPointToNPointParam();

                    m_cogCalibNPointToNPointTool.Calibration.Calibrate();
                    m_bCalibrated = m_cogCalibNPointToNPointTool.Calibration.Calibrated;

                    if (m_bCalibrated)
                    {
                        ShowCalibratedPoints(aDisplay, false);
                        ShowCalibratedOrigin(aDisplay, false);
                    }
                }
                catch
                {
                    MessageBox.Show("Calibration Error!");
                    m_bCalibrated = false;
                    return(false);
                }
            }

            return(m_bCalibrated);
        }
Beispiel #12
0
        public void ShowCalibratedOrigin(ADisplay aDisplay, bool isSwapHandedness)
        {
            double               dOriginX, dOriginY;
            ICogTransform2D      transform2D;
            CogTransform2DLinear transform2DLinear = null;

            try
            {
                if (m_bCalibrated == true)
                {
                    TransCalibrated2UncalibratedCoord(m_dOriginX, m_dOriginY, out dOriginX, out dOriginY);

                    m_cogCoordinateAxes.OriginX = dOriginX;
                    m_cogCoordinateAxes.OriginY = dOriginY;

                    transform2D       = m_cogCalibNPointToNPointTool.Calibration.GetComputedUncalibratedFromCalibratedTransform();
                    transform2DLinear = transform2D.LinearTransform(m_dOriginX, m_dOriginY);

                    m_cogCoordinateAxes.Rotation = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation);
                    m_cogCoordinateAxes.Skew     = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation + m_dPI / 2) - (m_cogCoordinateAxes.Rotation + m_dPI / 2);
                }
                else
                {
                    TransCalibrated2UncalibratedCoord(m_dOriginX, m_dOriginY, out dOriginX, out dOriginY);

                    m_cogCoordinateAxes.OriginX = dOriginX;
                    m_cogCoordinateAxes.OriginY = dOriginY;

                    transform2D       = m_cogCalibNPointToNPointTool.Calibration.GetComputedUncalibratedFromCalibratedTransform();
                    transform2DLinear = transform2D.LinearTransform(m_dOriginX, m_dOriginY);

                    m_cogCoordinateAxes.Rotation = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation);
                    if (isSwapHandedness == false)
                    {
                        m_cogCoordinateAxes.Skew = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation + m_dPI / 2) - (m_cogCoordinateAxes.Rotation + m_dPI / 2);
                    }
                    else
                    {
                        m_cogCoordinateAxes.Skew = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation + m_dPI / 2 + m_dPI) - (m_cogCoordinateAxes.Rotation + m_dPI / 2);
                    }
                }

                //m_cogCoordinateAxes.GraphicDOFEnable = (CogCoordinateAxesDOFConstants)(-2147483644);//Position+Rotation
                m_cogCoordinateAxes.GraphicDOFEnable = CogCoordinateAxesDOFConstants.None;
                m_cogCoordinateAxes.Interactive      = true;
                m_cogCoordinateAxes.Color            = CogColorConstants.Cyan;
                m_cogCoordinateAxes.XAxisLabel.Color = CogColorConstants.Cyan;
                m_cogCoordinateAxes.YAxisLabel.Color = CogColorConstants.Cyan;
                m_cogCoordinateAxes.TipText          = "Calibrated Origin";
                aDisplay.AddOverlay(m_cogCoordinateAxes as ICogGraphicInteractive, "");
            }
            catch { }
        }
Beispiel #13
0
        public void SetRegion(ADisplay aDisplay)
        {
            ICogGraphicInteractive icogGraphInteractive = aDisplay.GetInteractiveGraphics("Region of Interest");

            if (icogGraphInteractive != null)
            {
                icogGraphInteractive.GraphicDOFEnableBase = CogGraphicDOFConstants.None;
                icogGraphInteractive.Color       = CogColorConstants.Cyan;
                icogGraphInteractive.Interactive = false;
            }

            m_icogRegion = icogGraphInteractive as ICogRegion;
        }
Beispiel #14
0
        public void ShowRegion(ADisplay aDisplay)
        {
            ICogRegion             icogRegion           = m_cogBlobTool.Region;
            ICogGraphicInteractive icogGraphInteractive = icogRegion as ICogGraphicInteractive;

            if (icogGraphInteractive != null)
            {
                icogGraphInteractive.GraphicDOFEnableBase = CogGraphicDOFConstants.None;
                icogGraphInteractive.Interactive          = false;
                icogGraphInteractive.Color = CogColorConstants.DarkGreen;
                aDisplay.AddOverlay(icogGraphInteractive, "");
            }
        }
        public ICogImage GrabCalibrationImage(ADisplay aDisplay)
        {
            if (aDisplay.Image != null)
            {
                m_cogCalibCheckerboardTool.Calibration.CalibrationImage = aDisplay.Image;
                m_icogImageCalibration = aDisplay.Image;
                m_bGrabed = true;
            }
            else
            {
                m_bGrabed = false;
            }

            return(m_icogImageCalibration);
        }
Beispiel #16
0
        public void ViewLastRegion(ADisplay aDisplay)
        {
            ICogRegion             icogRegion           = m_cogBlobTool.Region;
            ICogGraphicInteractive icogGraphInteractive = icogRegion as ICogGraphicInteractive;

            if (icogGraphInteractive != null)
            {
                icogGraphInteractive.GraphicDOFEnableBase = CogGraphicDOFConstants.All;
                icogGraphInteractive.Interactive          = true;
                // 2016.09.19 by kdi
                icogGraphInteractive.TipText = "Region of Interest";

                aDisplay.AddOverlay(icogGraphInteractive, "");
            }
        }
Beispiel #17
0
        public void RunHistogram(ADisplay aDisplayInput, bool bViewTxt, bool bShowRegion, double dX, double dY)
        {
            Run(aDisplayInput);
            ViewResult(aDisplayInput, bShowRegion);

            m_stResult.dMean   = Mean;
            m_stResult.nMedian = Median;
            // 2014.06.12
            m_stResult.dStandardDeviation = StandardDeviation;

            if (bViewTxt)
            {
                aDisplayInput.AddTxt(dX, dY, "Histogram:" + m_stResult.nMedian.ToString(), CogColorConstants.Green);
            }
        }
Beispiel #18
0
        // 2015.05.05
        public void ShowRegion(ADisplay aDisplay, string strSpaceName)
        {
            ICogRegion icogRegion = m_cogCaliperTool.Region.Copy(CogCopyShapeConstants.GeometryOnly);

            icogRegion.SelectedSpaceName = strSpaceName;
            ICogGraphicInteractive icogGraphInteractive = icogRegion as ICogGraphicInteractive;

            if (icogGraphInteractive != null)
            {
                icogGraphInteractive.GraphicDOFEnableBase = CogGraphicDOFConstants.None;
                icogGraphInteractive.Interactive          = false;
                icogGraphInteractive.Color = CogColorConstants.DarkGreen;

                aDisplay.AddOverlay(icogGraphInteractive, "");
            }
        }
Beispiel #19
0
        public void ViewResult(ADisplay displayInput, ADisplay displayOutput, bool isShowMedian, bool isShowMean, bool isShowRegion)
        {
            int nOption = 0;

            if (isShowMean)
            {
                nOption = nOption + 64;
            }
            if (isShowMedian)
            {
                nOption = nOption + 128;
            }

            // 2015.02.09
            if (isShowRegion)
            {
                ShowRegion(displayInput);
            }

            if (m_isRun)
            {
                CogHistogramResult histResult = new CogHistogramResult();
                histResult = m_cogHistogramTool.Result;

                if (histResult != null)
                {
                    // 2015.02.09

                    /*
                     * if (isShowRegion)
                     * {
                     *  ShowRegion(displayInput);
                     * }
                     */

                    CogCompositeShape compositeShape = new CogCompositeShape();
                    compositeShape = histResult.CreateResultGraphics((CogHistogramResultGraphicConstants)(1 + 2 + 16 + nOption));

                    if (displayOutput != null)
                    {
                        displayOutput.ClearAll();
                        displayOutput.AddOverlay((ICogGraphicInteractive)compositeShape, "");
                        displayOutput.Display.Fit(true);
                    }
                }
            }
        }
Beispiel #20
0
        // 2011.10.31
        private void ATbCalibCheckerboard_FormClosed(object sender, FormClosedEventArgs e)
        {
            tmrLive.Enabled = false;
            tmrTime.Enabled = false;

            // 2015.03.17
            cogDisplay.Dispose();
            cogDisplayStatusBar.Dispose();

            // 2017.01.09
            m_aCalibCheckerboard = null;
#if (!_USE_BASLER_PYLON && !_USE_IMAGING_CONTROL)
            m_aAcqFifo = null;
#endif
            m_aPoint   = null;
            m_aDisplay = null;
        }
Beispiel #21
0
        public void ViewResult(ADisplay aDisplay, bool isShowCenter, bool isShowRegion)
        {
            int nOption = 0;

            if (isShowCenter)
            {
                nOption = 2;
            }
            // 2015.02.09
            if (isShowRegion)
            {
                ShowRegion(aDisplay);
            }

            if (m_nFindCount > 0)
            {
                CogBlobResult cogBlobResult = new CogBlobResult();

                // 2016.03.22
                int[] pnID = new int[m_nFindCount];
                pnID = m_cogBlobTool.Results.GetBlobIDs(true);

                for (int i = 0; i < m_nFindCount; i++)
                {
                    // 2016.03.22 i => pnID[i]
                    cogBlobResult = m_cogBlobTool.Results.GetBlobByID(pnID[i]);

                    if (cogBlobResult != null)
                    {
                        CogCompositeShape cogCompositeShape = new CogCompositeShape();
                        cogCompositeShape = cogBlobResult.CreateResultGraphics((CogBlobResultGraphicConstants)(1 + 4 + nOption));
                        aDisplay.AddOverlay((ICogGraphicInteractive)cogCompositeShape, "");
                    }
                }

                // 2015.02.09

                /*
                 * if (isShowRegion)
                 * {
                 *  ShowRegion(aDisplay);
                 * }
                 */
            }
        }
Beispiel #22
0
        public ATbCalibNPointToNPoint(int nType, int nPoint, int nToolIndex)
        {
            InitializeComponent();
            cogDisplayStatusBar.Display = cogDisplay;
            m_aPoint     = AVisionProBuild.GetPoint(nType, nPoint);
            m_nType      = nType;
            m_nPoint     = nPoint;
            m_nToolIndex = nToolIndex;

            // 2014.10.30
#if (!_USE_BASLER_PYLON && !_USE_IMAGING_CONTROL && !_USE_1Camera)
            if (m_aPoint.GetToolCount("AcqFifo") > 0)
#endif
            {
                // 2014.10.30
#if (!_USE_BASLER_PYLON && !_USE_IMAGING_CONTROL && !_USE_1Camera)
                m_aAcqFifo = m_aPoint.GetTool("AcqFifo", 0) as AAcqFifo;
#elif _USE_1Camera
                m_aAcqFifo = AVisionProBuild.GetAcq();
#endif
            }

            // 2016.07.29
            if (m_aPoint.GetToolCount("CalibNPointToNPoint") > m_nToolIndex)
            {
                m_aCalibNPointToNPoint = m_aPoint.GetTool("CalibNPointToNPoint", m_nToolIndex) as ACalibNPointToNPoint;
            }
            else
            {
                m_aCalibNPointToNPoint = new ACalibNPointToNPoint();

                m_aCalibNPointToNPoint.Name = AVisionProBuild.MakeName("CalibNPointToNPoint", DateTime.Now);
                m_aPoint.Add("CalibNPointToNPoint", m_aCalibNPointToNPoint);
            }

            m_aDisplay    = new ADisplay(cogDisplay, "");
            lblTitle.Text = AVisionProBuild.GetTypeName(m_nType) + " [" + m_aPoint.Name + "]";

            //m_aDisplay.Display.Image = m_aCalibNPointToNPoint.InputImage;
            //m_aDisplay.Display.Fit(true);
            InitLanguage();
            // 2011.10.07 위치이동
            InitializeCalibration();
        }
Beispiel #23
0
        public void Run(ADisplay display)
        {
            SetHistParam();

            if (m_cogHistogramTool != null)
            {
                m_cogHistogramTool.InputImage = display.GetImage8Grey();
                if (m_icogImgMask != null)
                {
                    m_cogHistogramTool.RunParams.InputImageMask = m_icogImgMask;
                }

                try
                {
                    // 2015.04.08
                    m_bRan = false;

                    m_cogHistogramTool.Run();

                    // 2015.04.08
                    WaitRanEvent();

                    if (m_cogHistogramTool.Result != null)
                    {
                        m_nWGVThreshold = m_cogHistogramTool.Result.GetMinimumWGVThreshold();
                        m_nMinValue     = m_cogHistogramTool.Result.Minimum;
                        m_nMaxValue     = m_cogHistogramTool.Result.Maximum;
                        m_dMean         = m_cogHistogramTool.Result.Mean;
                        m_nMode         = m_cogHistogramTool.Result.Mode;
                        m_nMedian       = m_cogHistogramTool.Result.Median;
                        m_nSampleCount  = m_cogHistogramTool.Result.NumSamples;
                        // 2014.06.12
                        m_dStandardDeviation = m_cogHistogramTool.Result.StandardDeviation;

                        m_isRun = true;
                    }
                }
                catch
                {
                    MessageBox.Show("Run Histogram Error");
                    m_isRun = false;
                }
            }
        }
Beispiel #24
0
        /*
         * public void GetPointParam(ADisplay aDisplay)
         * {
         *  double dOriginX, dOriginY;
         *  ICogTransform2D transform2D;
         *  CogTransform2DLinear transform2DLinear = null;
         *  ICogGraphicInteractive axes = aDisplay.GetInteractiveGraphics("Calibrated Origin");
         *
         *  if (axes != null)
         *  {
         *      CogCoordinateAxes coordinateAxes = axes as CogCoordinateAxes;
         *
         *      dOriginX = coordinateAxes.OriginX;
         *      dOriginY = coordinateAxes.OriginY;
         *      TransUncalibrated2CalibratedCoord(dOriginX, dOriginY, out m_dOriginX, out m_dOriginY);
         *
         *      if (isShowDistorted == true)
         *      {
         *          transform2D = m_cogCalibNPointToNPointTool.Calibration.OwnedWarpParams.GetOutputImageRootFromCalibratedTransform();
         *          transform2DLinear = transform2D.LinearTransform(dOriginX, dOriginY).Invert();
         *          m_dRotation = transform2DLinear.MapAngle(m_cogCoordinateAxes.Rotation) + m_dCaibratedRotation;
         *      }
         *      else
         *      {
         *          transform2D = m_cogCalibNPointToNPointTool.Calibration.GetComputedUncalibratedFromCalibratedTransform();
         *          transform2DLinear = transform2D.LinearTransform(m_dOriginX, m_dOriginY).Invert();
         *          m_dRotation = transform2DLinear.MapAngle(coordinateAxes.Rotation) + m_dCaibratedRotation;
         *      }
         *  }
         * }
         */

        public void GetAxesParam(ADisplay aDisplay)
        {
            double                 dOriginX, dOriginY;
            ICogTransform2D        transform2D;
            CogTransform2DLinear   transform2DLinear = null;
            ICogGraphicInteractive axes = aDisplay.GetInteractiveGraphics("Calibrated Origin");

            if (axes != null)
            {
                CogCoordinateAxes coordinateAxes = axes as CogCoordinateAxes;

                dOriginX = coordinateAxes.OriginX;
                dOriginY = coordinateAxes.OriginY;
                TransUncalibrated2CalibratedCoord(dOriginX, dOriginY, out m_dOriginX, out m_dOriginY);

                transform2D       = m_cogCalibNPointToNPointTool.Calibration.GetComputedUncalibratedFromCalibratedTransform();
                transform2DLinear = transform2D.LinearTransform(m_dOriginX, m_dOriginY).Invert();
                m_dRotation       = transform2DLinear.MapAngle(coordinateAxes.Rotation) + m_dCaibratedRotation;
            }
        }
Beispiel #25
0
        // 2014.03.27
        public int Run(ADisplay aDisplay)
        {
            m_stResult.dX     = 0;
            m_stResult.dY     = 0;
            m_stResult.dAngle = 0;

            if (m_cogFindCornerTool != null)
            {
                InputImage = aDisplay.Image;

                // 2015.04.08
                m_bRan = false;

                m_cogFindCornerTool.Run();

                // 2015.04.08
                WaitRanEvent();

                m_stResult.nR = (int)m_cogFindCornerTool.RunStatus.Result;
                // 2014.08.28
                if (m_stResult.nR == 0 && m_cogFindCornerTool.Result.CornerFound == true)
                {
                    m_stResult.dX = m_cogFindCornerTool.Result.CornerX;
                    m_stResult.dY = m_cogFindCornerTool.Result.CornerY;
                    // 2016.11.10
                    m_stResult.dAngle =
                        (m_cogFindCornerTool.Result.LineResultsB.GetLine().Rotation - m_cogFindCornerTool.Result.LineResultsA.GetLine().Rotation)
                        * (180 / Math.PI);
                }
                else
                {
                    m_stResult.nR = -2;
                }
            }
            else
            {
                m_stResult.nR = -1;
            }

            return(m_stResult.nR);
        }
Beispiel #26
0
        public int Run(ADisplay aDisplay)
        {
            // 2016.03.22
            m_nFindCount = 0;

            SetBlobParam();

            if (m_cogBlobTool != null)
            {
                m_cogBlobTool.InputImage = aDisplay.GetImage8Grey();
                if (m_cogimgMask != null)
                {
                    m_cogBlobTool.RunParams.InputImageMask = m_cogimgMask;
                }

                try
                {
                    // 2015.04.08
                    m_bRan = false;

                    m_cogBlobTool.Run();

                    // 2015.04.08
                    WaitRanEvent();

                    if (m_cogBlobTool.Results != null)
                    {
                        // 2011.05.24
                        m_nFindCount = m_cogBlobTool.Results.GetBlobs().Count;
                    }
                }
                catch
                {
                    MessageBox.Show("Run Blob Error");
                }
            }

            return(m_nFindCount);
        }
        public int Run(ADisplay aDisplay)
        {
            m_stResult.dX       = 0;
            m_stResult.dY       = 0;
            m_stResult.dRadiusX = 0;
            m_stResult.dRadiusY = 0;

            if (m_cogFindEllipseTool != null)
            {
                InputImage = aDisplay.Image;

                // 2015.04.08
                m_bRan = false;

                m_cogFindEllipseTool.Run();

                // 2015.04.08
                WaitRanEvent();

                m_stResult.nR = (int)m_cogFindEllipseTool.RunStatus.Result;
                if (m_stResult.nR == 0 && m_cogFindEllipseTool.Results.GetEllipse() != null)
                {
                    m_stResult.dX       = m_cogFindEllipseTool.Results.GetEllipse().CenterX;
                    m_stResult.dY       = m_cogFindEllipseTool.Results.GetEllipse().CenterY;
                    m_stResult.dRadiusX = m_cogFindEllipseTool.Results.GetEllipse().RadiusX;
                    m_stResult.dRadiusY = m_cogFindEllipseTool.Results.GetEllipse().RadiusY;
                }
                else
                {
                    m_stResult.nR = -2;
                }
            }
            else
            {
                m_stResult.nR = 2;
            }

            return(m_stResult.nR);
        }
        public void ShowCalibratedPoints(ADisplay aDisplay, bool isShowDistorted, bool isSwapHandedness)
        {
            try
            {
                int pointCount = m_cogCalibCheckerboardTool.Calibration.NumPoints;

                if (isShowDistorted == true)
                {
                    double x, y, mappedX, mappedY;
                    aDisplay.ClearAll();
                    aDisplay.Display.Image = m_cogCalibCheckerboardTool.Calibration.OwnedWarpParams.UndistortedCalibrationImage;
                    aDisplay.Display.Fit(true);
                    ICogGraphic mask = m_cogCalibCheckerboardTool.Calibration.OwnedWarpParams.OutputImageMask as ICogGraphic;
                    if (mask != null)
                    {
                        aDisplay.AddStaticGraphic(mask, "");
                    }

                    for (int i = 0; i < pointCount; i++)
                    {
                        CogPointMarker cogPointMaker = new CogPointMarker();
                        x = m_cogCalibCheckerboardTool.Calibration.GetUncalibratedPointX(i);
                        y = m_cogCalibCheckerboardTool.Calibration.GetUncalibratedPointY(i);

                        ICogTransform2D transform2D = m_cogCalibCheckerboardTool.Calibration.OwnedWarpParams.GetInputPixelFromOutputPixelTransform(aDisplay.Image);
                        transform2D.InvertBase().MapPoint(x, y, out mappedX, out mappedY);

                        cogPointMaker.GraphicType      = CogPointMarkerGraphicTypeConstants.Crosshair;
                        cogPointMaker.Color            = CogColorConstants.Magenta;
                        cogPointMaker.X                = mappedX;
                        cogPointMaker.Y                = mappedY;
                        cogPointMaker.GraphicDOFEnable = CogPointMarkerDOFConstants.None;
                        cogPointMaker.Interactive      = true;
                        cogPointMaker.TipText          = "Uncalibrated Point " + i.ToString();

                        aDisplay.AddOverlay(cogPointMaker as ICogGraphicInteractive, "");
                    }
                }
                else
                {
                    aDisplay.ClearAll();
                    aDisplay.Display.Image = m_cogCalibCheckerboardTool.Calibration.CalibrationImage;
                    aDisplay.Display.Fit(true);

                    for (int i = 0; i < pointCount; i++)
                    {
                        CogPointMarker cogPointMaker = new CogPointMarker();

                        cogPointMaker.GraphicType      = CogPointMarkerGraphicTypeConstants.Crosshair;
                        cogPointMaker.Color            = CogColorConstants.Magenta;
                        cogPointMaker.X                = m_cogCalibCheckerboardTool.Calibration.GetUncalibratedPointX(i);
                        cogPointMaker.Y                = m_cogCalibCheckerboardTool.Calibration.GetUncalibratedPointY(i);
                        cogPointMaker.GraphicDOFEnable = CogPointMarkerDOFConstants.None;
                        cogPointMaker.Interactive      = true;
                        cogPointMaker.TipText          = "Uncalibrated Point " + i.ToString();

                        aDisplay.AddOverlay(cogPointMaker as ICogGraphicInteractive, "");
                    }
                }

                ShowCalibratedOrigin(aDisplay, isShowDistorted, isSwapHandedness);
            }
            catch { }
        }
        public void ShowCalibratedOrigin(ADisplay aDisplay, bool isShowDistorted, bool isSwapHandedness)
        {
            double               dOriginX, dOriginY, dMappedX, dMappedY;
            ICogTransform2D      transform2D;
            CogTransform2DLinear transform2DLinear = null;

            try
            {
                if (m_bCalibrated == true)
                {
                    if (m_emComputationMode == CogCalibFixComputationModeConstants.Linear)
                    {
                        TransCalibrated2UncalibratedCoord(m_dOriginX, m_dOriginY, out dOriginX, out dOriginY);

                        m_cogCoordinateAxes.OriginX = dOriginX;
                        m_cogCoordinateAxes.OriginY = dOriginY;

                        transform2D       = m_cogCalibCheckerboardTool.Calibration.GetComputedUncalibratedFromCalibratedTransform();
                        transform2DLinear = transform2D.LinearTransform(m_dOriginX, m_dOriginY);

                        m_cogCoordinateAxes.Rotation = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation);
                        m_cogCoordinateAxes.Skew     = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation + m_dPI / 2) - (m_cogCoordinateAxes.Rotation + m_dPI / 2);
                    }
                    else if (m_emComputationMode == CogCalibFixComputationModeConstants.PerspectiveAndRadialWarp)
                    {
                        if (isShowDistorted == true)
                        {
                            transform2D = m_cogCalibCheckerboardTool.Calibration.OwnedWarpParams.GetOutputImageRootFromCalibratedTransform();
                            transform2D.MapPoint(m_dOriginX - m_dCaibratedOriginX, m_dOriginY - m_dCaibratedOriginY, out dMappedX, out dMappedY);

                            m_cogCoordinateAxes.OriginX = dMappedX;
                            m_cogCoordinateAxes.OriginY = dMappedY;

                            transform2DLinear            = transform2D.LinearTransform(dMappedX, dMappedY);
                            m_cogCoordinateAxes.Rotation = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation);
                            m_cogCoordinateAxes.Skew     = transform2DLinear.Skew;
                        }
                        else
                        {
                            TransCalibrated2UncalibratedCoord(m_dOriginX, m_dOriginY, out dOriginX, out dOriginY);

                            m_cogCoordinateAxes.OriginX = dOriginX;
                            m_cogCoordinateAxes.OriginY = dOriginY;

                            transform2D       = m_cogCalibCheckerboardTool.Calibration.GetComputedUncalibratedFromCalibratedTransform();
                            transform2DLinear = transform2D.LinearTransform(m_dOriginX, m_dOriginY);

                            m_cogCoordinateAxes.Rotation = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation);
                            m_cogCoordinateAxes.Skew     = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation + m_dPI / 2) - (m_cogCoordinateAxes.Rotation + m_dPI / 2);
                        }
                    }
                }
                else
                {
                    if (m_emComputationMode == CogCalibFixComputationModeConstants.Linear)
                    {
                        TransCalibrated2UncalibratedCoord(m_dOriginX, m_dOriginY, out dOriginX, out dOriginY);

                        m_cogCoordinateAxes.OriginX = dOriginX;
                        m_cogCoordinateAxes.OriginY = dOriginY;

                        transform2D       = m_cogCalibCheckerboardTool.Calibration.GetComputedUncalibratedFromCalibratedTransform();
                        transform2DLinear = transform2D.LinearTransform(m_dOriginX, m_dOriginY);

                        m_cogCoordinateAxes.Rotation = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation);
                        if (isSwapHandedness == false)
                        {
                            m_cogCoordinateAxes.Skew = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation + m_dPI / 2) - (m_cogCoordinateAxes.Rotation + m_dPI / 2);
                        }
                        else
                        {
                            m_cogCoordinateAxes.Skew = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation + m_dPI / 2 + m_dPI) - (m_cogCoordinateAxes.Rotation + m_dPI / 2);
                        }
                    }
                    else if (m_emComputationMode == CogCalibFixComputationModeConstants.PerspectiveAndRadialWarp)
                    {
                        if (isShowDistorted == true)
                        {
                            transform2D = m_cogCalibCheckerboardTool.Calibration.OwnedWarpParams.GetOutputImageRootFromCalibratedTransform();
                            transform2D.MapPoint(m_dOriginX - m_dCaibratedOriginX, m_dOriginY - m_dCaibratedOriginY, out dMappedX, out dMappedY);

                            m_cogCoordinateAxes.OriginX = dMappedX;
                            m_cogCoordinateAxes.OriginY = dMappedY;

                            transform2DLinear            = transform2D.LinearTransform(dMappedX, dMappedY);
                            m_cogCoordinateAxes.Rotation = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation);
                            if (isSwapHandedness == false)
                            {
                                m_cogCoordinateAxes.Skew = transform2DLinear.Skew;
                            }
                            else
                            {
                                m_cogCoordinateAxes.Skew = transform2DLinear.Skew + m_dPI;
                            }
                        }
                        else
                        {
                            TransCalibrated2UncalibratedCoord(m_dOriginX, m_dOriginY, out dOriginX, out dOriginY);

                            m_cogCoordinateAxes.OriginX = dOriginX;
                            m_cogCoordinateAxes.OriginY = dOriginY;

                            transform2D       = m_cogCalibCheckerboardTool.Calibration.GetComputedUncalibratedFromCalibratedTransform();
                            transform2DLinear = transform2D.LinearTransform(m_dOriginX, m_dOriginY);

                            m_cogCoordinateAxes.Rotation = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation);
                            if (isSwapHandedness == false)
                            {
                                m_cogCoordinateAxes.Skew = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation + m_dPI / 2) - (m_cogCoordinateAxes.Rotation + m_dPI / 2);
                            }
                            else
                            {
                                m_cogCoordinateAxes.Skew = transform2DLinear.MapAngle(m_dRotation - m_dCaibratedRotation + m_dPI / 2 + m_dPI) - (m_cogCoordinateAxes.Rotation + m_dPI / 2);
                            }
                        }
                    }
                }

                m_cogCoordinateAxes.GraphicDOFEnable = (CogCoordinateAxesDOFConstants)(-2147483644);//Position+Rotation
                m_cogCoordinateAxes.Interactive      = true;
                m_cogCoordinateAxes.Color            = CogColorConstants.Cyan;
                m_cogCoordinateAxes.XAxisLabel.Color = CogColorConstants.Cyan;
                m_cogCoordinateAxes.YAxisLabel.Color = CogColorConstants.Cyan;
                m_cogCoordinateAxes.TipText          = "Calibrated Origin";
                aDisplay.AddOverlay(m_cogCoordinateAxes as ICogGraphicInteractive, "");
            }
            catch { }
        }
Beispiel #30
0
        public bool GrabRegion(ADisplay aDisplay, AVisionProBuild._emRegionShape emRegionShape)
        {
            aDisplay.ClearOverlay();

            ICogGraphicInteractive icogGraphInteractive = null;
            ICogRegion             icogRegion           = m_cogBlobTool.Region;

            CogCircle                   circle             = icogRegion as CogCircle;
            CogEllipse                  ellipse            = icogRegion as CogEllipse;
            CogRectangle                rectangle          = icogRegion as CogRectangle;
            CogRectangleAffine          rectangleAffine    = icogRegion as CogRectangleAffine;
            CogCircularAnnulusSection   circularAnnuluns   = icogRegion as CogCircularAnnulusSection;
            CogEllipticalAnnulusSection ellipticalAnnuluns = icogRegion as CogEllipticalAnnulusSection;

            switch (emRegionShape)
            {
            case AVisionProBuild._emRegionShape.Circle:
            {
                if (circle == null)
                {
                    circle = new CogCircle();
                    circle.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5);
                }
                icogGraphInteractive = circle as ICogGraphicInteractive;
            }
            break;

            case AVisionProBuild._emRegionShape.Ellipse:
            {
                if (ellipse == null)
                {
                    ellipse = new CogEllipse();
                    ellipse.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5);
                }
                icogGraphInteractive = ellipse as ICogGraphicInteractive;
            }
            break;

            case AVisionProBuild._emRegionShape.Rectangle:
            {
                if (rectangle == null)
                {
                    rectangle = new CogRectangle();
                    rectangle.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5);
                }
                icogGraphInteractive = rectangle as ICogGraphicInteractive;
            }
            break;

            case AVisionProBuild._emRegionShape.RectangleAffine:
            {
                if (rectangleAffine == null)
                {
                    rectangleAffine = new CogRectangleAffine();
                    rectangleAffine.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5);
                }
                icogGraphInteractive = rectangleAffine as ICogGraphicInteractive;
            }
            break;

            case AVisionProBuild._emRegionShape.CircularAnnulusSection:
            {
                if (circularAnnuluns == null)
                {
                    circularAnnuluns = new CogCircularAnnulusSection();
                    circularAnnuluns.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5);
                }
                icogGraphInteractive = circularAnnuluns as ICogGraphicInteractive;
            }
            break;

            case AVisionProBuild._emRegionShape.EllipticalAnnulusSection:
            {
                if (ellipticalAnnuluns == null)
                {
                    ellipticalAnnuluns = new CogEllipticalAnnulusSection();
                    ellipticalAnnuluns.FitToImage(aDisplay.GetImage8Grey(), 0.5, 0.5);
                }
                icogGraphInteractive = ellipticalAnnuluns as ICogGraphicInteractive;
            }
            break;

            case AVisionProBuild._emRegionShape.Entire:
            {
                m_icogRegion = null;
                aDisplay.ClearOverlay();
            }
            break;

            default:
                m_icogRegion = null;

                return(false);
            }

            if (icogGraphInteractive != null)
            {
                icogGraphInteractive.GraphicDOFEnableBase = CogGraphicDOFConstants.All;
                icogGraphInteractive.Interactive          = true;
                icogGraphInteractive.TipText = "Region of Interest";
                aDisplay.AddOverlay(icogGraphInteractive, "");
            }

            return(true);
        }