void Vision_Cam1ResultAvailable(object sender, VisionResultAvailableEventArgs e) { string[] NGKeys = e.DataResult["NGKeys"].Split(','); CogGraphicLabel rsg = new CogGraphicLabel(); rsg.SelectedSpaceName = "*"; rsg.Alignment = CogGraphicLabelAlignmentConstants.TopLeft; rsg.SetXYText(10, 10, e.DataResult["ResultString"]); rsg.Color = e.DataResult["Result"] == "1" ? CogColorConstants.Green : CogColorConstants.Red; this.Invoke(new Action(() => { cogRecordDisplay1.StaticGraphics.Clear(); cogRecordDisplay1.Record = e.LastRunRecord.SubRecords[0]; cogRecordDisplay1.StaticGraphics.Add(rsg, "rs"); string key = ""; string value = ""; foreach (int item in cam1Rows) { key = dataGridView1.Rows[item].Cells[1].Value.ToString(); e.DataResult.TryGetValue(key, out value); dataGridView1.Rows[item].Cells[2].Value = value; dataGridView1.Rows[item].Cells[2].Style.BackColor = NGKeys.Contains(key) ? Color.Red : Color.White; } })); }
/// <summary> /// /// </summary> private void DisplayGraphic() { App.Current.Dispatcher.Invoke(new Action(delegate { float alignX = -1; float alignY = -1; float rotation = -1; CogDisplayOut.Image = CogAcqFifoEdit.Subject.OutputImage; if (CogAcqFifoEdit.Subject.OutputImage == null) { CogDisplayOut.Image = new CogImage8Grey(2592, 1944); } CogDisplayOut.StaticGraphics.Clear(); // if (CogPMAlign.Subject.Results.Count > 0) { var AlignGraphic = CogPMAlign.Subject.Results[0].CreateResultGraphics(CogPMAlignResultGraphicConstants.CoordinateAxes); AlignGraphic.Color = CogColorConstants.DarkGreen; CogDisplayOut.StaticGraphics.Add(AlignGraphic, ""); alignX = (float)CogPMAlign.Subject.Results[0].GetPose().TranslationX; alignY = (float)CogPMAlign.Subject.Results[0].GetPose().TranslationY; rotation = (float)CogPMAlign.Subject.Results[0].GetPose().Rotation; // // Static Graphic CogLine GraphicTest_X = new CogLine(); GraphicTest_X.LineStyle = CogGraphicLineStyleConstants.Solid; GraphicTest_X.X = CogCalibGrid.Subject.Calibration.GetComputedUncalibratedFromCalibratedTransform().LinearTransform(0, 0).TranslationX; GraphicTest_X.Y = CogCalibGrid.Subject.Calibration.GetComputedUncalibratedFromCalibratedTransform().LinearTransform(0, 0).TranslationY; GraphicTest_X.Rotation = 0; CogLine GraphicTest_Y = new CogLine(); GraphicTest_Y.LineStyle = CogGraphicLineStyleConstants.Solid; GraphicTest_Y.X = CogCalibGrid.Subject.Calibration.GetComputedUncalibratedFromCalibratedTransform().LinearTransform(0, 0).TranslationX; GraphicTest_Y.Y = CogCalibGrid.Subject.Calibration.GetComputedUncalibratedFromCalibratedTransform().LinearTransform(0, 0).TranslationY; GraphicTest_Y.Rotation = Math.PI / 2; GraphicTest_X.Color = CogColorConstants.DarkRed; GraphicTest_Y.Color = CogColorConstants.DarkRed; CogDisplayOut.StaticGraphics.Add(GraphicTest_X, "Test"); CogDisplayOut.StaticGraphics.Add(GraphicTest_Y, "Test"); } // CogGraphicLabel cogGraphicLabelTest = new CogGraphicLabel(); cogGraphicLabelTest.SetXYText(10, 10, $"RTC Camera {currentCameraIndex} X = {alignX} Y = {alignY} Angle = {rotation}"); cogGraphicLabelTest.Font = new Font(FontFamily.GenericSansSerif, 10, System.Drawing.FontStyle.Bold); cogGraphicLabelTest.Color = CogColorConstants.White; cogGraphicLabelTest.BackgroundColor = CogColorConstants.Black; cogGraphicLabelTest.Alignment = CogGraphicLabelAlignmentConstants.TopLeft; CogDisplayOut.StaticGraphics.Add(cogGraphicLabelTest, "Test"); // if (CogPMAlign.Subject.SearchRegion != null) { var SearchRegion = (CogPMAlign.Subject.SearchRegion.Map(CogPMAlign.Subject.InputImage.GetTransform("@", "."), CogCopyShapeConstants.All) as CogRectangleAffine); SearchRegion.Color = CogColorConstants.Orange; CogDisplayOut.StaticGraphics.Add(SearchRegion, "Test"); } CogDisplayOut.Fit(); })); }
public void DrawText(string _Message, double _StartX, double _StartY, CogColorConstants _Color, int _FontSize = 9, CogGraphicLabelAlignmentConstants _Align = CogGraphicLabelAlignmentConstants.TopLeft) { System.Drawing.Font _Font = new System.Drawing.Font("나눔바른고딕", _FontSize, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); cogLabel.Color = _Color; cogLabel.Font = _Font; cogLabel.Alignment = _Align; cogLabel.SetXYText(_StartX, _StartY, _Message); kCogDisplay.StaticGraphics.Add(cogLabel, "Message"); }
public static void ShowLabel_Invoke(CogRecordDisplay disp, float size, double posX, double posY, CogColorConstants color, string text) { var label = new CogGraphicLabel(); label.SelectedSpaceName = "#"; label.Alignment = CogGraphicLabelAlignmentConstants.TopLeft; label.Font = new Font("Arial", size); label.Color = color; label.SetXYText(posX, posY, text); _formMain.Invoke((MethodInvoker)(() => { disp.StaticGraphics.Add(label, "label"); })); }
public static void GCF(CogRecordDisplay mdisplay, string s1, string font, int size, double d1, double d2, string lab, CogColorConstants mcolor, CogGraphicLabelAlignmentConstants mali) { var mlable = new CogGraphicLabel(); //mfont = "微软雅黑"; var mfont = new Font(font, size, FontStyle.Regular); mlable.GraphicDOFEnableBase = CogGraphicDOFConstants.None; mlable.SelectedSpaceName = s1; mlable.Interactive = false; mlable.Font = mfont; mlable.Color = mcolor; mlable.Alignment = mali; mlable.SetXYText(d1, d2, lab); mdisplay.InteractiveGraphics.Add(mlable, "", false); }
private void BtnRun_Click(object sender, EventArgs e) { var pDocument = CDocument.GetDocument; do { try { m_objFindLineToolTop.Run(); m_objFindLineToolBottom.Run(); m_objCogDisplayMain.InteractiveGraphics.Clear(); m_objCogDisplayMain.StaticGraphics.Clear(); bool bResultTop = false; bool bResultBottom = false; if (null != m_objFindLineToolTop.Results && 0 < m_objFindLineToolTop.Results.Count) { for (int iLoopCount = 0; iLoopCount < m_objFindLineToolTop.Results.Count; iLoopCount++) { m_objCogDisplayMain.StaticGraphics.Add(m_objFindLineToolTop.Results[iLoopCount].CreateResultGraphics(CogFindLineResultGraphicConstants.DataPoint | CogFindLineResultGraphicConstants.TipText), ""); m_objCogDisplayMain.StaticGraphics.Add(m_objFindLineToolTop.Results.GetLine(), ""); } bResultTop = true; } if (null != m_objFindLineToolBottom.Results && 0 < m_objFindLineToolBottom.Results.Count) { for (int iLoopCount = 0; iLoopCount < m_objFindLineToolBottom.Results.Count; iLoopCount++) { m_objCogDisplayMain.StaticGraphics.Add(m_objFindLineToolBottom.Results[iLoopCount].CreateResultGraphics(CogFindLineResultGraphicConstants.DataPoint | CogFindLineResultGraphicConstants.TipText), ""); m_objCogDisplayMain.StaticGraphics.Add(m_objFindLineToolBottom.Results.GetLine(), ""); } bResultBottom = true; } if (false == bResultTop || false == bResultBottom) { break; } CogLine objCogLine = new CogLine(); objCogLine.SelectedSpaceName = "#"; objCogLine.SetXYRotation(m_objListImage[m_iPositionCrop].Width / 2, 0, 90 * (Math.PI / 180)); m_objCogDisplayMain.StaticGraphics.Add(objCogLine, ""); double dPositionXTop = 0; double dPositionYTop = 0; double dPositionXBottom = 0; double dPositionYBottom = 0; CogIntersectLineLineTool objIntersectLine = new CogIntersectLineLineTool(); objIntersectLine.InputImage = m_objListImage[m_iPositionCrop]; objIntersectLine.LineA = m_objFindLineToolTop.Results.GetLine(); objIntersectLine.LineB = objCogLine; objIntersectLine.Run(); dPositionXTop = objIntersectLine.X; dPositionYTop = objIntersectLine.Y; objIntersectLine.LineA = m_objFindLineToolBottom.Results.GetLine(); objIntersectLine.LineB = objCogLine; objIntersectLine.Run(); dPositionXBottom = objIntersectLine.X; dPositionYBottom = objIntersectLine.Y; CogDistancePointPointTool objDistance = new CogDistancePointPointTool(); objDistance.InputImage = m_objListImage[m_iPositionCrop]; objDistance.StartX = dPositionXTop; objDistance.StartY = dPositionYTop; objDistance.EndX = dPositionXBottom; objDistance.EndY = dPositionYBottom; objDistance.Run(); CogGraphicLabel objLabel = new CogGraphicLabel(); objLabel.SelectedSpaceName = "#"; objLabel.Alignment = CogGraphicLabelAlignmentConstants.BottomLeft; double dDistance = objDistance.Distance * pDocument.m_objConfig.GetCameraParameter(( int )CDefine.enumCamera.CAMERA_1).dResolution; objLabel.SetXYText(m_objListImage[m_iPositionCrop].Width / 2, 0, string.Format("DISTANCE : {0:F2}", dDistance)); m_objCogDisplayMain.StaticGraphics.Add(objLabel, ""); } catch (Exception ex) { pDocument.SetUpdateLog(CDefine.enumLogType.LOG_VISION_EXCEPTION_CAMERA_0, "CDialogFindLineSetting - Reload : " + ex.ToString()); } } while(false); }
//#region "when the tool group is run" // The GroupRun function is called when the tool group is run. The default // implementation provided here is equivalent to the normal behavior of the // tool group. Modifying this function will allow you to change the behavior // when the tool group is run. public override bool GroupRun(ref string message, ref CogToolResultConstants result) { // To let the execution stop in this script when a debugger is attached, uncomment the following lines. #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } #endif histCntr = 0; CogGraphicLabel myBaslerLabel = new CogGraphicLabel(); CogGraphicLabel myFlirLabel = new CogGraphicLabel(); CogPointMarker baslerMarker; //= new CogPointMarker(); double blobAngle = 0; double blobAngleRadians = 0; //Get references to the tools CogBlobTool blobBaslerTool = (CogBlobTool)toolGroup.Tools["FindWrappersInBasler"]; CogBlobTool blobFlirTool = (CogBlobTool)toolGroup.Tools["PopsicleBlobFinder"]; CogHistogramTool popsicleHistTool = (CogHistogramTool)toolGroup.Tools["PopsicleHistogramTool"]; //Define the regions CogRectangleAffine popsicleRegion = blobFlirTool.Region as CogRectangleAffine; CogRectangleAffine histogramRegion = blobFlirTool.Region as CogRectangleAffine; //Define the fonts System.Drawing.Font myBaslerFont = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); System.Drawing.Font myFlirFont = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); //Reset stats angleFailures = 0; thermalFailures = 0; //Reset any labels and rectangles from previous runs BaslerLabels.Clear(); FlirLabels.Clear(); FlirRectangles.Clear(); //***** Run the tools to perform the search in the basler image ***** //Update status strings for Visual Studio. Do not popup a message box for errors, this causes confusion with the operators. toolGroup.SetScriptTerminalData("BaslerStatus", "OK"); toolGroup.SetScriptTerminalData("FlirStatus", "OK"); bool acquireException = false; try { //Aquire an image from the Basler, send Exception to Visual Studio toolGroup.RunTool(toolGroup.Tools["BaslerAcqFifo"], ref message, ref result); } catch (Exception ex) { toolGroup.SetScriptTerminalData("BaslerStatus", "Script Error: " + ex.Message + " Check power connections and communication cables."); acquireException = true; } try { //Aquire an image from the Flir, send Exception to Visual Studio toolGroup.RunTool(toolGroup.Tools["FlirAcqFifo"], ref message, ref result); } catch (Exception ex) { toolGroup.SetScriptTerminalData("FlirStatus", "Script Error: " + ex.Message + " Check power connections and communication cables."); acquireException = true; } if (acquireException) { return(false); } try { // Scale the Flir image to zoom in to smaller temperature range toolGroup.RunTool(toolGroup.Tools["ScaleFlirImagePmap"], ref message, ref result); } catch (Exception ex) { toolGroup.SetScriptTerminalData("FlirStatus", "Script Error: " + ex.Message + " Failed: ScaleFlirImagePmap"); return(false); } try { // Transform the images to calibrated space toolGroup.RunTool(toolGroup.Tools["CalBasler"], ref message, ref result); toolGroup.RunTool(toolGroup.Tools["CalFlir"], ref message, ref result); } catch (Exception ex) { //MessageBox.Show("Calibration tool error: " + ex.Message, "Script Exception"); toolGroup.SetScriptTerminalData("BaslerStatus", "Script Error: " + ex.Message + " Failed: CalBasler"); toolGroup.SetScriptTerminalData("FlirStatus", "Script Error: " + ex.Message + " Failed: CalFlir"); return(false); } try { toolGroup.RunTool(toolGroup.Tools["CogPixelMapBasler"], ref message, ref result); } catch (Exception ex) { toolGroup.SetScriptTerminalData("BaslerStatus", "Script Error: " + ex.Message + " Failed: CogPixelMapBasler"); return(false); } try { toolGroup.RunTool(toolGroup.Tools["CogIPOneImageTool1"], ref message, ref result); } catch (Exception ex) { toolGroup.SetScriptTerminalData("BaslerStatus", "Script Error: " + ex.Message + " Failed: CogIPOneImageTool1"); return(false); } try { // Run the Flir hist tool toolGroup.RunTool(toolGroup.Tools["PopsicleHistogramTool"], ref message, ref result); } catch (Exception ex) { toolGroup.SetScriptTerminalData("FlirStatus", "Script Error: " + ex.Message + " Failed: PopsicleHistogramTool"); return(false); } try { // Run the blob tool and get a reference to the results. toolGroup.RunTool(blobBaslerTool, ref message, ref result); } catch (Exception ex) { toolGroup.SetScriptTerminalData("BaslerStatus", "Script Error: " + ex.Message + " Failed: Basler blobBaslerTool"); return(false); } CogBlobResultCollection blobResults = blobBaslerTool.Results.GetBlobs(); // Clear list before starting loop malBlobPoses.Clear(); Crosshairs.Clear(); // Get group input terminal data try { disableHist = (bool)toolGroup.GetScriptTerminalData("DisableHistogramInspection"); minPickAngle = (double)toolGroup.GetScriptTerminalData("MinPickAngle"); maxPickAngle = (double)toolGroup.GetScriptTerminalData("MaxPickAngle"); minPopsicleHistCount = (double)toolGroup.GetScriptTerminalData("MinPopsicleHistCount"); VisStudio_Running = (bool)toolGroup.GetScriptTerminalData("VS_Running"); showArea = (bool)toolGroup.GetScriptTerminalData("ShowArea"); showHist = (bool)toolGroup.GetScriptTerminalData("ShowHistCount"); visSideXLength = (double)toolGroup.GetScriptTerminalData("VisSideXLength"); visSideYLength = (double)toolGroup.GetScriptTerminalData("VisSideYLength"); visFlirRegionXadj = (double)toolGroup.GetScriptTerminalData("VisFlirRegionXadj"); visFlirRegionYadj = (double)toolGroup.GetScriptTerminalData("VisFlirRegionYadj"); } catch (Exception ex) { //MessageBox.Show("Getting terminal data exception: ", ex.Message); toolGroup.SetScriptTerminalData("BaslerStatus", "Getting script data: " + ex.Message); } // Set run variables for manual triggering if (!VisStudio_Running) { minPopsicleHistCount = 0; minPickAngle = -20; maxPickAngle = 20; showArea = true; showHist = true; visSideXLength = 200; visSideYLength = 70; visFlirRegionXadj = 0; visFlirRegionYadj = 0; } // *************************************** // ******** Process the blobs ********* // *************************************** try { foreach (CogBlobResult blob in blobResults) { // Set the transform for collections CogTransform2DLinear l2d = new CogTransform2DLinear(); l2d.TranslationX = blob.GetBoundingBoxAtAngle(blob.Angle).CenterX; l2d.TranslationY = blob.GetBoundingBoxAtAngle(blob.Angle).CenterY; l2d.Rotation = blob.Angle; blobAngleRadians = blob.Angle; // Crosshair setup for the Basler baslerMarker = new CogPointMarker(); baslerMarker.X = l2d.TranslationX; baslerMarker.Y = l2d.TranslationY; baslerMarker.Color = CogColorConstants.Green; baslerMarker.GraphicType = CogPointMarkerGraphicTypeConstants.Crosshair; // Flir region CogRectangleAffine myFlirRegion = new CogRectangleAffine(); myFlirRegion.CenterX = l2d.TranslationX + visFlirRegionXadj; myFlirRegion.CenterY = l2d.TranslationY + visFlirRegionYadj; myFlirRegion.Rotation = l2d.Rotation; myFlirRegion.SideXLength = visSideXLength; myFlirRegion.SideYLength = visSideYLength; blobFlirTool.Region = myFlirRegion; toolGroup.RunTool(blobFlirTool, ref message, ref result); popsicleHistTool.Region = myFlirRegion; toolGroup.RunTool(popsicleHistTool, ref message, ref result); // Get the histogram results from the bin binHist = popsicleHistTool.Result.GetHistogram(); // Count total pixels histCntr = 1; for (int i = 0; i < blobFlirTool.RunParams.SegmentationParams.HardFixedThreshold; i++) { histCntr = histCntr + binHist[i]; } myBaslerLabel = new CogGraphicLabel(); myBaslerLabel.SetXYText(0, 0, ""); myFlirLabel = new CogGraphicLabel(); myBaslerLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); myFlirLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); myFlirRegion.Visible = true; myBaslerLabel.Alignment = CogGraphicLabelAlignmentConstants.BaselineCenter; myFlirLabel.Alignment = CogGraphicLabelAlignmentConstants.BaselineCenter; // Decide to add the popsicle blob to the collection list if ((histCntr < minPopsicleHistCount) && (!disableHist)) { myBaslerLabel.Color = CogColorConstants.Red; myFlirRegion.Color = CogColorConstants.Red; // Show the hist count in the Flir image myFlirLabel.Color = CogColorConstants.Red; if (showHist) { myFlirLabel.SetXYText(blob.CenterOfMassX, blob.CenterOfMassY, "Size: " + histCntr.ToString()); } thermalFailures++; } else { myBaslerLabel.Color = CogColorConstants.Green; // If histogram check is disabled, draw rectangle in yellow, else green if (disableHist) { myFlirLabel.Color = CogColorConstants.Red; myFlirRegion.Color = CogColorConstants.Yellow; } else { myFlirLabel.Color = CogColorConstants.Green; myFlirRegion.Color = CogColorConstants.Green; } if (showHist) { myFlirLabel.SetXYText(blob.CenterOfMassX, blob.CenterOfMassY, "Size: " + histCntr.ToString()); } // Convert blob angle to degrees blobAngle = blob.Angle * 180 / Math.PI; if ((blobAngle > (double)minPickAngle) && (blobAngle < (double)maxPickAngle)) { malBlobPoses.Add(l2d); if (showArea) { myBaslerLabel.Color = CogColorConstants.Green; myBaslerLabel.SetXYText(l2d.TranslationX, l2d.TranslationY - 15, "Size: " + blob.Area.ToString("0")); } } else { myBaslerLabel.Color = CogColorConstants.Red; myBaslerLabel.SetXYText(l2d.TranslationX, l2d.TranslationY, "Angle: " + blobAngle.ToString("0")); myFlirLabel.Color = CogColorConstants.Red; myFlirRegion.Color = CogColorConstants.Red; angleFailures++; } } myBaslerLabel.Rotation = blobAngleRadians; BaslerLabels.Add(myBaslerLabel); FlirLabels.Add(myFlirLabel); FlirRectangles.Add(myFlirRegion); Crosshairs.Add(baslerMarker); // Update group output terminals toolGroup.SetScriptTerminalData("AngleFailures", angleFailures); toolGroup.SetScriptTerminalData("ThermalFailures", thermalFailures); toolGroup.SetScriptTerminalData("BlobCollection", malBlobPoses); } } catch (Exception ex) { toolGroup.SetScriptTerminalData("BaslerStatus", "Script Error during blob processing: " + ex.Message); malBlobPoses.Clear(); // Clear positional data for this frame } // Returning False indicates we ran the tools in script, and they should not be // run by VisionPro return(false); }
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 } }