├── Adjust.Designer.cs ├── Adjust.cs ├── Adjust.resx ├── FitLine.cs ├── FrmMain.Designer.cs ├── FrmMain.cs ├── FrmMain.resx ├── ImageGrab.cs ├── PasteLCM.csproj ├── PasteLCM.sln ├── Program.cs ├── README.md └── app.config /Adjust.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace PasteLCM 2 | { 3 | partial class Adjust 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 32 | this.checkBox1 = new System.Windows.Forms.CheckBox(); 33 | this.trackBar1 = new System.Windows.Forms.TrackBar(); 34 | this.trackBar2 = new System.Windows.Forms.TrackBar(); 35 | this.panel1 = new System.Windows.Forms.Panel(); 36 | this.button1 = new System.Windows.Forms.Button(); 37 | this.label4 = new System.Windows.Forms.Label(); 38 | this.label3 = new System.Windows.Forms.Label(); 39 | this.label2 = new System.Windows.Forms.Label(); 40 | this.label1 = new System.Windows.Forms.Label(); 41 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 42 | ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit(); 43 | ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit(); 44 | this.panel1.SuspendLayout(); 45 | this.SuspendLayout(); 46 | // 47 | // pictureBox1 48 | // 49 | this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 50 | this.pictureBox1.Location = new System.Drawing.Point(13, 13); 51 | this.pictureBox1.Name = "pictureBox1"; 52 | this.pictureBox1.Size = new System.Drawing.Size(460, 404); 53 | this.pictureBox1.TabIndex = 0; 54 | this.pictureBox1.TabStop = false; 55 | // 56 | // checkBox1 57 | // 58 | this.checkBox1.AutoSize = true; 59 | this.checkBox1.Location = new System.Drawing.Point(30, 13); 60 | this.checkBox1.Name = "checkBox1"; 61 | this.checkBox1.Size = new System.Drawing.Size(72, 16); 62 | this.checkBox1.TabIndex = 1; 63 | this.checkBox1.Text = "灰度调整"; 64 | this.checkBox1.UseVisualStyleBackColor = true; 65 | this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); 66 | // 67 | // trackBar1 68 | // 69 | this.trackBar1.Location = new System.Drawing.Point(30, 53); 70 | this.trackBar1.Maximum = 255; 71 | this.trackBar1.Minimum = 1; 72 | this.trackBar1.Name = "trackBar1"; 73 | this.trackBar1.Orientation = System.Windows.Forms.Orientation.Vertical; 74 | this.trackBar1.Size = new System.Drawing.Size(45, 272); 75 | this.trackBar1.TabIndex = 2; 76 | this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None; 77 | this.trackBar1.Value = 1; 78 | this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll); 79 | // 80 | // trackBar2 81 | // 82 | this.trackBar2.Location = new System.Drawing.Point(75, 53); 83 | this.trackBar2.Maximum = 255; 84 | this.trackBar2.Name = "trackBar2"; 85 | this.trackBar2.Orientation = System.Windows.Forms.Orientation.Vertical; 86 | this.trackBar2.Size = new System.Drawing.Size(45, 272); 87 | this.trackBar2.TabIndex = 2; 88 | this.trackBar2.TickStyle = System.Windows.Forms.TickStyle.None; 89 | this.trackBar2.Value = 255; 90 | this.trackBar2.Scroll += new System.EventHandler(this.trackBar2_Scroll); 91 | // 92 | // panel1 93 | // 94 | this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 95 | this.panel1.Controls.Add(this.button1); 96 | this.panel1.Controls.Add(this.label4); 97 | this.panel1.Controls.Add(this.label3); 98 | this.panel1.Controls.Add(this.label2); 99 | this.panel1.Controls.Add(this.label1); 100 | this.panel1.Controls.Add(this.checkBox1); 101 | this.panel1.Controls.Add(this.trackBar1); 102 | this.panel1.Controls.Add(this.trackBar2); 103 | this.panel1.Location = new System.Drawing.Point(480, 13); 104 | this.panel1.Name = "panel1"; 105 | this.panel1.Size = new System.Drawing.Size(129, 404); 106 | this.panel1.TabIndex = 3; 107 | // 108 | // button1 109 | // 110 | this.button1.Location = new System.Drawing.Point(27, 365); 111 | this.button1.Name = "button1"; 112 | this.button1.Size = new System.Drawing.Size(75, 23); 113 | this.button1.TabIndex = 4; 114 | this.button1.Text = "保存阈值"; 115 | this.button1.UseVisualStyleBackColor = true; 116 | this.button1.Click += new System.EventHandler(this.button1_Click); 117 | // 118 | // label4 119 | // 120 | this.label4.AutoSize = true; 121 | this.label4.Location = new System.Drawing.Point(78, 37); 122 | this.label4.Name = "label4"; 123 | this.label4.Size = new System.Drawing.Size(23, 12); 124 | this.label4.TabIndex = 3; 125 | this.label4.Text = "255"; 126 | // 127 | // label3 128 | // 129 | this.label3.AutoSize = true; 130 | this.label3.Location = new System.Drawing.Point(31, 37); 131 | this.label3.Name = "label3"; 132 | this.label3.Size = new System.Drawing.Size(11, 12); 133 | this.label3.TabIndex = 3; 134 | this.label3.Text = "1"; 135 | // 136 | // label2 137 | // 138 | this.label2.AutoSize = true; 139 | this.label2.Location = new System.Drawing.Point(65, 328); 140 | this.label2.Name = "label2"; 141 | this.label2.Size = new System.Drawing.Size(41, 12); 142 | this.label2.TabIndex = 3; 143 | this.label2.Text = "高灰度"; 144 | // 145 | // label1 146 | // 147 | this.label1.AutoSize = true; 148 | this.label1.Location = new System.Drawing.Point(18, 328); 149 | this.label1.Name = "label1"; 150 | this.label1.Size = new System.Drawing.Size(41, 12); 151 | this.label1.TabIndex = 3; 152 | this.label1.Text = "低灰度"; 153 | // 154 | // Adjust 155 | // 156 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 157 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 158 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); 159 | this.ClientSize = new System.Drawing.Size(621, 429); 160 | this.Controls.Add(this.pictureBox1); 161 | this.Controls.Add(this.panel1); 162 | this.Name = "Adjust"; 163 | this.Text = "灰度小助手"; 164 | this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Adjust_FormClosed); 165 | this.Load += new System.EventHandler(this.try_Load); 166 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 167 | ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit(); 168 | ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit(); 169 | this.panel1.ResumeLayout(false); 170 | this.panel1.PerformLayout(); 171 | this.ResumeLayout(false); 172 | 173 | } 174 | 175 | #endregion 176 | 177 | private System.Windows.Forms.PictureBox pictureBox1; 178 | private System.Windows.Forms.CheckBox checkBox1; 179 | private System.Windows.Forms.TrackBar trackBar1; 180 | private System.Windows.Forms.TrackBar trackBar2; 181 | private System.Windows.Forms.Panel panel1; 182 | private System.Windows.Forms.Button button1; 183 | private System.Windows.Forms.Label label2; 184 | private System.Windows.Forms.Label label1; 185 | private System.Windows.Forms.Label label4; 186 | private System.Windows.Forms.Label label3; 187 | } 188 | } -------------------------------------------------------------------------------- /Adjust.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Drawing.Imaging; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Runtime.InteropServices; 10 | using System.Windows.Forms; 11 | using HalconDotNet; 12 | 13 | namespace PasteLCM 14 | { 15 | 16 | /// 17 | /// 灰度值调整小助手 18 | /// 19 | public partial class Adjust : Form 20 | { 21 | public HObject Ho_img { get; set; } 22 | //窗体间传值 23 | private FrmMain Fm; 24 | [DllImport("kernel32", EntryPoint = "RtlMoveMemory", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)] 25 | private static extern void CopyMemory(int Destination, int Source, int length); 26 | public Adjust(HObject ho_img,FrmMain fm) 27 | { 28 | InitializeComponent(); 29 | this.Ho_img = ho_img; 30 | Fm = fm; 31 | } 32 | 33 | private void @try_Load(object sender, EventArgs e) 34 | { 35 | checkBox1.Checked = false; 36 | trackBar1.Enabled = false; 37 | trackBar2.Enabled = false; 38 | pictureBox1.Image = H2Bitmap(HobjectToHimage(this.Ho_img)); 39 | } 40 | HObject hregion; 41 | void Threshold(int a,int b) 42 | { 43 | //阈值化,输出region. 44 | HOperatorSet.Threshold(this.Ho_img, out hregion, a, b); 45 | //region转换为image. 46 | HOperatorSet.RegionToBin(hregion, out hregion, 255, 0, 512, 512); 47 | } 48 | #region Himage转Bitmap 49 | public Bitmap H2Bitmap(HImage img1) 50 | { 51 | IntPtr pt; 52 | int mwidth, mheight; 53 | string mtype = ""; 54 | Bitmap img; 55 | ColorPalette pal; 56 | int i; 57 | const int Alpha = 255; 58 | BitmapData bitmapData; 59 | Rectangle rect; 60 | int[] ptr = new int[2]; 61 | int PixelSize; 62 | //this.Ho_image.ReadImage("clip"); 63 | pt = img1.GetImagePointer1(out mtype, out mwidth, out mheight); 64 | img = new Bitmap(mwidth, mheight, PixelFormat.Format8bppIndexed); 65 | pal = img.Palette; 66 | for (i = 0; i <= 255; i++) 67 | { 68 | pal.Entries[i] = Color.FromArgb(Alpha, i, i, i); 69 | } 70 | img.Palette = pal; 71 | rect = new Rectangle(0, 0, mwidth, mheight); 72 | bitmapData = img.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed); 73 | PixelSize = Bitmap.GetPixelFormatSize(bitmapData.PixelFormat) / 8; 74 | ptr[0] = bitmapData.Scan0.ToInt32(); 75 | ptr[1] = pt.ToInt32(); 76 | if (mwidth % 4 == 0) 77 | CopyMemory(ptr[0], ptr[1], mwidth * mheight * PixelSize); 78 | else 79 | { 80 | for (i = 0; i < mheight; i++) 81 | { 82 | ptr[1] += mwidth; 83 | CopyMemory(ptr[0], ptr[1], mwidth * PixelSize); 84 | ptr[0] += bitmapData.Stride; 85 | } 86 | } 87 | img.UnlockBits(bitmapData); 88 | img1.Dispose(); 89 | return img; 90 | } 91 | #endregion 92 | /// 93 | /// hobject转himage 94 | /// 95 | /// hobject 96 | /// himage 97 | private HImage HobjectToHimage(HObject hobject) 98 | { 99 | HImage image = new HImage(); 100 | HTuple pointer, type, width, height; 101 | HOperatorSet.GetImagePointer1(hobject, out pointer, out type, out width, out height); 102 | image.GenImage1(type, width, height, pointer); 103 | return image; 104 | } 105 | 106 | private void checkBox1_CheckedChanged(object sender, EventArgs e) 107 | { 108 | if (checkBox1.Checked) 109 | { 110 | trackBar1.Enabled = true; 111 | trackBar2.Enabled = true; 112 | Threshold(trackBar1.Value,trackBar2.Value); 113 | Bitmap image = H2Bitmap(HobjectToHimage(hregion)); 114 | pictureBox1.Image = image; 115 | } 116 | else 117 | { 118 | trackBar1.Enabled = false; 119 | trackBar2.Enabled = false; 120 | } 121 | } 122 | 123 | private void trackBar1_Scroll(object sender, EventArgs e) 124 | { 125 | trackBar1.Maximum = trackBar2.Value; 126 | label3.Text = trackBar1.Value.ToString(); 127 | Threshold(trackBar1.Value, trackBar2.Value); 128 | Bitmap image = H2Bitmap(HobjectToHimage(hregion)); 129 | pictureBox1.Image = image; 130 | } 131 | 132 | private void trackBar2_Scroll(object sender, EventArgs e) 133 | { 134 | trackBar2.Minimum = trackBar1.Value; 135 | label4.Text = trackBar2.Value.ToString(); 136 | Threshold(trackBar1.Value, trackBar2.Value); 137 | Bitmap image = H2Bitmap(HobjectToHimage(hregion)); 138 | pictureBox1.Image = image; 139 | } 140 | 141 | private void Adjust_FormClosed(object sender, FormClosedEventArgs e) 142 | { 143 | Fm.textBox4.Text = this.trackBar1.Value.ToString(); 144 | Fm.textBox3.Text = this.trackBar2.Value.ToString(); 145 | } 146 | 147 | private void button1_Click(object sender, EventArgs e) 148 | { 149 | this.Close(); 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /Adjust.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /FitLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using HalconDotNet; 6 | 7 | namespace PasteLCM 8 | { 9 | /// 10 | /// 该类寻找边缘,并拟合直线,返回两条直线,四个点坐标 11 | /// 12 | class FitLine 13 | { 14 | public HRegion Region1 { get; set; }//1#ROI 15 | public HRegion Region2 { get; set; }//2#ROI 16 | public int LowThreshold { get; set; }//低阈值 17 | public int HighThreshold { get; set; }//高阈值 18 | public HImage Ho_image { get; set; }//传入图片 19 | /// 20 | /// 构造函数 21 | /// 22 | /// 传入图片 23 | /// 1#ROI 24 | /// 2#ROI 25 | /// 低阈值 26 | /// 高阈值 27 | public FitLine(HImage ho_image,HRegion region1,HRegion region2,int lowThreshold,int highThreshold) 28 | { 29 | this.Ho_image = ho_image; 30 | this.Region1 = region1; 31 | this.Region2 = region2; 32 | this.LowThreshold = lowThreshold; 33 | this.HighThreshold = highThreshold; 34 | } 35 | /// 36 | /// 图像处理 37 | /// 38 | /// 返回8个点位数组 39 | public double[] Process() 40 | { 41 | double[]coorderate=new double[8]; 42 | double hv_RowBegin1; double hv_ColBegin1; double hv_RowEnd1; double hv_ColEnd1; double hv_Nr1; double hv_Nc1; double hv_Dist1; 43 | double hv_RowBegin2; double hv_ColBegin2; double hv_RowEnd2; double hv_ColEnd2; double hv_Nr2; double hv_Nc2; double hv_Dist2; 44 | //图像阈值化,获得region 45 | HRegion hRegion = Ho_image.Threshold((double)LowThreshold,(double)HighThreshold); 46 | //region转化为himage 47 | HImage hImage = hRegion.RegionToBin(255, 0, 512, 512); 48 | //减去ROI以外多余部分 49 | HImage image1 = hImage.ReduceDomain(Region1); 50 | HImage image2 = hImage.ReduceDomain(Region2); 51 | //生成边缘轮廓 52 | HXLDCont edges1 = image1.EdgesSubPix("canny", 1, 5, 5); 53 | HXLDCont edges2 = image2.EdgesSubPix("canny", 1, 5, 5); 54 | //分割轮廓 55 | HXLDCont xldContsplit1 = edges1.SegmentContoursXld("lines_circles", 5, 4, 2); 56 | HXLDCont xldContsplit2 = edges2.SegmentContoursXld("lines_circles", 5, 4, 2); 57 | //根据特征筛选轮廓 58 | HXLDCont xldCont1 = xldContsplit1.SelectContoursXld("contour_length", 100, 99999999, -0.5, 0.5); 59 | HXLDCont xldCont2 = xldContsplit2.SelectContoursXld("contour_length", 100, 99999999, -0.5, 0.5); 60 | //拟合直线 61 | xldCont1.FitLineContourXld("tukey", -1, 0, 5, 2, out hv_RowBegin1, out hv_ColBegin1, out hv_RowEnd1, out hv_ColEnd1, out hv_Nr1, out hv_Nc1, out hv_Dist1); 62 | xldCont2.FitLineContourXld("tukey", -1, 0, 5, 2, out hv_RowBegin2, out hv_ColBegin2, out hv_RowEnd2, out hv_ColEnd2, out hv_Nr2, out hv_Nc2, out hv_Dist2); 63 | coorderate[0] = hv_RowBegin1; 64 | coorderate[1] = hv_ColBegin1; 65 | coorderate[2] = hv_RowEnd1; 66 | coorderate[3] = hv_ColEnd1; 67 | coorderate[4] = hv_RowBegin2; 68 | coorderate[5] = hv_ColBegin2; 69 | coorderate[6] = hv_RowEnd2; 70 | coorderate[7] = hv_ColEnd2; 71 | return coorderate; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /FrmMain.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace PasteLCM 2 | { 3 | partial class FrmMain 4 | { 5 | /// 6 | /// 必需的设计器变量。 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// 清理所有正在使用的资源。 12 | /// 13 | /// 如果应释放托管资源,为 true;否则为 false。 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows 窗体设计器生成的代码 24 | 25 | /// 26 | /// 设计器支持所需的方法 - 不要 27 | /// 使用代码编辑器修改此方法的内容。 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); 32 | this.panel1 = new System.Windows.Forms.Panel(); 33 | this.pictureBox5 = new System.Windows.Forms.PictureBox(); 34 | this.label1 = new System.Windows.Forms.Label(); 35 | this.button1 = new System.Windows.Forms.Button(); 36 | this.panel2 = new System.Windows.Forms.Panel(); 37 | this.hWindowControl1 = new HalconDotNet.HWindowControl(); 38 | this.panel3 = new System.Windows.Forms.Panel(); 39 | this.checkBox1 = new System.Windows.Forms.CheckBox(); 40 | this.button2 = new System.Windows.Forms.Button(); 41 | this.textBox3 = new System.Windows.Forms.TextBox(); 42 | this.textBox2 = new System.Windows.Forms.TextBox(); 43 | this.textBox4 = new System.Windows.Forms.TextBox(); 44 | this.textBox1 = new System.Windows.Forms.TextBox(); 45 | this.label10 = new System.Windows.Forms.Label(); 46 | this.label9 = new System.Windows.Forms.Label(); 47 | this.label8 = new System.Windows.Forms.Label(); 48 | this.label7 = new System.Windows.Forms.Label(); 49 | this.label6 = new System.Windows.Forms.Label(); 50 | this.panel4 = new System.Windows.Forms.Panel(); 51 | this.label5 = new System.Windows.Forms.Label(); 52 | this.label4 = new System.Windows.Forms.Label(); 53 | this.label3 = new System.Windows.Forms.Label(); 54 | this.label2 = new System.Windows.Forms.Label(); 55 | this.pictureBox4 = new System.Windows.Forms.PictureBox(); 56 | this.pictureBox3 = new System.Windows.Forms.PictureBox(); 57 | this.pictureBox2 = new System.Windows.Forms.PictureBox(); 58 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 59 | this.panel5 = new System.Windows.Forms.Panel(); 60 | this.label15 = new System.Windows.Forms.Label(); 61 | this.checkBox2 = new System.Windows.Forms.CheckBox(); 62 | this.button4 = new System.Windows.Forms.Button(); 63 | this.label11 = new System.Windows.Forms.Label(); 64 | this.textBox8 = new System.Windows.Forms.TextBox(); 65 | this.label12 = new System.Windows.Forms.Label(); 66 | this.textBox7 = new System.Windows.Forms.TextBox(); 67 | this.label13 = new System.Windows.Forms.Label(); 68 | this.textBox6 = new System.Windows.Forms.TextBox(); 69 | this.label14 = new System.Windows.Forms.Label(); 70 | this.textBox5 = new System.Windows.Forms.TextBox(); 71 | this.panel6 = new System.Windows.Forms.Panel(); 72 | this.button3 = new System.Windows.Forms.Button(); 73 | this.panel7 = new System.Windows.Forms.Panel(); 74 | this.hWindowControl2 = new HalconDotNet.HWindowControl(); 75 | this.panel1.SuspendLayout(); 76 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit(); 77 | this.panel2.SuspendLayout(); 78 | this.panel3.SuspendLayout(); 79 | this.panel4.SuspendLayout(); 80 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit(); 81 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); 82 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); 83 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 84 | this.panel5.SuspendLayout(); 85 | this.panel6.SuspendLayout(); 86 | this.panel7.SuspendLayout(); 87 | this.SuspendLayout(); 88 | // 89 | // panel1 90 | // 91 | this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 92 | | System.Windows.Forms.AnchorStyles.Right))); 93 | this.panel1.BackColor = System.Drawing.Color.Lime; 94 | this.panel1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel1.BackgroundImage"))); 95 | this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 96 | this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 97 | this.panel1.Controls.Add(this.pictureBox5); 98 | this.panel1.Controls.Add(this.label1); 99 | this.panel1.Controls.Add(this.button1); 100 | this.panel1.Location = new System.Drawing.Point(10, 10); 101 | this.panel1.Margin = new System.Windows.Forms.Padding(0); 102 | this.panel1.Name = "panel1"; 103 | this.panel1.Size = new System.Drawing.Size(1290, 100); 104 | this.panel1.TabIndex = 3; 105 | // 106 | // pictureBox5 107 | // 108 | this.pictureBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 109 | | System.Windows.Forms.AnchorStyles.Right))); 110 | this.pictureBox5.BackColor = System.Drawing.Color.Transparent; 111 | this.pictureBox5.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox5.BackgroundImage"))); 112 | this.pictureBox5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 113 | this.pictureBox5.Location = new System.Drawing.Point(1075, 13); 114 | this.pictureBox5.Name = "pictureBox5"; 115 | this.pictureBox5.Size = new System.Drawing.Size(75, 71); 116 | this.pictureBox5.TabIndex = 3; 117 | this.pictureBox5.TabStop = false; 118 | // 119 | // label1 120 | // 121 | this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 122 | | System.Windows.Forms.AnchorStyles.Left))); 123 | this.label1.AutoSize = true; 124 | this.label1.BackColor = System.Drawing.Color.Transparent; 125 | this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 126 | this.label1.Location = new System.Drawing.Point(656, 58); 127 | this.label1.Name = "label1"; 128 | this.label1.Size = new System.Drawing.Size(175, 14); 129 | this.label1.TabIndex = 2; 130 | this.label1.Text = "version 1.100 copyright"; 131 | // 132 | // button1 133 | // 134 | this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 135 | | System.Windows.Forms.AnchorStyles.Right))); 136 | this.button1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("button1.BackgroundImage"))); 137 | this.button1.Location = new System.Drawing.Point(1182, 13); 138 | this.button1.Name = "button1"; 139 | this.button1.Size = new System.Drawing.Size(77, 71); 140 | this.button1.TabIndex = 0; 141 | this.button1.UseVisualStyleBackColor = true; 142 | this.button1.Click += new System.EventHandler(this.button1_Click); 143 | // 144 | // panel2 145 | // 146 | this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 147 | | System.Windows.Forms.AnchorStyles.Left))); 148 | this.panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); 149 | this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 150 | this.panel2.Controls.Add(this.hWindowControl1); 151 | this.panel2.Location = new System.Drawing.Point(10, 120); 152 | this.panel2.Name = "panel2"; 153 | this.panel2.Size = new System.Drawing.Size(560, 435); 154 | this.panel2.TabIndex = 4; 155 | // 156 | // hWindowControl1 157 | // 158 | this.hWindowControl1.BackColor = System.Drawing.Color.Black; 159 | this.hWindowControl1.BorderColor = System.Drawing.Color.Black; 160 | this.hWindowControl1.Dock = System.Windows.Forms.DockStyle.Fill; 161 | this.hWindowControl1.ImagePart = new System.Drawing.Rectangle(0, 0, 640, 480); 162 | this.hWindowControl1.Location = new System.Drawing.Point(0, 0); 163 | this.hWindowControl1.Name = "hWindowControl1"; 164 | this.hWindowControl1.Size = new System.Drawing.Size(556, 431); 165 | this.hWindowControl1.TabIndex = 0; 166 | this.hWindowControl1.WindowSize = new System.Drawing.Size(556, 431); 167 | this.hWindowControl1.HMouseMove += new HalconDotNet.HMouseEventHandler(this.hWindowControl1_HMouseMove); 168 | this.hWindowControl1.HMouseDown += new HalconDotNet.HMouseEventHandler(this.hWindowControl1_HMouseDown); 169 | this.hWindowControl1.HMouseUp += new HalconDotNet.HMouseEventHandler(this.hWindowControl1_HMouseUp); 170 | // 171 | // panel3 172 | // 173 | this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 174 | this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); 175 | this.panel3.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel3.BackgroundImage"))); 176 | this.panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 177 | this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 178 | this.panel3.Controls.Add(this.checkBox1); 179 | this.panel3.Controls.Add(this.button2); 180 | this.panel3.Controls.Add(this.textBox3); 181 | this.panel3.Controls.Add(this.textBox2); 182 | this.panel3.Controls.Add(this.textBox4); 183 | this.panel3.Controls.Add(this.textBox1); 184 | this.panel3.Controls.Add(this.label10); 185 | this.panel3.Controls.Add(this.label9); 186 | this.panel3.Controls.Add(this.label8); 187 | this.panel3.Controls.Add(this.label7); 188 | this.panel3.Controls.Add(this.label6); 189 | this.panel3.Location = new System.Drawing.Point(10, 564); 190 | this.panel3.Name = "panel3"; 191 | this.panel3.Size = new System.Drawing.Size(560, 100); 192 | this.panel3.TabIndex = 5; 193 | // 194 | // checkBox1 195 | // 196 | this.checkBox1.AutoSize = true; 197 | this.checkBox1.BackColor = System.Drawing.Color.Transparent; 198 | this.checkBox1.Location = new System.Drawing.Point(405, 58); 199 | this.checkBox1.Name = "checkBox1"; 200 | this.checkBox1.Size = new System.Drawing.Size(84, 16); 201 | this.checkBox1.TabIndex = 3; 202 | this.checkBox1.Text = "显示十字线"; 203 | this.checkBox1.UseVisualStyleBackColor = false; 204 | // 205 | // button2 206 | // 207 | this.button2.Location = new System.Drawing.Point(408, 22); 208 | this.button2.Name = "button2"; 209 | this.button2.Size = new System.Drawing.Size(75, 23); 210 | this.button2.TabIndex = 2; 211 | this.button2.Text = "调整ROI"; 212 | this.button2.UseVisualStyleBackColor = true; 213 | this.button2.Click += new System.EventHandler(this.button2_Click_1); 214 | // 215 | // textBox3 216 | // 217 | this.textBox3.Enabled = false; 218 | this.textBox3.Location = new System.Drawing.Point(286, 56); 219 | this.textBox3.Name = "textBox3"; 220 | this.textBox3.Size = new System.Drawing.Size(44, 21); 221 | this.textBox3.TabIndex = 1; 222 | // 223 | // textBox2 224 | // 225 | this.textBox2.Location = new System.Drawing.Point(286, 24); 226 | this.textBox2.Name = "textBox2"; 227 | this.textBox2.Size = new System.Drawing.Size(44, 21); 228 | this.textBox2.TabIndex = 1; 229 | this.textBox2.Text = "100"; 230 | this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); 231 | // 232 | // textBox4 233 | // 234 | this.textBox4.Enabled = false; 235 | this.textBox4.Location = new System.Drawing.Point(142, 56); 236 | this.textBox4.Name = "textBox4"; 237 | this.textBox4.Size = new System.Drawing.Size(44, 21); 238 | this.textBox4.TabIndex = 1; 239 | // 240 | // textBox1 241 | // 242 | this.textBox1.Location = new System.Drawing.Point(143, 24); 243 | this.textBox1.Name = "textBox1"; 244 | this.textBox1.Size = new System.Drawing.Size(44, 21); 245 | this.textBox1.TabIndex = 1; 246 | this.textBox1.Text = "50"; 247 | this.textBox1.TextAlignChanged += new System.EventHandler(this.textBox1_TextAlignChanged); 248 | this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); 249 | this.textBox1.Leave += new System.EventHandler(this.textBox1_Leave); 250 | // 251 | // label10 252 | // 253 | this.label10.AutoSize = true; 254 | this.label10.BackColor = System.Drawing.Color.Transparent; 255 | this.label10.Location = new System.Drawing.Point(192, 59); 256 | this.label10.Name = "label10"; 257 | this.label10.Size = new System.Drawing.Size(89, 12); 258 | this.label10.TabIndex = 0; 259 | this.label10.Text = "highThreshold:"; 260 | // 261 | // label9 262 | // 263 | this.label9.AutoSize = true; 264 | this.label9.BackColor = System.Drawing.Color.Transparent; 265 | this.label9.Location = new System.Drawing.Point(54, 59); 266 | this.label9.Name = "label9"; 267 | this.label9.Size = new System.Drawing.Size(83, 12); 268 | this.label9.TabIndex = 0; 269 | this.label9.Text = "lowThreshold:"; 270 | // 271 | // label8 272 | // 273 | this.label8.AutoSize = true; 274 | this.label8.BackColor = System.Drawing.Color.Transparent; 275 | this.label8.Location = new System.Drawing.Point(227, 27); 276 | this.label8.Name = "label8"; 277 | this.label8.Size = new System.Drawing.Size(53, 12); 278 | this.label8.TabIndex = 0; 279 | this.label8.Text = "offsetY:"; 280 | // 281 | // label7 282 | // 283 | this.label7.AutoSize = true; 284 | this.label7.BackColor = System.Drawing.Color.Transparent; 285 | this.label7.Location = new System.Drawing.Point(84, 27); 286 | this.label7.Name = "label7"; 287 | this.label7.Size = new System.Drawing.Size(53, 12); 288 | this.label7.TabIndex = 0; 289 | this.label7.Text = "offsetX:"; 290 | // 291 | // label6 292 | // 293 | this.label6.AutoSize = true; 294 | this.label6.BackColor = System.Drawing.Color.Transparent; 295 | this.label6.Dock = System.Windows.Forms.DockStyle.Left; 296 | this.label6.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 297 | this.label6.Location = new System.Drawing.Point(0, 0); 298 | this.label6.Name = "label6"; 299 | this.label6.Size = new System.Drawing.Size(70, 28); 300 | this.label6.TabIndex = 0; 301 | this.label6.Text = "CCD1"; 302 | // 303 | // panel4 304 | // 305 | this.panel4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 306 | | System.Windows.Forms.AnchorStyles.Left) 307 | | System.Windows.Forms.AnchorStyles.Right))); 308 | this.panel4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); 309 | this.panel4.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel4.BackgroundImage"))); 310 | this.panel4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 311 | this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 312 | this.panel4.Controls.Add(this.label5); 313 | this.panel4.Controls.Add(this.label4); 314 | this.panel4.Controls.Add(this.label3); 315 | this.panel4.Controls.Add(this.label2); 316 | this.panel4.Controls.Add(this.pictureBox4); 317 | this.panel4.Controls.Add(this.pictureBox3); 318 | this.panel4.Controls.Add(this.pictureBox2); 319 | this.panel4.Controls.Add(this.pictureBox1); 320 | this.panel4.Location = new System.Drawing.Point(1150, 120); 321 | this.panel4.Name = "panel4"; 322 | this.panel4.Size = new System.Drawing.Size(150, 435); 323 | this.panel4.TabIndex = 6; 324 | // 325 | // label5 326 | // 327 | this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 328 | | System.Windows.Forms.AnchorStyles.Right))); 329 | this.label5.AutoSize = true; 330 | this.label5.BackColor = System.Drawing.Color.Transparent; 331 | this.label5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 332 | this.label5.Location = new System.Drawing.Point(76, 381); 333 | this.label5.Name = "label5"; 334 | this.label5.Size = new System.Drawing.Size(31, 12); 335 | this.label5.TabIndex = 1; 336 | this.label5.Text = "关于"; 337 | // 338 | // label4 339 | // 340 | this.label4.AutoSize = true; 341 | this.label4.BackColor = System.Drawing.Color.Transparent; 342 | this.label4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 343 | this.label4.Location = new System.Drawing.Point(70, 323); 344 | this.label4.Name = "label4"; 345 | this.label4.Size = new System.Drawing.Size(44, 12); 346 | this.label4.TabIndex = 1; 347 | this.label4.Text = "计算器"; 348 | // 349 | // label3 350 | // 351 | this.label3.AutoSize = true; 352 | this.label3.BackColor = System.Drawing.Color.Transparent; 353 | this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 354 | this.label3.Location = new System.Drawing.Point(76, 206); 355 | this.label3.Name = "label3"; 356 | this.label3.Size = new System.Drawing.Size(31, 12); 357 | this.label3.TabIndex = 1; 358 | this.label3.Text = "设定"; 359 | // 360 | // label2 361 | // 362 | this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 363 | | System.Windows.Forms.AnchorStyles.Right))); 364 | this.label2.AutoSize = true; 365 | this.label2.BackColor = System.Drawing.Color.Transparent; 366 | this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 367 | this.label2.Location = new System.Drawing.Point(76, 77); 368 | this.label2.Name = "label2"; 369 | this.label2.Size = new System.Drawing.Size(31, 12); 370 | this.label2.TabIndex = 1; 371 | this.label2.Text = "登录"; 372 | // 373 | // pictureBox4 374 | // 375 | this.pictureBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 376 | | System.Windows.Forms.AnchorStyles.Right))); 377 | this.pictureBox4.BackColor = System.Drawing.Color.Transparent; 378 | this.pictureBox4.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox4.BackgroundImage"))); 379 | this.pictureBox4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 380 | this.pictureBox4.Location = new System.Drawing.Point(57, 325); 381 | this.pictureBox4.Name = "pictureBox4"; 382 | this.pictureBox4.Size = new System.Drawing.Size(32, 52); 383 | this.pictureBox4.TabIndex = 0; 384 | this.pictureBox4.TabStop = false; 385 | this.pictureBox4.Click += new System.EventHandler(this.pictureBox4_Click); 386 | // 387 | // pictureBox3 388 | // 389 | this.pictureBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 390 | | System.Windows.Forms.AnchorStyles.Right))); 391 | this.pictureBox3.BackColor = System.Drawing.Color.Transparent; 392 | this.pictureBox3.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox3.BackgroundImage"))); 393 | this.pictureBox3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 394 | this.pictureBox3.Location = new System.Drawing.Point(57, 267); 395 | this.pictureBox3.Name = "pictureBox3"; 396 | this.pictureBox3.Size = new System.Drawing.Size(32, 52); 397 | this.pictureBox3.TabIndex = 0; 398 | this.pictureBox3.TabStop = false; 399 | // 400 | // pictureBox2 401 | // 402 | this.pictureBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 403 | | System.Windows.Forms.AnchorStyles.Right))); 404 | this.pictureBox2.BackColor = System.Drawing.Color.Transparent; 405 | this.pictureBox2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox2.BackgroundImage"))); 406 | this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 407 | this.pictureBox2.Location = new System.Drawing.Point(57, 150); 408 | this.pictureBox2.Name = "pictureBox2"; 409 | this.pictureBox2.Size = new System.Drawing.Size(32, 52); 410 | this.pictureBox2.TabIndex = 0; 411 | this.pictureBox2.TabStop = false; 412 | // 413 | // pictureBox1 414 | // 415 | this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 416 | | System.Windows.Forms.AnchorStyles.Right))); 417 | this.pictureBox1.BackColor = System.Drawing.Color.Transparent; 418 | this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage"))); 419 | this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 420 | this.pictureBox1.Location = new System.Drawing.Point(57, 21); 421 | this.pictureBox1.Name = "pictureBox1"; 422 | this.pictureBox1.Size = new System.Drawing.Size(32, 52); 423 | this.pictureBox1.TabIndex = 0; 424 | this.pictureBox1.TabStop = false; 425 | // 426 | // panel5 427 | // 428 | this.panel5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 429 | this.panel5.BackColor = System.Drawing.Color.White; 430 | this.panel5.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel5.BackgroundImage"))); 431 | this.panel5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 432 | this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 433 | this.panel5.Controls.Add(this.label15); 434 | this.panel5.Controls.Add(this.checkBox2); 435 | this.panel5.Controls.Add(this.button4); 436 | this.panel5.Controls.Add(this.label11); 437 | this.panel5.Controls.Add(this.textBox8); 438 | this.panel5.Controls.Add(this.label12); 439 | this.panel5.Controls.Add(this.textBox7); 440 | this.panel5.Controls.Add(this.label13); 441 | this.panel5.Controls.Add(this.textBox6); 442 | this.panel5.Controls.Add(this.label14); 443 | this.panel5.Controls.Add(this.textBox5); 444 | this.panel5.Location = new System.Drawing.Point(580, 564); 445 | this.panel5.Name = "panel5"; 446 | this.panel5.Size = new System.Drawing.Size(560, 100); 447 | this.panel5.TabIndex = 7; 448 | // 449 | // label15 450 | // 451 | this.label15.AutoSize = true; 452 | this.label15.BackColor = System.Drawing.Color.Transparent; 453 | this.label15.Dock = System.Windows.Forms.DockStyle.Left; 454 | this.label15.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 455 | this.label15.Location = new System.Drawing.Point(0, 0); 456 | this.label15.Name = "label15"; 457 | this.label15.Size = new System.Drawing.Size(70, 28); 458 | this.label15.TabIndex = 4; 459 | this.label15.Text = "CCD2"; 460 | // 461 | // checkBox2 462 | // 463 | this.checkBox2.AutoSize = true; 464 | this.checkBox2.BackColor = System.Drawing.Color.Transparent; 465 | this.checkBox2.Location = new System.Drawing.Point(406, 58); 466 | this.checkBox2.Name = "checkBox2"; 467 | this.checkBox2.Size = new System.Drawing.Size(84, 16); 468 | this.checkBox2.TabIndex = 3; 469 | this.checkBox2.Text = "显示十字线"; 470 | this.checkBox2.UseVisualStyleBackColor = false; 471 | // 472 | // button4 473 | // 474 | this.button4.Location = new System.Drawing.Point(409, 22); 475 | this.button4.Name = "button4"; 476 | this.button4.Size = new System.Drawing.Size(75, 23); 477 | this.button4.TabIndex = 2; 478 | this.button4.Text = "调整ROI"; 479 | this.button4.UseVisualStyleBackColor = true; 480 | this.button4.Click += new System.EventHandler(this.button4_Click); 481 | // 482 | // label11 483 | // 484 | this.label11.AutoSize = true; 485 | this.label11.BackColor = System.Drawing.Color.Transparent; 486 | this.label11.Location = new System.Drawing.Point(85, 27); 487 | this.label11.Name = "label11"; 488 | this.label11.Size = new System.Drawing.Size(53, 12); 489 | this.label11.TabIndex = 0; 490 | this.label11.Text = "offsetX:"; 491 | // 492 | // textBox8 493 | // 494 | this.textBox8.Location = new System.Drawing.Point(287, 56); 495 | this.textBox8.Name = "textBox8"; 496 | this.textBox8.Size = new System.Drawing.Size(44, 21); 497 | this.textBox8.TabIndex = 1; 498 | // 499 | // label12 500 | // 501 | this.label12.AutoSize = true; 502 | this.label12.BackColor = System.Drawing.Color.Transparent; 503 | this.label12.Location = new System.Drawing.Point(228, 27); 504 | this.label12.Name = "label12"; 505 | this.label12.Size = new System.Drawing.Size(53, 12); 506 | this.label12.TabIndex = 0; 507 | this.label12.Text = "offsetY:"; 508 | // 509 | // textBox7 510 | // 511 | this.textBox7.Location = new System.Drawing.Point(287, 24); 512 | this.textBox7.Name = "textBox7"; 513 | this.textBox7.Size = new System.Drawing.Size(44, 21); 514 | this.textBox7.TabIndex = 1; 515 | // 516 | // label13 517 | // 518 | this.label13.AutoSize = true; 519 | this.label13.BackColor = System.Drawing.Color.Transparent; 520 | this.label13.Location = new System.Drawing.Point(55, 59); 521 | this.label13.Name = "label13"; 522 | this.label13.Size = new System.Drawing.Size(83, 12); 523 | this.label13.TabIndex = 0; 524 | this.label13.Text = "lowThreshold:"; 525 | // 526 | // textBox6 527 | // 528 | this.textBox6.Location = new System.Drawing.Point(143, 56); 529 | this.textBox6.Name = "textBox6"; 530 | this.textBox6.Size = new System.Drawing.Size(44, 21); 531 | this.textBox6.TabIndex = 1; 532 | // 533 | // label14 534 | // 535 | this.label14.AutoSize = true; 536 | this.label14.BackColor = System.Drawing.Color.Transparent; 537 | this.label14.Location = new System.Drawing.Point(193, 59); 538 | this.label14.Name = "label14"; 539 | this.label14.Size = new System.Drawing.Size(89, 12); 540 | this.label14.TabIndex = 0; 541 | this.label14.Text = "highThreshold:"; 542 | // 543 | // textBox5 544 | // 545 | this.textBox5.Location = new System.Drawing.Point(144, 24); 546 | this.textBox5.Name = "textBox5"; 547 | this.textBox5.Size = new System.Drawing.Size(44, 21); 548 | this.textBox5.TabIndex = 1; 549 | // 550 | // panel6 551 | // 552 | this.panel6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 553 | | System.Windows.Forms.AnchorStyles.Right))); 554 | this.panel6.BackColor = System.Drawing.Color.Silver; 555 | this.panel6.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel6.BackgroundImage"))); 556 | this.panel6.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 557 | this.panel6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 558 | this.panel6.Controls.Add(this.button3); 559 | this.panel6.Location = new System.Drawing.Point(1150, 564); 560 | this.panel6.Name = "panel6"; 561 | this.panel6.Size = new System.Drawing.Size(150, 100); 562 | this.panel6.TabIndex = 8; 563 | // 564 | // button3 565 | // 566 | this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 567 | | System.Windows.Forms.AnchorStyles.Left) 568 | | System.Windows.Forms.AnchorStyles.Right))); 569 | this.button3.BackColor = System.Drawing.Color.Red; 570 | this.button3.FlatAppearance.BorderColor = System.Drawing.Color.Green; 571 | this.button3.FlatAppearance.BorderSize = 2; 572 | this.button3.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); 573 | this.button3.ForeColor = System.Drawing.Color.Black; 574 | this.button3.Location = new System.Drawing.Point(18, 16); 575 | this.button3.Name = "button3"; 576 | this.button3.Size = new System.Drawing.Size(110, 66); 577 | this.button3.TabIndex = 0; 578 | this.button3.Text = "登 录"; 579 | this.button3.UseVisualStyleBackColor = false; 580 | this.button3.Click += new System.EventHandler(this.button3_Click); 581 | // 582 | // panel7 583 | // 584 | this.panel7.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 585 | | System.Windows.Forms.AnchorStyles.Left))); 586 | this.panel7.BackColor = System.Drawing.Color.Olive; 587 | this.panel7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 588 | this.panel7.Controls.Add(this.hWindowControl2); 589 | this.panel7.Location = new System.Drawing.Point(580, 120); 590 | this.panel7.Name = "panel7"; 591 | this.panel7.Size = new System.Drawing.Size(560, 435); 592 | this.panel7.TabIndex = 9; 593 | // 594 | // hWindowControl2 595 | // 596 | this.hWindowControl2.BackColor = System.Drawing.Color.Black; 597 | this.hWindowControl2.BorderColor = System.Drawing.Color.Black; 598 | this.hWindowControl2.Dock = System.Windows.Forms.DockStyle.Fill; 599 | this.hWindowControl2.ImagePart = new System.Drawing.Rectangle(0, 0, 640, 480); 600 | this.hWindowControl2.Location = new System.Drawing.Point(0, 0); 601 | this.hWindowControl2.Name = "hWindowControl2"; 602 | this.hWindowControl2.Size = new System.Drawing.Size(556, 431); 603 | this.hWindowControl2.TabIndex = 0; 604 | this.hWindowControl2.WindowSize = new System.Drawing.Size(556, 431); 605 | // 606 | // FrmMain 607 | // 608 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 609 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 610 | this.BackColor = System.Drawing.Color.Silver; 611 | this.ClientSize = new System.Drawing.Size(1312, 676); 612 | this.Controls.Add(this.panel7); 613 | this.Controls.Add(this.panel6); 614 | this.Controls.Add(this.panel5); 615 | this.Controls.Add(this.panel4); 616 | this.Controls.Add(this.panel3); 617 | this.Controls.Add(this.panel2); 618 | this.Controls.Add(this.panel1); 619 | this.ForeColor = System.Drawing.Color.Black; 620 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 621 | this.Name = "FrmMain"; 622 | this.Text = "Form1"; 623 | this.WindowState = System.Windows.Forms.FormWindowState.Maximized; 624 | this.Load += new System.EventHandler(this.FrmMain_Load); 625 | this.panel1.ResumeLayout(false); 626 | this.panel1.PerformLayout(); 627 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit(); 628 | this.panel2.ResumeLayout(false); 629 | this.panel3.ResumeLayout(false); 630 | this.panel3.PerformLayout(); 631 | this.panel4.ResumeLayout(false); 632 | this.panel4.PerformLayout(); 633 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit(); 634 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit(); 635 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); 636 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 637 | this.panel5.ResumeLayout(false); 638 | this.panel5.PerformLayout(); 639 | this.panel6.ResumeLayout(false); 640 | this.panel7.ResumeLayout(false); 641 | this.ResumeLayout(false); 642 | 643 | } 644 | 645 | #endregion 646 | 647 | private System.Windows.Forms.Panel panel1; 648 | private System.Windows.Forms.Panel panel2; 649 | private System.Windows.Forms.Panel panel3; 650 | private System.Windows.Forms.Panel panel4; 651 | private System.Windows.Forms.Panel panel5; 652 | private System.Windows.Forms.Panel panel6; 653 | private System.Windows.Forms.Panel panel7; 654 | private System.Windows.Forms.Button button1; 655 | private HalconDotNet.HWindowControl hWindowControl1; 656 | private System.Windows.Forms.Button button3; 657 | private System.Windows.Forms.Label label1; 658 | private System.Windows.Forms.PictureBox pictureBox4; 659 | private System.Windows.Forms.PictureBox pictureBox3; 660 | private System.Windows.Forms.PictureBox pictureBox2; 661 | private System.Windows.Forms.PictureBox pictureBox1; 662 | private System.Windows.Forms.Label label5; 663 | private System.Windows.Forms.Label label4; 664 | private System.Windows.Forms.Label label3; 665 | private System.Windows.Forms.Label label2; 666 | private System.Windows.Forms.PictureBox pictureBox5; 667 | private System.Windows.Forms.CheckBox checkBox1; 668 | private System.Windows.Forms.Button button2; 669 | public System.Windows.Forms.TextBox textBox3; 670 | private System.Windows.Forms.TextBox textBox2; 671 | public System.Windows.Forms.TextBox textBox4; 672 | private System.Windows.Forms.TextBox textBox1; 673 | private System.Windows.Forms.Label label10; 674 | private System.Windows.Forms.Label label9; 675 | private System.Windows.Forms.Label label8; 676 | private System.Windows.Forms.Label label7; 677 | private System.Windows.Forms.Label label6; 678 | private System.Windows.Forms.Label label15; 679 | private System.Windows.Forms.CheckBox checkBox2; 680 | private System.Windows.Forms.Button button4; 681 | private System.Windows.Forms.Label label11; 682 | private System.Windows.Forms.TextBox textBox8; 683 | private System.Windows.Forms.Label label12; 684 | private System.Windows.Forms.TextBox textBox7; 685 | private System.Windows.Forms.Label label13; 686 | private System.Windows.Forms.TextBox textBox6; 687 | private System.Windows.Forms.Label label14; 688 | private System.Windows.Forms.TextBox textBox5; 689 | private HalconDotNet.HWindowControl hWindowControl2; 690 | } 691 | } 692 | 693 | -------------------------------------------------------------------------------- /FrmMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using HalconDotNet; 10 | using System.Threading; 11 | 12 | namespace PasteLCM 13 | { 14 | public partial class FrmMain : Form 15 | { 16 | public FrmMain() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | private void button1_Click(object sender, EventArgs e) 22 | { 23 | if (MessageBox.Show("是否确认退出?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) 24 | { Application.Exit(); } 25 | } 26 | ImageGrab ig = null; 27 | private void FrmMain_Load(object sender, EventArgs e) 28 | { 29 | this.SetStyle(ControlStyles.OptimizedDoubleBuffer|ControlStyles.ResizeRedraw|ControlStyles.AllPaintingInWmPaint,true); 30 | ig = new ImageGrab("DirectShow", hWindowControl1.HalconWindow, 100, 300, 200, 500, 300, 100, 400, 250, 148.4, 399.9, 149.8, 300.3, 250.0, 229.5, 399.9, 218.5, double.Parse(textBox1.Text), double.Parse(textBox2.Text),0); 31 | ig.OpenFramegrabber(); 32 | ig.ShowImg(); 33 | } 34 | 35 | private void button2_Click(object sender, EventArgs e) 36 | { 37 | ig.Row11 += 1; 38 | } 39 | private HImage HobjectToHimage(HObject hobject) 40 | { 41 | HImage image = new HImage(); 42 | HTuple pointer, type, width, height; 43 | HOperatorSet.GetImagePointer1(hobject, out pointer, out type, out width, out height); 44 | image.GenImage1(type, width, height, pointer); 45 | return image; 46 | } 47 | 48 | private void button3_Click(object sender, EventArgs e) 49 | { 50 | HImage hImage = HobjectToHimage(ig.ho_img1); 51 | HRegion region1 = new HRegion(ig.Row11, ig.Column11, ig.Row12, ig.Column12); 52 | HRegion region2 = new HRegion(ig.Row21, ig.Column21, ig.Row22, ig.Column22); 53 | try 54 | { 55 | FitLine ft = new FitLine(hImage, region1, region2, int.Parse(textBox4.Text), int.Parse(textBox3.Text)); 56 | double[] lines = ft.Process(); 57 | ig.LineRowBegin1 = lines[0]; 58 | ig.LineColBegin1 = lines[1]; 59 | ig.LineRowEnd1 = lines[2]; 60 | ig.LineColEnd1 = lines[3]; 61 | ig.LineRowBegin2 = lines[4]; 62 | ig.LineColBegin2 = lines[5]; 63 | ig.LineRowEnd2 = lines[6]; 64 | ig.LineColEnd2 = lines[7]; 65 | } 66 | catch { } 67 | } 68 | 69 | private void pictureBox4_Click(object sender, EventArgs e) 70 | { 71 | 72 | } 73 | 74 | private void button2_Click_1(object sender, EventArgs e) 75 | { 76 | 77 | } 78 | 79 | private void button4_Click(object sender, EventArgs e) 80 | { 81 | ig.SendImg = 10; 82 | Adjust try1 = new Adjust(ig.ho_img1, this); 83 | ig.SendImg = 0; 84 | try1.ShowDialog(); 85 | } 86 | 87 | private void textBox1_TextChanged(object sender, EventArgs e) 88 | { 89 | } 90 | 91 | private void textBox2_TextChanged(object sender, EventArgs e) 92 | { 93 | ig.Distance2 = double.Parse(textBox2.Text); 94 | } 95 | 96 | private void textBox1_TextAlignChanged(object sender, EventArgs e) 97 | { 98 | 99 | } 100 | 101 | private void textBox1_Leave(object sender, EventArgs e) 102 | { 103 | ig.Distance1 = double.Parse(textBox1.Text); 104 | 105 | } 106 | 107 | private void hWindowControl1_HMouseMove(object sender, HMouseEventArgs e) 108 | { 109 | if (distToClose <= 5) 110 | { 111 | ig.moveByHandle(e.X, e.Y); 112 | } 113 | } 114 | double distToClose; 115 | private void hWindowControl1_HMouseDown(object sender, HMouseEventArgs e) 116 | { 117 | distToClose = ig.distToClosestHandle(e.X, e.Y); 118 | } 119 | 120 | private void hWindowControl1_HMouseUp(object sender, HMouseEventArgs e) 121 | { 122 | distToClose = 10; 123 | } 124 | 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /ImageGrab.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using HalconDotNet; 6 | using System.Threading; 7 | 8 | namespace PasteLCM 9 | { 10 | class ImageGrab 11 | { 12 | public double Row11 { get; set; } 13 | public double Column11 { get; set; } 14 | public double Row12 { get; set; } 15 | public double Column12 { get; set; } 16 | public double Row21 { get; set; } 17 | public double Column21 { get; set; } 18 | public double Row22 { get; set; } 19 | public double Column22 { get; set; } 20 | public string CCD { get; set; } 21 | public HWindow Window { get; set; } 22 | public double LineRowBegin1 { get; set; } 23 | public double LineColBegin1 { get; set; } 24 | public double LineRowEnd1 { get; set; } 25 | public double LineColEnd1 { get; set; } 26 | public double LineRowBegin2 { get; set; } 27 | public double LineColBegin2 { get; set; } 28 | public double LineRowEnd2 { get; set; } 29 | public double LineColEnd2 { get; set; } 30 | public double Distance1 { get; set; } 31 | public double Distance2 { get; set; } 32 | public int SendImg { get; set; } 33 | private HTuple acqHandle; 34 | public ImageGrab(string ccd, HWindow window, HTuple row11, HTuple column11, HTuple row12, HTuple column12, HTuple row21, HTuple column21, HTuple row22, HTuple column22, HTuple lineRowBegin1, HTuple lineColBegin1, HTuple lineRowEnd1, HTuple lineColEnd1, HTuple lineRowBegin2, HTuple lineColBegin2, HTuple lineRowEnd2, HTuple lineColEnd2, HTuple distance1, HTuple distance2,int sendImg) 35 | { 36 | this.CCD = ccd; 37 | this.Window = window; 38 | this.Row11 = row11; 39 | this.Column11 = column11; 40 | this.Row12 = row12; 41 | this.Column12 = column12; 42 | this.Row21 = row21; 43 | this.Column21 = column21; 44 | this.Row22 = row22; 45 | this.Column22 = column22; 46 | this.LineRowBegin1 = lineRowBegin1; 47 | this.LineColBegin1 = lineColBegin1; 48 | this.LineRowEnd1 = lineRowEnd1; 49 | this.LineColEnd1 = lineColEnd1; 50 | this.LineRowBegin2 = lineRowBegin2; 51 | this.LineColBegin2 = lineColBegin2; 52 | this.LineRowEnd2 = lineRowEnd2; 53 | this.LineColEnd2 = lineColEnd2; 54 | this.Distance1 = distance1; 55 | this.Distance2 = distance2; 56 | this.SendImg = sendImg; 57 | } 58 | public void OpenFramegrabber() 59 | { 60 | HOperatorSet.OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8, "rgb", 61 | -1, "false", "default", "0", -1, -1, out acqHandle); 62 | HOperatorSet.GrabImageStart(acqHandle, -1); 63 | } 64 | public HObject ho_img; 65 | //public bool sendImg = false; 66 | public HObject ho_img1; 67 | public void ShowImg() 68 | { 69 | Thread th = new Thread(Show); 70 | th.IsBackground = true; 71 | th.Start(); 72 | } 73 | /* public void SengImg() 74 | { 75 | while(SendImg) 76 | { 77 | ho_img1 = ho_img; 78 | this.SendImg = false; 79 | } 80 | }*/ 81 | public void Show() 82 | { 83 | while (true) 84 | { 85 | if (this.SendImg>=5) 86 | { 87 | ho_img1 = ho_img; 88 | //break; 89 | } 90 | if (ho_img != null) 91 | { 92 | ho_img.Dispose(); 93 | } 94 | HOperatorSet.GrabImageAsync(out ho_img, acqHandle, -1); 95 | HOperatorSet.DispImage(ho_img, Window); 96 | 97 | Window.SetLineWidth(2); 98 | Window.SetDraw("margin"); 99 | Window.SetColor("green"); 100 | ShowRectancleandLine(); 101 | ExtendAndDoubleLine(); 102 | displayActive(); 103 | } 104 | } 105 | public void ShowRectancleandLine() 106 | { 107 | Window.DispRectangle1(Row11, Column11, Row12, Column12); 108 | Window.DispRectangle2(Row11 / 2 + Row12 / 2, Column12 / 2 + Column11 / 2, 0, 5, 5); 109 | Window.DispRectangle1(Row21, Column21, Row22, Column22); 110 | Window.DispRectangle2(Row21 / 2 + Row22 / 2, Column22 / 2 + Column21 / 2, 0, 5, 5); 111 | } 112 | /// 113 | /// 延伸和复制线 114 | /// 115 | public void ExtendAndDoubleLine() 116 | { 117 | HTuple phi1, phi2; 118 | HOperatorSet.LineOrientation(LineRowBegin1, LineColBegin1, LineRowEnd1, LineColEnd1, out phi1); 119 | HOperatorSet.LineOrientation(LineRowBegin2, LineColBegin2, LineRowEnd2, LineColEnd2, out phi2); 120 | Window.DispLine(LineRowBegin1 - 10000 * Math.Sin(phi1), LineColBegin1 + 10000 * Math.Cos(phi1), LineRowEnd1 + 10000 * Math.Sin(phi1), LineColEnd1 - 10000 * Math.Cos(phi1)); 121 | Window.DispLine(LineRowBegin2 - 10000 * Math.Sin(phi2), LineColBegin2 + 10000 * Math.Cos(phi2), LineRowEnd2 + 10000 * Math.Sin(phi2), LineColEnd2 - 10000 * Math.Cos(phi2)); 122 | Window.SetColor("red"); 123 | if ((LineRowBegin1 / 2 + LineRowEnd1 / 2) < (LineRowBegin2 / 2 + LineRowEnd2 / 2)) 124 | { 125 | //Window.ReadString("wwww", 32); 126 | //Window.ClearWindow(); 127 | 128 | Window.DispLine(LineRowBegin1 - 10000 * Math.Sin(phi1) + Distance2 / Math.Cos(phi1), LineColBegin1 + 10000 * Math.Cos(phi1), LineRowEnd1 + 10000 * Math.Sin(phi1) + Distance2 / Math.Cos(phi1), LineColEnd1 - 10000 * Math.Cos(phi1)); 129 | Window.DispLine(LineRowBegin2 - 10000 * Math.Sin(phi2), LineColBegin2 + 10000 * Math.Cos(phi2) + Math.Abs(Distance1 / Math.Sin(phi2)), LineRowEnd2 + 10000 * Math.Sin(phi2), LineColEnd2 - 10000 * Math.Cos(phi2) + Math.Abs(Distance1 / Math.Sin(phi2))); 130 | } 131 | else 132 | { 133 | Window.DispLine(LineRowBegin1 - 10000 * Math.Sin(phi1), LineColBegin1 + 10000 * Math.Cos(phi1) + Math.Abs(Distance1 / Math.Sin(phi1)), LineRowEnd1 + 10000 * Math.Sin(phi1), LineColEnd1 - 10000 * Math.Cos(phi1) + Math.Abs(Distance1 / Math.Sin(phi1))); 134 | Window.DispLine(LineRowBegin2 - 10000 * Math.Sin(phi2) + Distance2 / Math.Cos(phi2), LineColBegin2 + 10000 * Math.Cos(phi2), LineRowEnd2 + 10000 * Math.Sin(phi2) + Distance2 / Math.Cos(phi2), LineColEnd2 - 10000 * Math.Cos(phi2)); 135 | } 136 | } 137 | public void CloseFramegrabber() 138 | { 139 | HOperatorSet.CloseFramegrabber(acqHandle); 140 | ho_img.Dispose(); 141 | } 142 | int NumHandles = 10; 143 | int activeHandleIdx = 10; 144 | /// 145 | /// 计算鼠标到点的距离 146 | /// 147 | /// 148 | /// 149 | /// 150 | public double distToClosestHandle(double x, double y) 151 | { 152 | double max = 10000; 153 | double[] val = new double[NumHandles]; 154 | val[0] = HMisc.DistancePp(y, x, Row11, Column11); // 1upper left 155 | val[1] = HMisc.DistancePp(y, x, Row11, Column12); // 1upper right 156 | val[2] = HMisc.DistancePp(y, x, Row12, Column12); // 1lower right 157 | val[3] = HMisc.DistancePp(y, x, Row12, Column11); // 1lower left 158 | val[4] = HMisc.DistancePp(y, x, Row11 / 2 + Row12 / 2, Column11 / 2 + Column12 / 2); // 1midpoint 159 | val[5] = HMisc.DistancePp(y, x, Row21, Column21); // 2upper left 160 | val[6] = HMisc.DistancePp(y, x, Row21, Column22); // 2upper right 161 | val[7] = HMisc.DistancePp(y, x, Row22, Column22); // 2lower right 162 | val[8] = HMisc.DistancePp(y, x, Row22, Column21); // 2lower left 163 | val[9] = HMisc.DistancePp(y, x, Row21 / 2 + Row22 / 2, Column21 / 2 + Column22 / 2); // 2midpoint 164 | for (int i = 0; i < NumHandles; i++) 165 | { 166 | if (val[i] < max) 167 | { 168 | max = val[i]; 169 | activeHandleIdx = i; 170 | } 171 | }// end of for 172 | 173 | return val[activeHandleIdx]; 174 | } 175 | /// 176 | /// 显示激活点 177 | /// 178 | public void displayActive() 179 | { 180 | switch (activeHandleIdx) 181 | { 182 | case 0: 183 | Window.DispRectangle2(Row11, Column11, 0, 5, 5); 184 | break; 185 | case 1: 186 | Window.DispRectangle2(Row11, Column12, 0, 5, 5); 187 | break; 188 | case 2: 189 | Window.DispRectangle2(Row12, Column12, 0, 5, 5); 190 | break; 191 | case 3: 192 | Window.DispRectangle2(Row12, Column11, 0, 5, 5); 193 | break; 194 | case 4: 195 | Window.DispRectangle2(Row11 / 2 + Row12 / 2, Column11 / 2 + Column12 / 2, 0, 5, 5); 196 | break; 197 | case 5: 198 | Window.DispRectangle2(Row21, Column21, 0, 5, 5); 199 | break; 200 | case 6: 201 | Window.DispRectangle2(Row21, Column22, 0, 5, 5); 202 | break; 203 | case 7: 204 | Window.DispRectangle2(Row22, Column22, 0, 5, 5); 205 | break; 206 | case 8: 207 | Window.DispRectangle2(Row22, Column21, 0, 5, 5); 208 | break; 209 | case 9: 210 | Window.DispRectangle2(Row21 / 2 + Row22 / 2, Column21 / 2 + Column22 / 2, 0, 5, 5); 211 | break; 212 | } 213 | } 214 | /// 215 | /// 用鼠标拖动 216 | /// 217 | /// 218 | /// 219 | public void moveByHandle(double newX, double newY) 220 | { 221 | double len1, len2; 222 | double tmp; 223 | switch (activeHandleIdx) 224 | { 225 | case 0: 226 | Row11 = newY; 227 | Column11 = newX; 228 | break; 229 | case 1: 230 | Row11 = newY; 231 | Column12 = newX; 232 | break; 233 | case 2: 234 | Row12 = newY; 235 | Column12 = newX; 236 | break; 237 | case 3: 238 | Row12 = newY; 239 | Column11 = newX; 240 | break; 241 | case 4: 242 | len1 = Row12 / 2 - Row11 / 2; 243 | len2 = Column12 / 2 - Column11 / 2; 244 | Row11 = newY - len1; 245 | Column11 = newX - len2; 246 | Row12 = newY + len1; 247 | Column12 = newX + len2; 248 | break; 249 | case 5: 250 | Row21 = newY; 251 | Column21 = newX; 252 | break; 253 | case 6: 254 | Row21 = newY; 255 | Column22 = newX; 256 | break; 257 | case 7: 258 | Row22 = newY; 259 | Column22 = newX; 260 | break; 261 | case 8: 262 | Row22 = newY; 263 | Column21 = newX; 264 | break; 265 | case 9: 266 | len1 = Row22 / 2 - Row21 / 2; 267 | len2 = Column22 / 2 - Column21 / 2; 268 | Row21 = newY - len1; 269 | Column21 = newX - len2; 270 | Row22 = newY + len1; 271 | Column22 = newX + len2; 272 | break; 273 | } 274 | if (Row12 <= Row11) 275 | { 276 | tmp = Row11; 277 | Row11 = Row12; 278 | Row12 = tmp; 279 | } 280 | if (Column12 <= Column11) 281 | { 282 | tmp = Column11; 283 | Column11 = Column12; 284 | Column12 = tmp; 285 | } 286 | if (Row22 <= Row21) 287 | { 288 | tmp = Row21; 289 | Row21 = Row22; 290 | Row22 = tmp; 291 | } 292 | if (Column22 <= Column21) 293 | { 294 | tmp = Column21; 295 | Column21 = Column22; 296 | Column22 = tmp; 297 | } 298 | } 299 | } 300 | } 301 | -------------------------------------------------------------------------------- /PasteLCM.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {43AD43F0-7A3E-4C8F-9398-7B6E96BB8BAC} 9 | WinExe 10 | Properties 11 | PasteLCM 12 | PasteLCM 13 | v4.0 14 | 15 | 16 | 512 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | true 28 | 29 | 30 | x86 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | False 41 | ..\..\..\..\Program Files\MVTec\HALCON-10.0\bin\dotnet20\halcondotnet.dll 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | Form 58 | 59 | 60 | FrmMain.cs 61 | 62 | 63 | 64 | 65 | 66 | Form 67 | 68 | 69 | Adjust.cs 70 | 71 | 72 | FrmMain.cs 73 | 74 | 75 | ResXFileCodeGenerator 76 | Resources.Designer.cs 77 | Designer 78 | 79 | 80 | True 81 | Resources.resx 82 | True 83 | 84 | 85 | Adjust.cs 86 | 87 | 88 | 89 | SettingsSingleFileGenerator 90 | Settings.Designer.cs 91 | 92 | 93 | True 94 | Settings.settings 95 | True 96 | 97 | 98 | 99 | 100 | {C60BE24F-86AA-4005-B940-12AAB26D24CA} 101 | 1 102 | 0 103 | 0 104 | aximp 105 | False 106 | 107 | 108 | {00020430-0000-0000-C000-000000000046} 109 | 2 110 | 0 111 | 0 112 | primary 113 | False 114 | False 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /PasteLCM.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PasteLCM", "PasteLCM\PasteLCM.csproj", "{43AD43F0-7A3E-4C8F-9398-7B6E96BB8BAC}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x86 = Debug|x86 9 | Release|x86 = Release|x86 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {43AD43F0-7A3E-4C8F-9398-7B6E96BB8BAC}.Debug|x86.ActiveCfg = Debug|x86 13 | {43AD43F0-7A3E-4C8F-9398-7B6E96BB8BAC}.Debug|x86.Build.0 = Debug|x86 14 | {43AD43F0-7A3E-4C8F-9398-7B6E96BB8BAC}.Release|x86.ActiveCfg = Release|x86 15 | {43AD43F0-7A3E-4C8F-9398-7B6E96BB8BAC}.Release|x86.Build.0 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace PasteLCM 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// 应用程序的主入口点。 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new FrmMain()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PasteLCM 2 | 用C#写的基于halcon开发包的模组贴合影像系统 3 | -------------------------------------------------------------------------------- /app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | --------------------------------------------------------------------------------