Ejemplo n.º 1
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, "");
            }
        }
Ejemplo n.º 2
0
 private void AcqFifoTool_Ran(object sender, System.EventArgs e)
 {
     cogRecordDisplay1.InteractiveGraphics.Clear();
     cogRecordDisplay1.StaticGraphics.Clear();
     calbCheckerBoard            = cogToolBlockEditV21.Subject.Tools["CogCalibCheckerboardTool1"] as CogCalibCheckerboardTool;
     calbCheckerBoard.InputImage = AcqFifoTool.OutputImage;
     calbCheckerBoard.Run();
     CalibNPointTool            = cogToolBlockEditV21.Subject.Tools["CogCalibNPointToNPointTool1"] as CogCalibNPointToNPointTool;
     CalibNPointTool.InputImage = calbCheckerBoard.OutputImage;
     CalibNPointTool.Run();
     if (flagDisplayResult)  //add on 25/11/14
     {
         cogRecordDisplay1.Image = cogPMAlignTool.InputImage;
     }
     cogPMAlignTool.InputImage       = CalibNPointTool.OutputImage as CogImage8Grey;
     PatMaxTool.InputImage           = AcqFifoTool.OutputImage as CogImage8Grey;
     PatMaxTool.InputImage           = CalibNPointTool.OutputImage as CogImage8Grey;
     ImageFileTool.InputImage        = AcqFifoTool.OutputImage;
     static_AcqFifoTool_Ran_numacqs += 1;
     if (static_AcqFifoTool_Ran_numacqs > 4)
     {
         GC.Collect();
         static_AcqFifoTool_Ran_numacqs = 0;
     }
 }
Ejemplo n.º 3
0
        private void RunTool(int imagePathSn)
        {
            if (testImagePathList.Count > imagePathSn)
            {
                CogImage8Grey img = new CogImage8Grey(new Bitmap(testImagePathList[imagePathSn]));
                //var imgFile = new CogImageFileTool();
                //imgFile.Operator.Open(testImagePathList[imagePathSn], CogImageFileModeConstants.Read);
                //imgFile.Run();
                //ICogImage img = imgFile.OutputImage;
                if (_enableCheckerboard)
                {
                    _cogCalibCheckerboard.InputImage = img;
                    _cogCalibCheckerboard.Run();
                    img = (CogImage8Grey)_cogCalibCheckerboard.OutputImage;
                }
                _cogToolBlock.Inputs[1].Value = img;
                if (_enableCalibNPointToNPoint)
                {
                    _cogCalibNPointToNPoint.InputImage = img;
                    _cogCalibNPointToNPoint.Run();
                    img = (CogImage8Grey)_cogCalibNPointToNPoint.OutputImage;
                }
                _cogToolBlock.Inputs[0].Value = img;
                _cogToolBlock.Run();

                _imageSelectCount = imagePathSn + 1;
                RefreshImageCount();
            }
            else
            {
                MessageBox.Show(@"找不到指定图片");
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)  //Teach
        {
            if (!SettingUp)
            {
                if ((!AppGen.Inst.MDImain.frmVisionMain.FrmUnloadCarrier.flagFullTray))
                {
                    MessageBox.Show("Please acquire full frame");
                    return;
                }
                cogPMAlignTool.Pattern.TrainImage = CalibNPointTool.OutputImage as CogImage8Grey;
                //While setting up PMAlign, disable other GUI controls.
                SettingUp = true;
                DisableAll(settingUpPatMax);
                //Add TrainRegion to display's interactive graphics
                //Add SearchRegion to display's static graphics for display only.
                cogRecordDisplay1.InteractiveGraphics.Clear();
                cogRecordDisplay1.StaticGraphics.Clear();

                cogRecordDisplay1.InteractiveGraphics.Add(cogPMAlignTool.Pattern.TrainRegion as ICogGraphicInteractive, "test", false);

                //Now
                axes                  = new CogCoordinateAxes();
                axes.Transform        = cogPMAlignTool.Pattern.Origin;
                axes.GraphicDOFEnable = CogCoordinateAxesDOFConstants.All &
                                        ~CogCoordinateAxesDOFConstants.Skew;
                axes.Interactive = true;
                // Add a standard VisionPro "manipulable" mouse cursor.
                axes.MouseCursor            = CogStandardCursorConstants.ManipulableGraphic;
                axes.XAxisLabel.MouseCursor = CogStandardCursorConstants.ManipulableGraphic;
                axes.YAxisLabel.MouseCursor = CogStandardCursorConstants.ManipulableGraphic;
                cogRecordDisplay1.InteractiveGraphics.Add((ICogGraphicInteractive)axes, "test", false);



                //if ((cogPMAlignTool.SearchRegion != null))
                //{
                //    //cogPMAlignTool.SearchRegion.FitToImage(cogRecordDisplay1.Image, 0.990,0.999);
                //    cogRecordDisplay1.StaticGraphics.Add(cogPMAlignTool.SearchRegion as ICogGraphic, "test");
                //    cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image;
                //}

                //OK has been pressed, completing Setup.
            }
            else
            {
                SettingUp = false;
                cogRecordDisplay1.InteractiveGraphics.Clear();
                cogRecordDisplay1.StaticGraphics.Clear();
                //Make sure we catch errors from Train, since they are likely.  For example,
                //No InputImage, No Pattern Features, etc.
                try
                {
                    CalibNPointTool = cogToolBlockEditV21.Subject.Tools["CogCalibNPointToNPointTool1"] as CogCalibNPointToNPointTool;
                    CalibNPointTool.Run();
                    cogPMAlignTool.Pattern.Train();


                    //SavePatternToFile();
                    //save the teach pattern according to order name (ziv)
                    AppGen.Inst.MDImain.frmVisionMain.savePattern("Camera3", AppGen.Inst.OrderParams.InsertCode, cogPMAlignTool.Pattern);
                }
                catch (CogException cogex)
                {
                    MessageBox.Show("Following Specific Cognex Error Occured:" + cogex.Message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "PatMax Setup Error");
                }
                EnableAll(settingUpPatMax);
            }
        }