示例#1
0
        public MainWindow()
        {
            InitializeComponent();

            camList  = new List <GigECamInfo>();
            grabbers = new CogFrameGrabbers();

            if (grabbers.Count != 0)
            {
                for (int i = 0; i < grabbers.Count; i++)
                {
                    ICogFrameGrabber grabber    = grabbers[i];
                    ICogGigEAccess   gigEAccess = grabber.OwnedGigEAccess;
                    string           vendor     = gigEAccess.GetFeature("DeviceVendorName");

                    camList.Add(new GigECamInfo()
                    {
                        Name = grabber.Name, SerialNumber = grabber.SerialNumber, VendorName = vendor
                    });
                }
            }

            dataGrid.ItemsSource = camList;

            display   = new CogDisplay();
            WFH.Child = display;

            fifo                   = grabbers[0].CreateAcqFifo("Generic GigEVision (Mono)", CogAcqFifoPixelFormatConstants.Format8Grey, 0, false);
            textBlock.Text         = grabbers[0].Name;
            dataGrid.SelectedIndex = 0;
        }
示例#2
0
        public CameraVPro()
        {
            // Thiết lập Camera đầu vào
            CogAcqFifoEdit         = new CogAcqFifoEditV2();
            CogAcqFifoEdit.Subject = new CogAcqFifoTool();

            // Khai báo tool Calib. Đầu vào ảnh từ Tool Acq.
            CogCalibGrid         = new CogCalibCheckerboardEditV2();
            CogCalibGrid.Subject = new CogCalibCheckerboardTool();

            // Khai báo hiển thị đầu ra
            CogDisplayOut              = new CogDisplay();
            CogDisplayOut.DoubleClick += ProcessDoubleClickDisplay;

            // Khai báo tool Align. Mặc định link đầu vào ảnh với Tool Acq
            CogPMAlign         = new CogPMAlignEditV2();
            CogPMAlign.Subject = new CogPMAlignTool();

            // Khai báo Tool AutoCalib
            RTCAutoCalibTool = new AutoCalibTool();
            // Khởi tạo Autocalib
            AutoCalibRunning = false;

            // Khởi tạo CameraIndex
            currentCameraIndex = -1;
        }
 public CrossHairsControl(CogDisplay cogDisplay, bool validCamera)
 {
     _cogDisplay = cogDisplay;
     _validCam   = validCamera;
     Location    = cogDisplay.Location;
     Size        = cogDisplay.Size;
     TabIndex    = 1;
     ResetCrossHairs();
 }
        void CogDisplay_Changed(object sender, CogChangedEventArgs e)
        {
            CogDisplay cog = (sender as CogDisplay);

            if (cog.Parent.Controls.ContainsKey(CROSSHAIRSCTLNAME))
            {
                cog.Parent.Controls[CROSSHAIRSCTLNAME].Invalidate();
            }
        }
        private void StopLiveDisplay(CogDisplay display)
        {
            if (display.InvokeRequired)
            {
                display.BeginInvoke(new _delParamCogDisplay(StopLiveDisplay), new object[] { display });
                return;
            }

            display.StopLiveDisplay();
        }
        //void CogDisplay_Paint(object sender, PaintEventArgs e)
        //{
        //    e.Graphics.DrawLine(Pens.LightPink, 0, 0, 110, 110);
        //}

        //void OnCogDisplay_Changed(object sender, CogChangedEventArgs e)
        //{

        //    (sender as CogDisplay).
        //}

        private CogDisplay GetCogDisplay(Control parentWindow)
        {
            CogDisplay cogDisplay = parentWindow.Controls.ContainsKey(COGNEXWINDOWNAME) ? parentWindow.Controls[COGNEXWINDOWNAME] as CogDisplay : null;

            if (cogDisplay != null && _cogDisplayWindows.Contains(cogDisplay))
            {
                return(cogDisplay);
            }
            return(null);
        }
 public override void UnregisterCameraWindow(Control parentWindow)
 {
     lock (LockCogDisplay)
     {
         CogDisplay cogDisplay = GetCogDisplay(parentWindow);
         if (cogDisplay != null && _cogDisplayWindows.Contains(cogDisplay))
         {
             _cogDisplayWindows.Remove(cogDisplay);
         }
     }
 }
