/// <summary> /// Obtain a list of camera. Also assigns the frame grabber if it matches the ID /// </summary> /// <returns></returns> public override string[] GetCameraIDs() { List <string> list = new List <string>(); ICogFrameGrabber foundGrabber = null; if (Parent is Cognex8) { lock (_lockAcqFifo) { CogFrameGrabbers grabbers = (Parent as Cognex8).FramegrabberCams; if (grabbers != null) { foreach (ICogFrameGrabber grabber in grabbers) { list.Add(BuildCameraID(grabber)); if (BuildCameraID(grabber) == CameraID) { foundGrabber = grabber; } } } } _frameGrabber = foundGrabber; if (_frameGrabber == null) { U.LogError("Camera not found! : '{0}'", CameraID); } } return(list.ToArray()); }
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; }
public ICogAcqFifo ConnectCam(ICogFrameGrabber CurrentCamFG) { ICogAcqFifo CurrentCamFifo = null; string videoFormat = "Generic GigEVision (Mono)"; CurrentCamFifo = CurrentCamFG.CreateAcqFifo(videoFormat, CogAcqFifoPixelFormatConstants.Format8Grey, 0, true); // CogAcqFifo 초기화 return(CurrentCamFifo); }
private void brightnessUpDown_ValueChanged(object sender, EventArgs e) { myFrameGrabbers = new CogFrameGrabbers(); myFrameGrabber = myFrameGrabbers[0]; myAcqFifo = AcqFifoTool.Operator; myAcqFifo.OwnedBrightnessParams.Brightness = cogAcqTool.Operator.OwnedBrightnessParams.Brightness; brightnessParams = myAcqFifo.OwnedBrightnessParams; if (brightnessParams != null) { brightnessParams.Brightness = Convert.ToDouble(brightnessUpDown.Value); myAcqFifo.OwnedBrightnessParams.Brightness = brightnessParams.Brightness; cogAcqTool.Operator.OwnedBrightnessParams.Brightness = brightnessParams.Brightness; } }
private void InitializeFifo() { const string VIDEO_FORMAT = "Sony XC75 640x480"; ICogAcqROI ROIParams; myFrameGrabbers = new CogFrameGrabbers(); myFrameGrabber = myFrameGrabbers[0]; myAcqFifo = myFrameGrabber.CreateAcqFifo(VIDEO_FORMAT, Cognex.VisionPro.CogAcqFifoPixelFormatConstants.Format8Grey, 0, false); ROIParams = myAcqFifo.OwnedROIParams; if (ROIParams != null) { ROIParams.SetROIXYWidthHeight(10, 20, 300, 200); } }
/// <summary> /// Destroy this Component /// </suimmary> public override void Destroy() { base.Destroy(); StopLiveAllCameraWindows(); lock (LockCogDisplay) { _cogDisplayWindows.Clear(); } if (_frameGrabber != null) { lock (_lockAcqFifo) { if (_cogAcqFifo != null) { _cogAcqFifo.Flush(); } } _frameGrabber.Disconnect(false); _frameGrabber = null; } }
private string BuildCameraID(ICogFrameGrabber frameGrabber) { return(string.Format("{0}-{1}", frameGrabber.Name, frameGrabber.SerialNumber)); }
public void InitVision() { SettingUp = false; ImageFileTool = CogImageFileEdit1.Subject; ImageFileTool.Ran += ImageFileTool_Ran; //Set reference to CogAcqFifoTool created by Edit Control //The Acq Fifo Edit Control creates its subject when its AutoCreateTool property is True AcqFifoTool = CogAcqFifoEdit1.Subject; AcqFifoTool.Ran += AcqFifoTool_Ran; cogAcqTool = CogAcqFifoEdit1.Subject; cogAcqTool = cogToolBlockEditV21.Subject.Tools["CogAcqFifoTool1"] as CogAcqFifoTool; cogAcqTool.Run(); //Operator will be Nothing if no Frame Grabber is available. Disable the Frame Grabber //option on the "VisionPro Demo" tab if no frame grabber available. if (AcqFifoTool.Operator == null) { optImageAcquisitionOptionFrameGrabber.Enabled = false; } //Initialize the Dialog box for the "Open File" button on the "VisionPro Demo" tab. ImageAcquisitionCommonDialog.Filter = ImageFileTool.Operator.FilterText; ImageAcquisitionCommonDialog.CheckFileExists = true; ImageAcquisitionCommonDialog.ReadOnlyChecked = true; //AutoCreateTool for the PMAlign edit control is False, therefore, we must create //a PMAlign tool and set the subject of the control to reference the new tool. PatMaxTool = new CogPMAlignTool(); PatMaxTool.Changed += PatMaxTool_Changed; CogPMAlignEdit1.Subject = PatMaxTool; //Change the default Train Region to center of a 640x480 image & change the DOFs //so that Skew is not enabled. Note - TrainRegion is of type ICogRegion, therefore, //we must use a CogRectangleAffine reference in order to call CogRectangleAffine //properties. CogRectangleAffine PatMaxTrainRegion = default(CogRectangleAffine); PatMaxTrainRegion = PatMaxTool.Pattern.TrainRegion as CogRectangleAffine; //PatMaxTrainRegion = cogPMAlignTool.Pattern.TrainRegion as CogRectangleAffine; if ((PatMaxTrainRegion != null)) { PatMaxTrainRegion.SetCenterLengthsRotationSkew(320, 240, 100, 100, 0, 0); PatMaxTrainRegion.GraphicDOFEnable = CogRectangleAffineDOFConstants.Position | CogRectangleAffineDOFConstants.Rotation | CogRectangleAffineDOFConstants.Size; } //PatMaxTool.SearchRegion = PatMaxSearchRegion; //PatMaxSearchRegion.SetCenterWidthHeight(320, 240, 640, 480); //PatMaxSearchRegion.GraphicDOFEnable = CogRectangleDOFConstants.Position | CogRectangleDOFConstants.Size; //PatMaxSearchRegion.Interactive = true; numericUpDown1.Value = Convert.ToDecimal(cogPMAlignTool.RunParams.AcceptThreshold); PatMaxTool.RunParams.AcceptThreshold = Convert.ToDouble(numericUpDown1.Value); numericUpDown2.Value = Convert.ToDecimal(cogPMAlignTool.RunParams.ApproximateNumberToFind); PatMaxTool.RunParams.ApproximateNumberToFind = Convert.ToInt32(numericUpDown2.Value); myAcqFifo = AcqFifoTool.Operator; try { myFrameGrabber = cogAcqTool.Operator.FrameGrabber; myAcqFifo = cogAcqTool.Operator; AcqFifoTool.Operator = myAcqFifo; myAcqFifo.OwnedContrastParams.Contrast = cogAcqTool.Operator.OwnedContrastParams.Contrast; myAcqFifo.OwnedBrightnessParams.Brightness = cogAcqTool.Operator.OwnedBrightnessParams.Brightness; brightnessParams = myAcqFifo.OwnedBrightnessParams; contrastParams = myAcqFifo.OwnedContrastParams; } catch (Exception ex) { MessageBox.Show(ex.Message); } if (brightnessParams != null) { brightnessUpDown.Value = Convert.ToDecimal(brightnessParams.Brightness); } if (contrastParams != null) { contrastUpDown.Value = Convert.ToDecimal(contrastParams.Contrast); } try { cogToolBlockEditV21.Subject.Inputs["Image"].Value = cogRecordDisplay1.Image; } catch (Exception ex) { MessageBox.Show("Input image wasn't set"); } }