public static HRegion GenEllipseRegion(double row, double col, double angle, double radius1, double radius2) { HRegion ellipse = new HRegion(); ellipse.GenEmptyRegion(); ellipse.GenEllipse(row, col, angle, radius1, radius2); return(ellipse); }
public DrawEllipse(double row, double column, double phi, double radius1, double radius2) { Row = row; Column = column; Phi = phi; Radius1 = radius1; Radius2 = radius2; ROIType = ROIType.Ellipse; Region = new HRegion(); Region.GenEllipse(Row, Column, Phi, Radius1, Radius2); }
/// <summary> /// 从DataRow数据获取区域 /// </summary> /// <param name="dr">DataRow</param> /// <returns>区域</returns> public HRegion GetRegion(DataRow dr) { var type = dr["Type"] as string; var hRegion = new HRegion(); switch (type) { case "Ellipse": hRegion.GenEllipse((double)dr["Row"], (double)dr["Column"], (double)dr["Phi"], (double)dr["Ra"], (double)dr["Rb"]); break; case "Rectangle": hRegion.GenRectangle2((double)dr["Row"], (double)dr["Column"], (double)dr["Phi"], (double)dr["Ra"], (double)dr["Rb"]); break; } return(hRegion); }
/// <summary> /// 在图像中绘制椭圆形区域 /// </summary> /// <param name="row"></param> /// <param name="column"></param> /// <param name="radius"></param> public void DrawEllipse(string color, out double row, out double column, out double phi, out double radius1, out double radius2) { try { Double _row, _column, _phi, _radius1, _radius2; ShieldMouseEvent(); hWindowControl1.Focus(); hWindowControl1.HalconWindow.SetColor(color); hWindowControl1.HalconWindow.DrawEllipse(out _row, out _column, out _phi, out _radius1, out _radius2); HRegion ellipse = new HRegion(); ellipse.GenEllipse(_row, _column, _phi, _radius1, _radius2); ellipse.GenContourRegionXld("border").DispObj(hWindowControl1.HalconWindow); // ellipse.DispObj(hWindowControl1.HalconWindow); ellipse.Dispose(); ReloadMouseEvent(); row = _row; column = _column; phi = _phi; radius1 = _radius1; radius2 = _radius2; } catch (Exception ex) { row = 0.0; column = 0.0; phi = 0.0; radius1 = 0.0; radius2 = 0.0; status_message.Text = ex.Message; } }