示例#8
0
        public MainWindow()
        {
            InitializeComponent();

            fifo         = CogSerializer.LoadObjectFromFile(@"C:\Users\jkhong\Desktop\fifo.vpp") as CogAcqFifoTool;
            IsFreeRun    = true;
            textBox.Text = "FreeRun";

            display   = new CogDisplay();
            WFH.Child = display;
        }
        private void CogDisplay_MouseDown(object sender, MouseEventArgs e)
        {
            CogDisplay cogDisplay = sender as CogDisplay;

            if (cogDisplay != null)
            {
                CrossHairsControl crossHairsCtl = cogDisplay.Tag as CrossHairsControl;
                if (crossHairsCtl != null)
                {
                    crossHairsCtl.CogMouseDown(e);
                }
            }
        }
        private void SetCogImage(CogDisplay cogDisplay, ICogImage cogImage)
        {
            if (cogDisplay.InvokeRequired)
            {
                cogDisplay.BeginInvoke(new _delParamCogImage(SetCogImage), new object[] { cogDisplay, cogImage });
                return;
            }

            try
            {
                cogDisplay.Image = cogImage;
            }
            catch (Exception ex)
            {
                U.LogError(ex, "Unable to set CognexWindow image");
            }
        }
示例#11
0
        public VisionJob()
        {
            toolBlockEdit = new CogToolBlockEditV2();
            toolGroupEdit = new CogToolGroupEditV2();

            // Temp hiển thị tool Imagefile Select
            imageFileTool         = new CogImageFileTool();
            imageFileEdit         = new CogImageFileEditV2();
            imageFileEdit.Subject = imageFileTool;

            // Thiết lập Camera đầu vào
            acqFifoTool         = new CogAcqFifoEditV2();
            acqFifoTool.Subject = new CogAcqFifoTool();


            // Load thư viện ảnh mặc định
            cogDisplayMain = new CogDisplay();
            ImageFileTool.Operator.Open(@"C:\Program Files\Cognex\VisionPro\Images\CheckCal.idb", CogImageFileModeConstants.Read);

            // Link ảnh đầu ra với ảnh đầu vào
            // Tắt tạm thời ảnh vào từ Imagefile
            // Load ảnh trực tiếp từ Camera
            //cogDisplayMain.DataBindings.Add("Image", ImageFileTool, "OutputImage", true);
            cogDisplayMain.DataBindings.Add("Image", AcqFifoTool.Subject, "OutputImage", true);

            // Tool Align
            pmAlignTool         = new CogPMAlignEditV2();
            pmAlignTool.Subject = new CogPMAlignTool();
            //pmAlignTool.Subject.DataBindings.Add("InputImage", ImageFileTool, "OutputImage");
            pmAlignTool.Subject.DataBindings.Add("InputImage", AcqFifoTool.Subject, "OutputImage");

            // Cấu hình Tool Calib
            calibGribCBTool         = new CogCalibCheckerboardEditV2();
            calibGribCBTool.Subject = new CogCalibCheckerboardTool();
            // Sửa đầu vào Tool Calib
            //calibGribCBTool.Subject.DataBindings.Add("InputImage", ImageFileTool, "OutputImage");
            calibGribCBTool.Subject.DataBindings.Add("InputImage", AcqFifoTool.Subject, "OutputImage");

            calibGribCBTool.Subject.Calibration.Changed += UpdateCalibImage;
            pmAlignTool.SubjectChanged     += UpdateCalibImage;
            calibGribCBTool.SubjectChanged += UpdateImageSource;

            //
        }
示例#12
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 초기화
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        private bool Initialize()
        {
            bool bReturn   = false;
            var  pDocument = CDocument.GetDocument;

            do
            {
                InitializeForm();
                timer1.Start();
                m_objCogDisplayMain = cogDisplayRunImage;
                // m_objRecipeParameter = pDocument.m_objConfig.GetRecipeParameter( ( int )CDefine.enumCamera.CAMERA_1 );
                m_objFindLineToolTop    = new CogFindLineTool();
                m_objFindLineToolBottom = new CogFindLineTool();
                m_iPositionCrop         = 0;
                Reload();
                bReturn = true;
            } while(false);

            return(bReturn);
        }
