/// <summary> /// Assign the new Gaphic to windows /// </summary> /// <param name="cogImage"></param> public void AssignGraphicToWindows(ICogGraphic cogGraphic) { lock (LockCogDisplay) { foreach (CogDisplay cogDisplay in _cogDisplayWindows) { cogDisplay.InteractiveGraphics.Add((ICogGraphicInteractive)cogGraphic, "", false); } } }
private void Recognize_Click(object sender, EventArgs e) { this.cogDisplayRecognize.StaticGraphics.Clear(); this.txtResult.Text = string.Empty; this.txtLocationX.Text = string.Empty; this.txtLocationY.Text = string.Empty; this.txtConstrast.Text = string.Empty; if (!_PMAlignTool.Pattern.Trained) { TrainCurrentImage(); } try { _PMAlignTool.RunParams.AcceptThreshold = double.Parse(this.spinAcceptThreshold.Value.ToString()); //_PMAlignTool.RunParams.ContrastThreshold = 10; _PMAlignTool.RunParams.RunAlgorithm = (CogPMAlignRunAlgorithmConstants)Enum.Parse (typeof(CogPMAlignRunAlgorithmConstants), this.cboRunAlgorithm.Text); _PMAlignTool.RunParams.RunMode = (CogPMAlignRunModeConstants)Enum.Parse (typeof(CogPMAlignRunModeConstants), this.cboRunMode.Text); _PMAlignTool.InputImage = new CogImage8Grey(_inputImageRecognize); _PMAlignTool.Run(); if ((CogToolBase.SfCreateLastRunRecord == (int)CogBarcodeLastRunRecordConstants.ResultsBounds) || (CogToolBase.SfRunStatus == 4)) { if (_PMAlignTool.Results == null && _PMAlignTool.RunStatus.Exception != null) { return; } var bestResult = from CogPMAlignResult eachResult in _PMAlignTool.Results orderby(eachResult.GetPose().TranslationX) orderby eachResult.GetPose().TranslationY select eachResult; foreach (CogPMAlignResult eachResult in bestResult) { CogTransform2DLinear resultPosition = eachResult.GetPose(); this.txtResult.Text += eachResult.Score.ToString("0.00") + ";"; this.txtLocationX.Text += resultPosition.TranslationX.ToString("0.00") + ";"; this.txtLocationY.Text += resultPosition.TranslationY.ToString("0.00") + ";"; this.txtConstrast.Text += eachResult.Contrast.ToString("0.00") + ";"; CogCompositeShape shape = eachResult.CreateResultGraphics(CogPMAlignResultGraphicConstants.All); ICogGraphic graphic = shape.CopyBase(CogCopyShapeConstants.BasicGraphics); graphic.Color = CogColorConstants.Green; this.cogDisplayRecognize.StaticGraphics.Add(graphic, "ResultRegion"); } } } catch (Exception ex) { XtraMessageBox.Show(string.Format("Recognize Failed! {0}", ex.Message)); } }
// 2013.12.22 public void AddLine(double dX, double dY, double dRotation, CogColorConstants color) { CogLine cogLine = new CogLine(); cogLine.X = dX; cogLine.Y = dY; cogLine.Rotation = dRotation; ICogGraphic icogGraphic = cogLine as ICogGraphic; icogGraphic.Color = color; AddStaticGraphic(icogGraphic, ""); }
public void AddLine(double dStartX, double dStartY, double dEndX, double dEndY, CogColorConstants color) { CogLineSegment cogLineSegment = new CogLineSegment(); cogLineSegment.StartX = dStartX; cogLineSegment.StartY = dStartY; cogLineSegment.EndX = dEndX; cogLineSegment.EndY = dEndY; ICogGraphic icogGraphic = cogLineSegment as ICogGraphic; icogGraphic.Color = color; AddStaticGraphic(icogGraphic, ""); }
public void AddTxt(double dX, double dY, string strTxt, CogColorConstants color) { CogGraphicLabel cogGraphicLabel = new CogGraphicLabel(); cogGraphicLabel.X = dX; cogGraphicLabel.Y = dY; cogGraphicLabel.SelectedSpaceName = "#"; cogGraphicLabel.Alignment = CogGraphicLabelAlignmentConstants.TopLeft; cogGraphicLabel.Text = strTxt; ICogGraphic icogGraphic = cogGraphicLabel as ICogGraphic; icogGraphic.Color = color; AddStaticGraphic(icogGraphic, ""); }
// 2013.12.22 public void AddLine(double dX, double dY, double dRotation, CogColorConstants color, string strSpaceName) { CogLine cogLine = new CogLine(); cogLine.X = dX; cogLine.Y = dY; cogLine.Rotation = dRotation; cogLine.SelectedSpaceName = strSpaceName; ICogGraphic icogGraphic = cogLine as ICogGraphic; icogGraphic.Color = color; AddStaticGraphic(icogGraphic, ""); }
// 2013.01.07 public void AddTxt(double dX, double dY, string strTxt, CogColorConstants color, int nSize) { CogGraphicLabel cogGraphicLabel = new CogGraphicLabel(); cogGraphicLabel.X = dX; cogGraphicLabel.Y = dY; cogGraphicLabel.SelectedSpaceName = "#"; cogGraphicLabel.Alignment = CogGraphicLabelAlignmentConstants.TopLeft; cogGraphicLabel.Text = strTxt; // 2013.01.07 System.Drawing.Font tmpFont = new System.Drawing.Font("Microsoft Sans Serif", nSize); cogGraphicLabel.Font = tmpFont; ICogGraphic icogGraphic = cogGraphicLabel as ICogGraphic; icogGraphic.Color = color; AddStaticGraphic(icogGraphic, ""); tmpFont.Dispose(); }
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 AddStaticGraphic(ICogGraphic icogGraphic, string strGroupName) { m_cogDisplay.StaticGraphics.Add(icogGraphic, strGroupName); }