diff --git a/Rs.Controls/CameraTemplate.Designer.cs b/Rs.Controls/CameraTemplate.Designer.cs
index 216f232..2e65f6d 100644
--- a/Rs.Controls/CameraTemplate.Designer.cs
+++ b/Rs.Controls/CameraTemplate.Designer.cs
@@ -105,6 +105,7 @@
this.btnGrab = new System.Windows.Forms.Button();
this.btnLoadImage = new System.Windows.Forms.Button();
this.btnGrabContinue = new System.Windows.Forms.Button();
+ this.btnDrawBarCode = new System.Windows.Forms.Button();
this.panelEx3.SuspendLayout();
this.panelEx7.SuspendLayout();
this.groupBox7.SuspendLayout();
@@ -776,6 +777,7 @@
// groupBox3
//
this.groupBox3.Controls.Add(this.btnDrawRectangle2);
+ this.groupBox3.Controls.Add(this.btnDrawBarCode);
this.groupBox3.Controls.Add(this.btnDrawAny);
this.groupBox3.Controls.Add(this.btnDrawCircle);
this.groupBox3.Dock = System.Windows.Forms.DockStyle.Top;
@@ -791,9 +793,9 @@
//
this.btnDrawRectangle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
this.btnDrawRectangle2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btnDrawRectangle2.Location = new System.Drawing.Point(17, 20);
+ this.btnDrawRectangle2.Location = new System.Drawing.Point(12, 20);
this.btnDrawRectangle2.Name = "btnDrawRectangle2";
- this.btnDrawRectangle2.Size = new System.Drawing.Size(75, 23);
+ this.btnDrawRectangle2.Size = new System.Drawing.Size(55, 23);
this.btnDrawRectangle2.TabIndex = 8;
this.btnDrawRectangle2.Text = "画矩形";
this.btnDrawRectangle2.UseVisualStyleBackColor = false;
@@ -803,9 +805,9 @@
//
this.btnDrawAny.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
this.btnDrawAny.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btnDrawAny.Location = new System.Drawing.Point(239, 20);
+ this.btnDrawAny.Location = new System.Drawing.Point(162, 20);
this.btnDrawAny.Name = "btnDrawAny";
- this.btnDrawAny.Size = new System.Drawing.Size(75, 23);
+ this.btnDrawAny.Size = new System.Drawing.Size(55, 23);
this.btnDrawAny.TabIndex = 8;
this.btnDrawAny.Text = "任意";
this.btnDrawAny.UseVisualStyleBackColor = false;
@@ -815,9 +817,9 @@
//
this.btnDrawCircle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
this.btnDrawCircle.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.btnDrawCircle.Location = new System.Drawing.Point(128, 20);
+ this.btnDrawCircle.Location = new System.Drawing.Point(87, 20);
this.btnDrawCircle.Name = "btnDrawCircle";
- this.btnDrawCircle.Size = new System.Drawing.Size(75, 23);
+ this.btnDrawCircle.Size = new System.Drawing.Size(55, 23);
this.btnDrawCircle.TabIndex = 8;
this.btnDrawCircle.Text = "画圆";
this.btnDrawCircle.UseVisualStyleBackColor = false;
@@ -1035,6 +1037,18 @@
this.btnGrabContinue.UseVisualStyleBackColor = false;
this.btnGrabContinue.Click += new System.EventHandler(this.btnGrabContinue_Click);
//
+ // btnDrawBarCode
+ //
+ this.btnDrawBarCode.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
+ this.btnDrawBarCode.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.btnDrawBarCode.Location = new System.Drawing.Point(237, 20);
+ this.btnDrawBarCode.Name = "btnDrawBarCode";
+ this.btnDrawBarCode.Size = new System.Drawing.Size(71, 23);
+ this.btnDrawBarCode.TabIndex = 8;
+ this.btnDrawBarCode.Text = "二维码";
+ this.btnDrawBarCode.UseVisualStyleBackColor = false;
+ this.btnDrawBarCode.Click += new System.EventHandler(this.btnDrawBarCode_Click);
+ //
// CameraTemplate
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -1151,5 +1165,6 @@
private System.Windows.Forms.Label label15;
private System.Windows.Forms.ComboBox cboxCamera;
private System.Windows.Forms.ComboBox comboBox1;
+ private System.Windows.Forms.Button btnDrawBarCode;
}
}
diff --git a/Rs.Controls/CameraTemplate.cs b/Rs.Controls/CameraTemplate.cs
index 2b26b00..40d35a9 100644
--- a/Rs.Controls/CameraTemplate.cs
+++ b/Rs.Controls/CameraTemplate.cs
@@ -21,6 +21,12 @@ using static System.Net.Mime.MediaTypeNames;
namespace Rs.MotionPlat
{
+ enum ERegionType
+ {
+ Roi,
+ Search,
+ Barcode
+ }
public enum ERoiShape
{
Rectange,
@@ -612,12 +618,12 @@ namespace Rs.MotionPlat
private void btnDrawRectangle(object sender, EventArgs e)
{
- DrawRoi(ERoiShape.Rectange);
+ DrawRoi(ERoiShape.Rectange, ERegionType.Roi);
}
private void btnDrawCircle_Click(object sender, EventArgs e)
{
- DrawRoi(ERoiShape.Circle);
+ DrawRoi(ERoiShape.Circle, ERegionType.Roi);
}
bool bPaint = true;
@@ -907,7 +913,7 @@ namespace Rs.MotionPlat
}
private void btnDrawAny_Click(object sender, EventArgs e)
{
- DrawRoi(ERoiShape.Any);
+ DrawRoi(ERoiShape.Any, ERegionType.Roi);
}
#region 加载
@@ -988,7 +994,7 @@ namespace Rs.MotionPlat
#endregion
private void btnDrawSearch_Click(object sender, EventArgs e)
{
- DrawRoi(ERoiShape.Rectange, true);
+ DrawRoi(ERoiShape.Rectange, ERegionType.Search);
}
private void txtExposure_KeyUp(object sender, KeyEventArgs e)
@@ -1050,7 +1056,12 @@ namespace Rs.MotionPlat
}
- private void DrawRoi(ERoiShape roiShape,bool isSearch=false)
+ private void btnDrawBarCode_Click(object sender, EventArgs e)
+ {
+ DrawRoi(ERoiShape.Rectange, ERegionType.Barcode);
+ }
+
+ private void DrawRoi(ERoiShape roiShape, ERegionType regionType)
{
HImage img = hWindow_Final1.Image;
hImage = img.CopyObj(1, 1);
@@ -1086,18 +1097,22 @@ namespace Rs.MotionPlat
{
HOperatorSet.DrawRegion(out roiRegion, winHandle);
}
-
- if(isSearch)
+ switch (regionType)
{
- pm.SearchRegion = roiRegion;
- hWindow_Final1.DispObj(pm.SearchRegion, "green");
- }
- else
- {
- pm.RoiRegion = roiRegion;
- hWindow_Final1.DispObj(pm.RoiRegion, "green");
-
-
+ case ERegionType.Roi:
+ pm.RoiRegion = roiRegion;
+ hWindow_Final1.DispObj(pm.RoiRegion, "green");
+ break;
+ case ERegionType.Search:
+ pm.SearchRegion = roiRegion;
+ hWindow_Final1.DispObj(pm.SearchRegion, "green");
+ break;
+ case ERegionType.Barcode:
+ pm.BarCodeRegion = roiRegion;
+ hWindow_Final1.DispObj(pm.BarCodeRegion, "green");
+ break;
+ default:
+ break;
}
//pm.RoiRow1 = row1; pm.RoiRow2 = row2;
//pm.RoiColumn1 = column1; pm.RoiColumn2 = column2;
diff --git a/Rs.Controls/Common/ProductModel.cs b/Rs.Controls/Common/ProductModel.cs
index d6863aa..e2b3ab0 100644
--- a/Rs.Controls/Common/ProductModel.cs
+++ b/Rs.Controls/Common/ProductModel.cs
@@ -18,6 +18,11 @@ namespace Rs.MotionPlat.Commom
///
public HObject SearchRegion { get; set; }
+ ///
+ /// 二维码搜索区域
+ ///
+ public HObject BarCodeRegion { get; set; }
+
///
/// ROI区域
///
@@ -102,6 +107,12 @@ namespace Rs.MotionPlat.Commom
{
HOperatorSet.WriteRegion(SearchRegion, savePath + "\\" + "search.reg");
}
+ //保存二维码区域
+ if (BarCodeRegion != null && BarCodeRegion.CountObj() > 0)
+ {
+ HOperatorSet.WriteRegion(BarCodeRegion, savePath + "\\" + "barcode.reg");
+ }
+
//保存ROI区域
if (RoiRegion!=null && RoiRegion.CountObj()>0)
{