示例#13
0
        /// <summary>
        /// Displays a alignment reticle in middle of image
        /// </summary>
        public void DisplayReticle2(int cameraModule, CogDisplay cogDisplay)
        {
            if (cogDisplay != null)
            {
                // remove any old group

                foreach (string groupName in cogDisplay.StaticGraphics.ZOrderGroups)
                {
                    if (groupName == "Reticle")
                    {
                        cogDisplay.StaticGraphics.Remove("Reticle");
                    }
                }
                // image must be visible to see
                CogLineSegment cogLineSegment;

                cogLineSegment = new CogLineSegment();

                // vertical line
                cogLineSegment.SelectedSpaceName = "#";
                cogLineSegment.StartX            = this.displaySizeX[cameraModule] / 2;
                cogLineSegment.StartY            = 0;
                cogLineSegment.EndX  = this.displaySizeX[cameraModule] / 2;
                cogLineSegment.EndY  = this.displaySizeY[cameraModule];
                cogLineSegment.Color = CogColorConstants.Blue;
                cogLineSegment.LineWidthInScreenPixels = 1;

                cogDisplay.StaticGraphics.Add(cogLineSegment, "Reticle");

                // horizontal line
                cogLineSegment.StartX = 0;
                cogLineSegment.StartY = this.displaySizeY[cameraModule] / 2;
                cogLineSegment.EndX   = this.displaySizeX[cameraModule];
                cogLineSegment.EndY   = this.displaySizeY[cameraModule] / 2;

                cogDisplay.StaticGraphics.Add(cogLineSegment, "Reticle");
            }
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //추가 :
        //목적 : 초기화
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool Initialize(CogDisplay objCogDisplay)
        {
            bool bReturn = false;

            do
            {
                // 메인 코그 디스플레이 연결
                m_objCogDisplayMain = objCogDisplay;
                // 초기화 언어 변경
                SetChangeLanguage();
                // 버튼 이벤트 로그 정의
                SetButtonEventChange();
                // 버튼 색상 정의
                SetButtonColor();
                // 타이머 외부에서 제어
                timer.Interval = 100;
                timer.Enabled  = false;

                bReturn = true;
            } while(false);

            return(bReturn);
        }
示例#15
0
 public ADisplay(CogDisplay cogDisplay, string strName)
 {
     m_cogDisplay = cogDisplay;
     m_strName    = strName;
 }
示例#16
0
        private void AssignCogRecordToDisplay(Control cogDisplay, ICogRecord cogRecord)
        {
            if (cogDisplay.Visible != true)
            {
                return;
            }

            if (cogDisplay.InvokeRequired)
            {
                cogDisplay.BeginInvoke(new _delParamCogDisplayIcogRecord(AssignCogRecordToDisplay), new object[] { cogDisplay, cogRecord });
                return;
            }

            if (cogDisplay is CogRecordsDisplay)
            {
                (cogDisplay as CogRecordsDisplay).Subject = cogRecord;
            }

            else if (cogDisplay is CogDisplay)
            {
                CogDisplay cDisplay = cogDisplay as CogDisplay;
                try
                {
                    //cogDisplay.Visible = false;
                    if (cogRecord.SubRecords == null || cogRecord.SubRecords.Count == 0)
                    {
                        return;
                    }


                    if (cogRecord.Content != null && cogRecord.Content is List <ICogRecord> )
                    {
                        List <ICogRecord> recordList = cogRecord.Content as List <ICogRecord>;
                        CogGraphicInteractiveCollection cogGraphicInteractCollection = new CogGraphicInteractiveCollection();
                        foreach (ICogRecord record in recordList)
                        {
                            // Assign image if it is not there
                            if ((cDisplay.Image == null || !(cDisplay.Image is CogImage8Grey)) &&
                                CogCamera != null)
                            {
                                // Assign image
                                lock (CogCamera.LockCogDisplay)
                                {
                                    cDisplay.Image = record.SubRecords[0].Content as ICogImage;
                                    cDisplay.Fit(true);
                                }
                            }

                            cDisplay.InteractiveGraphics.Clear();

                            if (IsDisplayGraphic)
                            {
                                //Assign graphic if any
                                foreach (ICogRecord subRecord in record.SubRecords[0].SubRecords)
                                {
                                    if (subRecord.Content is CogGraphicCollection)
                                    {
                                        CogGraphicCollection contentCollect = subRecord.Content as CogGraphicCollection;
                                        if (contentCollect != null)
                                        {
                                            foreach (CogCompositeShape graphic in contentCollect)
                                            {
                                                //cDisplay.InteractiveGraphics.Add(graphic, this.Name, false);
                                                cogGraphicInteractCollection.Add(graphic);
                                            }
                                        }
                                    }
                                    if (subRecord.Content is ICogGraphicInteractive)
                                    {
                                        //cDisplay.InteractiveGraphics.Add(subRecord.Content as ICogGraphicInteractive, this.Name, false);
                                        cogGraphicInteractCollection.Add(subRecord.Content as ICogGraphicInteractive);
                                    }
                                }


                                if (EnableDisplayTimeLabel)
                                {
                                    CogGraphicLabel cogLabel = new CogGraphicLabel();
                                    cogLabel.SelectedSpaceName = "@";
                                    cogLabel.Color             = CogColorConstants.Green;
                                    cogLabel.SetXYText(TimeLabelLocX, TimeLabelLocY, DateTime.Now.ToString("HH:mm:ss:fff"));
                                    cogGraphicInteractCollection.Add(cogLabel);
                                }

                                cDisplay.InteractiveGraphics.AddList(cogGraphicInteractCollection, this.Name, false);
                                //(cogDisplay as CogDisplay).Invalidate();
                            }
                        }
                    }
                    else
                    {
                        // Assign image if it is not there
                        if ((cDisplay.Image == null || !(cDisplay.Image is CogImage8Grey)) &&
                            CogCamera != null)
                        {
                            // Assign image
                            lock (CogCamera.LockCogDisplay)
                            {
                                //(cogDisplay as CogDisplay).Image = cogRecord.SubRecords[0].Content as ICogImage;
                                cDisplay.Image = cogRecord.SubRecords[cogRecord.SubRecords.Count - 1].Content as ICogImage;
                                cDisplay.Fit(true);
                            }
                        }

                        cDisplay.InteractiveGraphics.Clear();
                        if (IsDisplayGraphic)
                        {
                            // Assign graphic if any
                            CogGraphicInteractiveCollection cogGraphicInteractCollection = new CogGraphicInteractiveCollection();


                            foreach (ICogRecord record in cogRecord.SubRecords[cogRecord.SubRecords.Count - 1].SubRecords)
                            {
                                if (record.Content is CogGraphicCollection)
                                {
                                    CogGraphicCollection contentCollect = record.Content as CogGraphicCollection;

                                    foreach (CogObjectBase objBase in contentCollect)
                                    {
                                        ICogGraphicInteractive graphic = objBase as ICogGraphicInteractive;
                                        if (graphic != null)
                                        {
                                            //cDisplay.InteractiveGraphics.Add(graphic, this.Name, false);
                                            cogGraphicInteractCollection.Add(graphic);
                                        }
                                    }
                                }
                                else if (record.Content is ICogGraphicInteractive)
                                {
                                    //cDisplay.InteractiveGraphics.Add(record.Content as ICogGraphicInteractive, this.Name, false);
                                    cogGraphicInteractCollection.Add(record.Content as ICogGraphicInteractive);
                                }
                            }


                            if (EnableDisplayTimeLabel)
                            {
                                CogGraphicLabel cogLabel = new CogGraphicLabel();
                                cogLabel.SelectedSpaceName = "@";
                                cogLabel.Color             = CogColorConstants.Green;
                                cogLabel.SetXYText(TimeLabelLocX, TimeLabelLocY, DateTime.Now.ToString("HH:mm:ss:fff"));
                                cogGraphicInteractCollection.Add(cogLabel);
                            }

                            cDisplay.InteractiveGraphics.AddList(cogGraphicInteractCollection, this.Name, false);

                            //(cogDisplay as CogDisplay).Invalidate();
                        }
                    }
                }
                finally
                {
                    //cogDisplay.Visible = true;
                    //cogDisplay.Update();
                }

                //CogDisplayResult =new Bitmap((cogDisplay as CogDisplay).CreateContentBitmap(CogDisplayContentBitmapConstants.Image, null, 0));
            }
            else
            {
                // There is no Cognex Display, do nothing
            }
        }
示例#17
0
 public void StopLiveAcquisition(CogDisplay cogDisplay)
 {
     cogDisplay.StopLiveDisplay();
 }