已修改46个文件
已添加12个文件
已删除1个文件
| | |
| | | // |
| | | // btnSetting |
| | | // |
| | | btnSetting.ForeColor = SystemColors.ControlText; |
| | | btnSetting.Location = new Point(3, 18); |
| | | btnSetting.Name = "btnSetting"; |
| | | btnSetting.Size = new Size(97, 29); |
| | |
| | | // |
| | | // CameraForm |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | AutoScaleMode = AutoScaleMode.None; |
| | | ClientSize = new Size(900, 600); |
| | | Controls.Add(themeForm1); |
| | | FormBorderStyle = FormBorderStyle.None; |
| | |
| | | <data name="themeForm1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
| | | <value> |
| | | iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO |
| | | vQAADr0BR/uQrQAAA+JJREFUWEftVkuIHGUQbt34iMEoq2S2q3p3yTJsuqpnJ+L6WBRdwaigohfFgEou |
| | | vAAADrwBlbxySQAAA+JJREFUWEftVkuIHGUQbt34iMEoq2S2q3p3yTJsuqpnJ+L6WBRdwaigohfFgEou |
| | | BkVBUPCBCEG8BXNQ48GLeImCehIJxMsqhsSZruod46K4HtSIGjU+4iOr0c1I9fSsM3/PLNtCPO0H36m/ |
| | | evz/X11VnreKVRTAHPOZumkY6lFwqURws3BwZ8ywTQnuiCP/+iTCzY1qaUPzdm/Atf3PaHre6XPsjyQM |
| | | 2xLGV4XwIyX4QRj+UMK/lPFvJTyhBMeV8IgQvmRJuH4Ko+l5p9UjGBbCJ5RxTgj+VMZmXxKcSAjekHE/ |
| | |
| | | // |
| | | // CamerasEditPage |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | BackColor = Color.FromArgb(32, 41, 50); |
| | | Controls.Add(tableLayoutPanel1); |
| | | Name = "CamerasEditPage"; |
| | |
| | | // |
| | | // CreateCameraForm |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | AutoScaleMode = AutoScaleMode.None; |
| | | ClientSize = new Size(507, 309); |
| | | ControlBox = false; |
| | | Controls.Add(uiComboBoxSN); |
| | |
| | | <data name="themeForm1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
| | | <value> |
| | | iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO |
| | | wgAADsIBFShKgAAAA+JJREFUWEftVkuIHGUQbt34iMEoq2S2q3p3yTJsuqpnJ+L6WBRdwaigohfFgEou |
| | | BkVBUPCBCEG8BXNQ48GLeImCehIJxMsqhsSZruod46K4HtSIGjU+4iOr0c1I9fSsM3/PLNtCPO0H36m/ |
| | | evz/X11VnreKVRTAHPOZumkY6lFwqURws3BwZ8ywTQnuiCP/+iTCzY1qaUPzdm/Atf3PaHre6XPsjyQM |
| | | 2xLGV4XwIyX4QRj+UMK/lPFvJTyhBMeV8IgQvmRJuH4Ko+l5p9UjGBbCJ5RxTgj+VMZmXxKcSAjekHE/ |
| | | NNs5DgaTKLinEQYVO4Trf1mkV81wixLUslPmA3bzF2XcKeP+hWY/u3n0fCXcrQwLyjAvjNsb1dI6N05P |
| | | mFAIHlHG73sEypPgGwnhfpn0zzH7jzddcK4Q7kqfKNMI4a9K+MwBDgbdeF04MBWsFYYdQvhbLlBvfhKT |
| | | f+vMtLfG7C0JJXxKGY67WnvCmPAFGRs7z42boul5AzHBfdK6TjdQtzPGk8oos5F/5Y7sfVvPhg+lp+1h |
| | | 0yIsxARPmtaN78WEl8eEX+SNclxUhne0glUrNrN9zfMGlPAuZTzaQ99FYfwuDv3ruoLvq5bWaQSvZCfL |
| | | GXUYLwrj240Qxtu2lkSN4FpdWfKZH9jb9RQ1Cq62f9sVOlxUxn3KQXnJ0PO8QxU/jBm1h74v7ZniEG9K |
| | | Hdg/quzvXO709k0Y3u08ucGqWgheX862H4XgxbR47SqU8D1X0EXC2VmGizqDz0xPr0kYH9eO360gNe0b |
| | | jWppozB+1kOQEb5MCLa0C64NoeGrhOGrvH6lhK81GiIvnggmrDLzgvTkvwvDA+5wsU4nhG/m9AUoBD/F |
| | | HFzWN4H0XQn2vF8eXN8Z3FAPYasl59oUYjuB+sTImDB+nhfgYQ39STf4fmu1DHtz+oIUgiM1KkWtwcFw |
| | | sOujVT3hrnaL7UQc+hcL5W+sKIXhw0OVjaW0iwnBc47gqIQ45QY32PKRzv8eTguRYM9SS5YouEEZjv37 |
| | | EffbzbjBDdZyxZYQ12EB2qS0bWrJqRVazPDWkojwZbuZrsgZtDJ0iY1g12khEtTicMTvclwn2CKE32YJ |
| | | 7G5PORfZ1HtMCH7MOV4BrQ3XCe92+4onk5Nn2PolDAvWXnuOzAwzo6Nnx4Q3SrojwqfKeMxWMpsXWVs+ |
| | | 2WrfKRdbW1W6Hf0shM/33Y7my4PrleFZIfhAaWjU/e5ivlw+y3S2FySMtynjvcrwsFiLJv/RhPBB2ws1 |
| | | hK2WcBLBFf1qawlplwvxaQlxe786OOU4PBWsjSO85mBlQ8n99r/BisSdAas4FfgHpdEUZpwUX7sAAAAA |
| | | SUVORK5CYII= |
| | | wAAADsABataJCQAAA+xJREFUWEftV0loFUkYbvcNFzJi0lWdBEPQruqXKEYdcRgz4AYqeplBwYiXEUVB |
| | | UHAhCEG8iR509OBlmIsOjJ5EBvQSRVHzuvslxjAy8eCG+75GozF+f716L6873fqe2ykffDR59e9/1V8V |
| | | ow99KARtUg72J5aypGNN8xy2yJPWcleylb5gS13HnJdy+KSW6uJx3b8ZA7TKl6PbMPq3SbMsBUcpyf/2 |
| | | BP8PDh96kr32BX/rS/4O30789grfO1j/k4LQ6p8POO6XdFgpDNbDSZsn2Bt8u2MpWGdKsCPeBNMm3TZp |
| | | FaUc6/cW20pQEtpsflCllmwxjDbpLKOd9vAZuBPOx5J+86TyMdDbBxsdYLsn+SpUZYQy/imQILLdBIP3 |
| | | cxzEU7Dbns3WejXmcNK/NPGHkajabtUiLYO/nyOgXWdRFeUkDmdnWMOg2ACFFwEn8fzfFeaSxlpjIOlT |
| | | EHC0HVm/CstSC13B93sVFaOVszDQpwGuYGtQLipnQDlMyLzH12t2zJ8adH/TbeMbVLYROmmyDvjYRrLK |
| | | aS4Q3Y/gtWjFALtg6KSf4NW02Uj3HwSPzOuw9iAk24sI/p5rm3OV0wyOo+++ww7pzCIViVjvAk+02GyC |
| | | VlWnpUmw2Qggn+AV0eZ/A61oEtYsOttRwjlE5vy4L61KrabQmjBtV3I/JPtRUptcmy9UBuiM+tLc+bHs |
| | | aQ1Rn8rNnEC7Gpvr8KcqF0XoHVCbl0qB8p2OEspS8OZmySZrvwqNtbUDMRm3Yj9kj1uB9NXcwLkfjwyu |
| | | RAhoshuYcHMyGy4DT5T+jKrcjNbJh+yW75QIw62yqhDAvUghwV/Cybrw5UKTDn08GqmTJ9GCx660pscG |
| | | oPoq2MHzlUWjtN8skjZbRsGFdQpiJoBkVVkFnF3tLcCv+7ZZo31mcYZGLY5RL/kCiQrcaRLFTvrikOxc |
| | | YJF2PeZ5ZsTmAkNkCtaiW1YAkcTF1sT4YjXFEM3ekMADz+YztM8AULqlqE5nSL5wor3Zkew51nxU4WnP |
| | | Ij9DlVGLIWCtDhV6FzBWIJH9a3pNaZOGQRsNT6tjWSHB/6LK6OUA/ETJVER/O9dgwcQ7w7XLTG0yjSTO |
| | | Onp7Ny3A92VuuTD0rbcFbXsUMJonaQwnBV8Rniu4y2sGYbEe5emA8cORV6ZGY3n5UNycC9AKvBHZZRh+ |
| | | iqxoX9BlRWMZozvLLiSEV5V6HT2Bjz9iX0ftaAWE9sDoBV+UlOufY9FeWTmE5OhdgLH8Kxyvhv5GON3q |
| | | C3NzSvD19C70MTco4JTDZsbtrSzUlLP5DnBV3D745riOp5nr8F/OJcYV65++P2iTfNV/MPoQCcP4AKXR |
| | | FGYxo/VGAAAAAElFTkSuQmCC |
| | | </value> |
| | | </data> |
| | | </root> |
| | |
| | | tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); |
| | | tableLayoutPanel1.Size = new Size(368, 39); |
| | | tableLayoutPanel1.TabIndex = 4; |
| | | tableLayoutPanel1.Paint += tableLayoutPanel1_Paint; |
| | | // |
| | | // textBox1 |
| | | // |
| | |
| | | //LogInfo?.Invoke($"Xä½ç½®å·²æ´æ°ä¸º: {xPosition}", LogInfoType.INFO); |
| | | } |
| | | } |
| | | |
| | | private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | Name = "AllProcessesPage"; |
| | | Text = "主çé¢"; |
| | | //this.Font = new Font("Microsoft YaHei UI", 16F, FontStyle.Regular, GraphicsUnit.Point, 0); |
| | | this.BackColor = Color.FromArgb(32, 41, 50); |
| | | |
| | | InitVisionUI(); |
| | |
| | | |
| | | public void InitVisionUI() |
| | | { |
| | | this.controlsPanel.Dock = DockStyle.Fill; |
| | | List<string> keys = dicProcessControls.Keys.ToList(); |
| | | |
| | | foreach (var title in keys) |
| | |
| | | foreach (var layout in GlobalVar.dicLayout.Values) |
| | | { |
| | | if (GlobalVar.dicProcesses.ContainsKey(layout.ProcessName)) |
| | | { |
| | | enableLayout++; |
| | | } |
| | | } |
| | | |
| | | int index = 0; |
| | |
| | | ProcessControl processControl = dicProcessControls[title]; |
| | | processControl.Size |
| | | = new Size(this.controlsPanel.Size.Width / enableLayout |
| | | , this.controlsPanel.Size.Height-40); |
| | | , this.controlsPanel.Size.Height); |
| | | processControl.Location |
| | | = new Point(processControl.Size.Width * index, 0); |
| | | |
| | | if (GlobalVar.dicProcesses[name].GetImage(GlobalVar.dicLayout[i], out _, out HObject RecordImage)) |
| | | { |
| | | dicProcessControls[title].ShowHoImage(RecordImage); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | this.controlsPanel.Controls.Add(processControl); |
| | | |
| | | if (GlobalVar.dicProcesses[name].GetImage(GlobalVar.dicLayout[i], out _, out HObject RecordImage)) |
| | | { |
| | | dicProcessControls[title].ShowHoImage(RecordImage); |
| | | } |
| | | } |
| | | index++; |
| | | } |
| | |
| | | /// <param name="disposing">妿åºéæ¾æç®¡èµæºï¼ä¸º trueï¼å¦å为 falseã</param> |
| | | protected override void Dispose(bool disposing) |
| | | { |
| | | this.isClosed = true; |
| | | if (disposing && (components != null)) |
| | | { |
| | | components.Dispose(); |
| | |
| | | |
| | | if (ProcessRunBll != null) |
| | | this.label1.Text = $"æ»æ°ï¼{ProcessRunBll.total}"; |
| | | this.isClosed = false ; |
| | | var TaskPhotoContinue = Task.Factory.StartNew(() => |
| | | { |
| | | ThreadCircleRun(); |
| | | }); |
| | | } |
| | | |
| | | public void SetTitle(string title) |
| | |
| | | })); |
| | | } |
| | | else |
| | | { |
| | | UserHSmartWindowControl.ClearObj(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | })); |
| | | } |
| | | else |
| | | { |
| | | this.label1.Text = $"æ»æ°ï¼{ProcessRunBll.total}"; |
| | | } |
| | | } |
| | | |
| | | public bool Run(out string msg) |
| | |
| | | } |
| | | |
| | | if (isCircleRuning || ProcessRunBll.bRuning) |
| | | { |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}æ£å¨è¿è¡", LogInfoType.ERROR); |
| | | } |
| | | |
| | | ProcessRunBll.Run(); |
| | | |
| | |
| | | try |
| | | { |
| | | if (ProcessRunBll == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | ProcessRunBll.LogInfo(string.Format("æµç¨[{0}]å¼å§è¿è¡", this.ProcessRunBll.Name), LogInfoType.INFO); |
| | | |
| | |
| | | result = Run(out msg); |
| | | |
| | | if (ProcessRunBll.GetImage(_Layout, out _, out HObject RecordImage)) |
| | | { |
| | | ShowHoImage(RecordImage); |
| | | } |
| | | } |
| | | catch { msg = "è¿è¡åºç°äºå¼å¸¸"; } |
| | | |
| | |
| | | |
| | | if (isCircleRuning) |
| | | { |
| | | threadCircleRun = new Thread(ThreadCircleRun); |
| | | threadCircleRun.IsBackground = true; |
| | | threadCircleRun.Start(); |
| | | this.mAutoResetEvent.Set(); |
| | | } |
| | | else |
| | | { |
| | | isCircleRuning = false; |
| | | //threadCircleRun.Abort(); |
| | | } |
| | | if (!isCircleRuning) |
| | | { |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}å
³éè¿ç»è¿è¡", LogInfoType.PASS); |
| | | return; |
| | | } |
| | | |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}å¼å¯è¿ç»è¿è¡", LogInfoType.WARN); |
| | | } |
| | | catch { } |
| | | } |
| | | |
| | | Thread threadCircleRun = null; |
| | | private AutoResetEvent mAutoResetEvent = new AutoResetEvent(false); |
| | | bool isClosed = false; |
| | | |
| | | void ThreadCircleRun() |
| | | { |
| | | if (!isCircleRuning) |
| | | while (!isClosed) |
| | | { |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}å
³éè¿ç»è¿è¡", LogInfoType.PASS); |
| | | return; |
| | | } |
| | | |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}å¼å¯è¿ç»è¿è¡", LogInfoType.WARN); |
| | | |
| | | while (isCircleRuning) |
| | | { |
| | | //this.BeginInvoke(new Action(() => |
| | | //{ |
| | | try |
| | | { |
| | | if (isCircleRuning == false) |
| | | { |
| | | this.mAutoResetEvent.WaitOne(); |
| | | } |
| | | |
| | | ProcessRunBll.LogInfo($"{ProcessRunBll.Name}å¼å§è¿è¡", LogInfoType.WARN); |
| | | ClearObj(); |
| | | bool result = ProcessRunBll.Run(); |
| | |
| | | , result ? LogInfoType.PASS : LogInfoType.ERROR); |
| | | |
| | | if (ProcessRunBll.GetImage(_Layout, out _, out HObject RecordImage)) |
| | | { |
| | | ShowHoImage(RecordImage); |
| | | } |
| | | } |
| | | catch { } |
| | | //})); |
| | | |
| | | Thread.Sleep(33); |
| | | } |
| | | } |
| | |
| | |  |
| | | using ReaLTaiizor.Controls; |
| | | using Sunny.UI; |
| | | using System.Drawing.Printing; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace LB_SmartVision.Forms.Pages.UserManagementPage |
| | | { |
| | | partial class UserManagementEditPage |
| | | { |
| | | /// <summary> |
| | | /// Required designer variable. |
| | | /// <summary> |
| | | /// å¿
éç设计å¨åéã |
| | | /// </summary> |
| | | private System.ComponentModel.IContainer components = null; |
| | | |
| | | /// <summary> |
| | | /// Clean up any resources being used. |
| | | /// <summary> |
| | | /// æ¸
çæææ£å¨ä½¿ç¨çèµæºã |
| | | /// </summary> |
| | | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
| | | /// <param name="disposing">妿åºéæ¾æç®¡èµæºï¼ä¸º trueï¼å¦å为 falseã</param> |
| | | protected override void Dispose(bool disposing) |
| | | { |
| | | if (disposing && (components != null)) |
| | |
| | | base.Dispose(disposing); |
| | | } |
| | | |
| | | #region Windows Form Designer generated code |
| | | #region ç»ä»¶è®¾è®¡å¨çæç代ç |
| | | |
| | | /// <summary> |
| | | /// Required method for Designer support - do not modify |
| | | /// the contents of this method with the code editor. |
| | | /// <summary> |
| | | /// è®¾è®¡å¨æ¯ææéçæ¹æ³ - ä¸è¦ä¿®æ¹ |
| | | /// 使ç¨ä»£ç ç¼è¾å¨ä¿®æ¹æ¤æ¹æ³çå
容ã |
| | | /// </summary> |
| | | private void InitializeComponent() |
| | | { |
| | | btn_Add = new HopeButton(); |
| | | btn_Clear = new LostButton(); |
| | | uiFlowLayoutPanel1 = new FlowLayoutPanel(); |
| | | grpSetting = new ParrotGroupBox(); |
| | | tableLayoutPanel1 = new TableLayoutPanel(); |
| | | tableLayoutPanel2 = new TableLayoutPanel(); |
| | | tableLayoutPanel3 = new TableLayoutPanel(); |
| | | textBoxEmployeeID = new TextBox(); |
| | | labelEmployeeID = new Label(); |
| | | textBoxName = new TextBox(); |
| | | labelName = new Label(); |
| | | labelPermission = new Label(); |
| | | textBoxPassword = new TextBox(); |
| | | labelPassword = new Label(); |
| | | labelUsername = new Label(); |
| | | textBoxUsername = new TextBox(); |
| | | comboBoxPermission = new ComboBox(); |
| | | dataGridViewUM = new DataGridView(); |
| | | tableLayoutPanel4 = new TableLayoutPanel(); |
| | | btnEdit = new HopeButton(); |
| | | btnFind = new HopeButton(); |
| | | btnDel = new HopeButton(); |
| | | btnAdd = new ForeverButton(); |
| | | grpSetting.SuspendLayout(); |
| | | tableLayoutPanel1.SuspendLayout(); |
| | | tableLayoutPanel2.SuspendLayout(); |
| | | tableLayoutPanel3.SuspendLayout(); |
| | | ((System.ComponentModel.ISupportInitialize)dataGridViewUM).BeginInit(); |
| | | tableLayoutPanel4.SuspendLayout(); |
| | | SuspendLayout(); |
| | | // |
| | | // btn_Add |
| | | // grpSetting |
| | | // |
| | | btn_Add.BorderColor = Color.FromArgb(220, 223, 230); |
| | | btn_Add.ButtonType = ReaLTaiizor.Util.HopeButtonType.Primary; |
| | | btn_Add.Cursor = Cursors.Hand; |
| | | btn_Add.DangerColor = Color.FromArgb(245, 108, 108); |
| | | btn_Add.DefaultColor = Color.FromArgb(255, 255, 255); |
| | | btn_Add.Dock = DockStyle.Fill; |
| | | btn_Add.Font = new Font("å®ä½", 12F); |
| | | btn_Add.HoverTextColor = Color.FromArgb(48, 49, 51); |
| | | btn_Add.InfoColor = Color.FromArgb(144, 147, 153); |
| | | btn_Add.Location = new Point(503, 3); |
| | | btn_Add.MinimumSize = new Size(1, 1); |
| | | btn_Add.Name = "btn_Add"; |
| | | btn_Add.PrimaryColor = Color.FromArgb(64, 158, 255); |
| | | btn_Add.Size = new Size(95, 38); |
| | | btn_Add.SuccessColor = Color.FromArgb(103, 194, 58); |
| | | btn_Add.TabIndex = 11; |
| | | btn_Add.Text = "å¢å "; |
| | | btn_Add.TextColor = Color.White; |
| | | btn_Add.WarningColor = Color.FromArgb(230, 162, 60); |
| | | // |
| | | // btn_Clear |
| | | // |
| | | btn_Clear.BackColor = Color.FromArgb(45, 45, 48); |
| | | btn_Clear.Cursor = Cursors.Hand; |
| | | btn_Clear.Dock = DockStyle.Fill; |
| | | btn_Clear.Font = new Font("å®ä½", 12F); |
| | | btn_Clear.ForeColor = Color.White; |
| | | btn_Clear.HoverColor = Color.DodgerBlue; |
| | | btn_Clear.Image = null; |
| | | btn_Clear.Location = new Point(403, 3); |
| | | btn_Clear.MinimumSize = new Size(1, 1); |
| | | btn_Clear.Name = "btn_Clear"; |
| | | btn_Clear.Size = new Size(94, 38); |
| | | btn_Clear.TabIndex = 12; |
| | | btn_Clear.Text = "æ¸
é¤"; |
| | | // |
| | | // uiFlowLayoutPanel1 |
| | | // |
| | | uiFlowLayoutPanel1.BackColor = Color.FromArgb(32, 41, 50); |
| | | uiFlowLayoutPanel1.Dock = DockStyle.Fill; |
| | | uiFlowLayoutPanel1.Font = new Font("å®ä½", 12F); |
| | | uiFlowLayoutPanel1.ForeColor = SystemColors.Control; |
| | | uiFlowLayoutPanel1.Location = new Point(4, 5); |
| | | uiFlowLayoutPanel1.Margin = new Padding(4, 5, 4, 5); |
| | | uiFlowLayoutPanel1.MinimumSize = new Size(1, 1); |
| | | uiFlowLayoutPanel1.Name = "uiFlowLayoutPanel1"; |
| | | uiFlowLayoutPanel1.Padding = new Padding(2); |
| | | uiFlowLayoutPanel1.Size = new Size(599, 293); |
| | | uiFlowLayoutPanel1.TabIndex = 10; |
| | | uiFlowLayoutPanel1.Text = "`"; |
| | | grpSetting.BorderColor = Color.DodgerBlue; |
| | | grpSetting.BorderWidth = 1; |
| | | grpSetting.Controls.Add(tableLayoutPanel1); |
| | | grpSetting.Dock = DockStyle.Fill; |
| | | grpSetting.Font = new Font("å®ä½", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); |
| | | grpSetting.Location = new Point(0, 0); |
| | | grpSetting.Name = "grpSetting"; |
| | | grpSetting.ShowText = true; |
| | | grpSetting.Size = new Size(866, 580); |
| | | grpSetting.TabIndex = 6; |
| | | grpSetting.TabStop = false; |
| | | grpSetting.Text = "ç¨æ·ç®¡ç设置"; |
| | | grpSetting.TextColor = Color.DodgerBlue; |
| | | // |
| | | // tableLayoutPanel1 |
| | | // |
| | | tableLayoutPanel1.ColumnCount = 1; |
| | | tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); |
| | | tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F)); |
| | | tableLayoutPanel1.Controls.Add(uiFlowLayoutPanel1, 0, 0); |
| | | tableLayoutPanel1.Controls.Add(tableLayoutPanel2, 0, 1); |
| | | tableLayoutPanel1.Controls.Add(tableLayoutPanel2, 0, 0); |
| | | tableLayoutPanel1.Controls.Add(tableLayoutPanel4, 0, 1); |
| | | tableLayoutPanel1.Dock = DockStyle.Fill; |
| | | tableLayoutPanel1.Location = new Point(0, 0); |
| | | tableLayoutPanel1.Location = new Point(3, 22); |
| | | tableLayoutPanel1.Name = "tableLayoutPanel1"; |
| | | tableLayoutPanel1.RowCount = 2; |
| | | tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); |
| | | tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 50F)); |
| | | tableLayoutPanel1.Size = new Size(607, 353); |
| | | tableLayoutPanel1.TabIndex = 13; |
| | | tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 45F)); |
| | | tableLayoutPanel1.Size = new Size(860, 555); |
| | | tableLayoutPanel1.TabIndex = 1; |
| | | // |
| | | // tableLayoutPanel2 |
| | | // |
| | | tableLayoutPanel2.ColumnCount = 6; |
| | | tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.666666F)); |
| | | tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.666666F)); |
| | | tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.666666F)); |
| | | tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.666666F)); |
| | | tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.666666F)); |
| | | tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.666666F)); |
| | | tableLayoutPanel2.Controls.Add(btn_Add, 5, 0); |
| | | tableLayoutPanel2.Controls.Add(btn_Clear, 4, 0); |
| | | tableLayoutPanel2.ColumnCount = 2; |
| | | tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 340F)); |
| | | tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); |
| | | tableLayoutPanel2.Controls.Add(tableLayoutPanel3, 0, 0); |
| | | tableLayoutPanel2.Controls.Add(dataGridViewUM, 1, 0); |
| | | tableLayoutPanel2.Dock = DockStyle.Fill; |
| | | tableLayoutPanel2.Location = new Point(3, 306); |
| | | tableLayoutPanel2.Location = new Point(3, 3); |
| | | tableLayoutPanel2.Name = "tableLayoutPanel2"; |
| | | tableLayoutPanel2.RowCount = 1; |
| | | tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); |
| | | tableLayoutPanel2.Size = new Size(601, 44); |
| | | tableLayoutPanel2.TabIndex = 11; |
| | | tableLayoutPanel2.Size = new Size(854, 504); |
| | | tableLayoutPanel2.TabIndex = 0; |
| | | // |
| | | // tableLayoutPanel3 |
| | | // |
| | | tableLayoutPanel3.ColumnCount = 2; |
| | | tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 100F)); |
| | | tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); |
| | | tableLayoutPanel3.Controls.Add(textBoxEmployeeID, 1, 4); |
| | | tableLayoutPanel3.Controls.Add(labelEmployeeID, 0, 4); |
| | | tableLayoutPanel3.Controls.Add(textBoxName, 1, 3); |
| | | tableLayoutPanel3.Controls.Add(labelName, 0, 3); |
| | | tableLayoutPanel3.Controls.Add(labelPermission, 0, 2); |
| | | tableLayoutPanel3.Controls.Add(textBoxPassword, 1, 1); |
| | | tableLayoutPanel3.Controls.Add(labelPassword, 0, 1); |
| | | tableLayoutPanel3.Controls.Add(labelUsername, 0, 0); |
| | | tableLayoutPanel3.Controls.Add(textBoxUsername, 1, 0); |
| | | tableLayoutPanel3.Controls.Add(comboBoxPermission, 1, 2); |
| | | tableLayoutPanel3.Location = new Point(3, 3); |
| | | tableLayoutPanel3.Name = "tableLayoutPanel3"; |
| | | tableLayoutPanel3.RowCount = 5; |
| | | tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 20F)); |
| | | tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 20F)); |
| | | tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 20F)); |
| | | tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 20F)); |
| | | tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 20F)); |
| | | tableLayoutPanel3.Size = new Size(333, 225); |
| | | tableLayoutPanel3.TabIndex = 0; |
| | | // |
| | | // textBoxEmployeeID |
| | | // |
| | | textBoxEmployeeID.Location = new Point(107, 187); |
| | | textBoxEmployeeID.Margin = new Padding(7); |
| | | textBoxEmployeeID.Name = "textBoxEmployeeID"; |
| | | textBoxEmployeeID.Size = new Size(219, 26); |
| | | textBoxEmployeeID.TabIndex = 9; |
| | | // |
| | | // labelEmployeeID |
| | | // |
| | | labelEmployeeID.AutoSize = true; |
| | | labelEmployeeID.Dock = DockStyle.Fill; |
| | | labelEmployeeID.ForeColor = Color.White; |
| | | labelEmployeeID.Location = new Point(3, 180); |
| | | labelEmployeeID.Name = "labelEmployeeID"; |
| | | labelEmployeeID.Size = new Size(94, 45); |
| | | labelEmployeeID.TabIndex = 8; |
| | | labelEmployeeID.Text = "åå·¥ç¼å·"; |
| | | labelEmployeeID.TextAlign = ContentAlignment.MiddleLeft; |
| | | // |
| | | // textBoxName |
| | | // |
| | | textBoxName.Location = new Point(107, 142); |
| | | textBoxName.Margin = new Padding(7); |
| | | textBoxName.Name = "textBoxName"; |
| | | textBoxName.Size = new Size(219, 26); |
| | | textBoxName.TabIndex = 7; |
| | | // |
| | | // labelName |
| | | // |
| | | labelName.AutoSize = true; |
| | | labelName.Dock = DockStyle.Fill; |
| | | labelName.ForeColor = Color.White; |
| | | labelName.Location = new Point(3, 135); |
| | | labelName.Name = "labelName"; |
| | | labelName.Size = new Size(94, 45); |
| | | labelName.TabIndex = 6; |
| | | labelName.Text = "å§å"; |
| | | labelName.TextAlign = ContentAlignment.MiddleLeft; |
| | | // |
| | | // labelPermission |
| | | // |
| | | labelPermission.AutoSize = true; |
| | | labelPermission.Dock = DockStyle.Fill; |
| | | labelPermission.ForeColor = Color.White; |
| | | labelPermission.Location = new Point(3, 90); |
| | | labelPermission.Name = "labelPermission"; |
| | | labelPermission.Size = new Size(94, 45); |
| | | labelPermission.TabIndex = 4; |
| | | labelPermission.Text = "æé"; |
| | | labelPermission.TextAlign = ContentAlignment.MiddleLeft; |
| | | // |
| | | // textBoxPassword |
| | | // |
| | | textBoxPassword.Location = new Point(107, 52); |
| | | textBoxPassword.Margin = new Padding(7); |
| | | textBoxPassword.Name = "textBoxPassword"; |
| | | textBoxPassword.Size = new Size(219, 26); |
| | | textBoxPassword.TabIndex = 3; |
| | | // |
| | | // labelPassword |
| | | // |
| | | labelPassword.AutoSize = true; |
| | | labelPassword.Dock = DockStyle.Fill; |
| | | labelPassword.ForeColor = Color.White; |
| | | labelPassword.Location = new Point(3, 45); |
| | | labelPassword.Name = "labelPassword"; |
| | | labelPassword.Size = new Size(94, 45); |
| | | labelPassword.TabIndex = 2; |
| | | labelPassword.Text = "å¯ç "; |
| | | labelPassword.TextAlign = ContentAlignment.MiddleLeft; |
| | | // |
| | | // labelUsername |
| | | // |
| | | labelUsername.AutoSize = true; |
| | | labelUsername.Dock = DockStyle.Fill; |
| | | labelUsername.ForeColor = Color.White; |
| | | labelUsername.Location = new Point(3, 0); |
| | | labelUsername.Name = "labelUsername"; |
| | | labelUsername.Size = new Size(94, 45); |
| | | labelUsername.TabIndex = 0; |
| | | labelUsername.Text = "ç¨æ·å"; |
| | | labelUsername.TextAlign = ContentAlignment.MiddleLeft; |
| | | // |
| | | // textBoxUsername |
| | | // |
| | | textBoxUsername.Location = new Point(107, 7); |
| | | textBoxUsername.Margin = new Padding(7); |
| | | textBoxUsername.Name = "textBoxUsername"; |
| | | textBoxUsername.Size = new Size(219, 26); |
| | | textBoxUsername.TabIndex = 1; |
| | | // |
| | | // comboBoxPermission |
| | | // |
| | | comboBoxPermission.DropDownStyle = ComboBoxStyle.DropDownList; |
| | | comboBoxPermission.FormattingEnabled = true; |
| | | comboBoxPermission.Location = new Point(107, 97); |
| | | comboBoxPermission.Margin = new Padding(7); |
| | | comboBoxPermission.Name = "comboBoxPermission"; |
| | | comboBoxPermission.Size = new Size(219, 24); |
| | | comboBoxPermission.TabIndex = 5; |
| | | // |
| | | // dataGridViewUM |
| | | // |
| | | dataGridViewUM.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; |
| | | dataGridViewUM.Dock = DockStyle.Fill; |
| | | dataGridViewUM.Location = new Point(343, 3); |
| | | dataGridViewUM.Name = "dataGridViewUM"; |
| | | dataGridViewUM.RowHeadersWidth = 51; |
| | | dataGridViewUM.Size = new Size(508, 498); |
| | | dataGridViewUM.TabIndex = 1; |
| | | // |
| | | // tableLayoutPanel4 |
| | | // |
| | | tableLayoutPanel4.Anchor = AnchorStyles.Top | AnchorStyles.Right; |
| | | tableLayoutPanel4.ColumnCount = 4; |
| | | tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); |
| | | tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); |
| | | tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); |
| | | tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); |
| | | tableLayoutPanel4.Controls.Add(btnEdit, 1, 0); |
| | | tableLayoutPanel4.Controls.Add(btnFind, 0, 0); |
| | | tableLayoutPanel4.Controls.Add(btnDel, 3, 0); |
| | | tableLayoutPanel4.Controls.Add(btnAdd, 2, 0); |
| | | tableLayoutPanel4.Location = new Point(457, 513); |
| | | tableLayoutPanel4.Name = "tableLayoutPanel4"; |
| | | tableLayoutPanel4.RowCount = 1; |
| | | tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); |
| | | tableLayoutPanel4.Size = new Size(400, 39); |
| | | tableLayoutPanel4.TabIndex = 1; |
| | | // |
| | | // btnEdit |
| | | // |
| | | btnEdit.BorderColor = Color.FromArgb(220, 223, 230); |
| | | btnEdit.ButtonType = ReaLTaiizor.Util.HopeButtonType.Primary; |
| | | btnEdit.DangerColor = Color.FromArgb(245, 108, 108); |
| | | btnEdit.DefaultColor = Color.FromArgb(255, 255, 255); |
| | | btnEdit.Font = new Font("Segoe UI", 12F); |
| | | btnEdit.HoverTextColor = Color.FromArgb(48, 49, 51); |
| | | btnEdit.InfoColor = Color.FromArgb(144, 147, 153); |
| | | btnEdit.Location = new Point(103, 3); |
| | | btnEdit.Name = "btnEdit"; |
| | | btnEdit.PrimaryColor = Color.FromArgb(64, 158, 255); |
| | | btnEdit.Size = new Size(94, 33); |
| | | btnEdit.SuccessColor = Color.FromArgb(103, 194, 58); |
| | | btnEdit.TabIndex = 2; |
| | | btnEdit.Text = "ä¿®æ¹"; |
| | | btnEdit.TextColor = Color.White; |
| | | btnEdit.WarningColor = Color.FromArgb(230, 162, 60); |
| | | // |
| | | // btnFind |
| | | // |
| | | btnFind.BorderColor = Color.FromArgb(220, 223, 230); |
| | | btnFind.ButtonType = ReaLTaiizor.Util.HopeButtonType.Primary; |
| | | btnFind.DangerColor = Color.FromArgb(245, 108, 108); |
| | | btnFind.DefaultColor = Color.FromArgb(255, 255, 255); |
| | | btnFind.Font = new Font("Segoe UI", 12F); |
| | | btnFind.HoverTextColor = Color.FromArgb(48, 49, 51); |
| | | btnFind.InfoColor = Color.FromArgb(144, 147, 153); |
| | | btnFind.Location = new Point(3, 3); |
| | | btnFind.Name = "btnFind"; |
| | | btnFind.PrimaryColor = Color.FromArgb(64, 158, 255); |
| | | btnFind.Size = new Size(94, 33); |
| | | btnFind.SuccessColor = Color.FromArgb(103, 194, 58); |
| | | btnFind.TabIndex = 1; |
| | | btnFind.Text = "æ¥è¯¢"; |
| | | btnFind.TextColor = Color.White; |
| | | btnFind.WarningColor = Color.FromArgb(230, 162, 60); |
| | | // |
| | | // btnDel |
| | | // |
| | | btnDel.BorderColor = Color.FromArgb(220, 223, 230); |
| | | btnDel.ButtonType = ReaLTaiizor.Util.HopeButtonType.Primary; |
| | | btnDel.DangerColor = Color.FromArgb(245, 108, 108); |
| | | btnDel.DefaultColor = Color.FromArgb(255, 255, 255); |
| | | btnDel.Font = new Font("Segoe UI", 12F); |
| | | btnDel.HoverTextColor = Color.FromArgb(48, 49, 51); |
| | | btnDel.InfoColor = Color.FromArgb(144, 147, 153); |
| | | btnDel.Location = new Point(303, 3); |
| | | btnDel.Name = "btnDel"; |
| | | btnDel.PrimaryColor = Color.FromArgb(64, 158, 255); |
| | | btnDel.Size = new Size(94, 33); |
| | | btnDel.SuccessColor = Color.FromArgb(103, 194, 58); |
| | | btnDel.TabIndex = 3; |
| | | btnDel.Text = "å é¤"; |
| | | btnDel.TextColor = Color.White; |
| | | btnDel.WarningColor = Color.FromArgb(230, 162, 60); |
| | | btnDel.Click += btnDel_Click; |
| | | // |
| | | // btnAdd |
| | | // |
| | | btnAdd.BackColor = Color.Transparent; |
| | | btnAdd.BaseColor = Color.FromArgb(35, 168, 109); |
| | | btnAdd.Font = new Font("Segoe UI", 12F); |
| | | btnAdd.Location = new Point(203, 3); |
| | | btnAdd.Name = "btnAdd"; |
| | | btnAdd.Rounded = false; |
| | | btnAdd.Size = new Size(94, 33); |
| | | btnAdd.TabIndex = 4; |
| | | btnAdd.Text = "æ·»å "; |
| | | btnAdd.TextColor = Color.FromArgb(243, 243, 243); |
| | | btnAdd.Click += btnAdd_Click; |
| | | // |
| | | // UserManagementEditPage |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | BackColor = Color.FromArgb(32, 41, 50); |
| | | Controls.Add(tableLayoutPanel1); |
| | | ForeColor = SystemColors.Control; |
| | | Controls.Add(grpSetting); |
| | | Name = "UserManagementEditPage"; |
| | | Size = new Size(607, 353); |
| | | Paint += MESEditPage_Paint; |
| | | Size = new Size(866, 580); |
| | | grpSetting.ResumeLayout(false); |
| | | grpSetting.PerformLayout(); |
| | | tableLayoutPanel1.ResumeLayout(false); |
| | | tableLayoutPanel2.ResumeLayout(false); |
| | | tableLayoutPanel3.ResumeLayout(false); |
| | | tableLayoutPanel3.PerformLayout(); |
| | | ((System.ComponentModel.ISupportInitialize)dataGridViewUM).EndInit(); |
| | | tableLayoutPanel4.ResumeLayout(false); |
| | | ResumeLayout(false); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | private ReaLTaiizor.Controls.HopeButton btn_Add; |
| | | private ReaLTaiizor.Controls.LostButton btn_Clear; |
| | | private FlowLayoutPanel uiFlowLayoutPanel1; |
| | | private ParrotGroupBox grpSetting; |
| | | private TableLayoutPanel tableLayoutPanel1; |
| | | private TableLayoutPanel tableLayoutPanel2; |
| | | private TableLayoutPanel tableLayoutPanel3; |
| | | private Label labelUsername; |
| | | private TextBox textBoxUsername; |
| | | private TextBox textBoxEmployeeID; |
| | | private Label labelEmployeeID; |
| | | private TextBox textBoxName; |
| | | private Label labelName; |
| | | private Label labelPermission; |
| | | private TextBox textBoxPassword; |
| | | private Label labelPassword; |
| | | private ComboBox comboBoxPermission; |
| | | private DataGridView dataGridViewUM; |
| | | private TableLayoutPanel tableLayoutPanel4; |
| | | private HopeButton btnDel; |
| | | private HopeButton btnEdit; |
| | | private HopeButton btnFind; |
| | | private ForeverButton btnAdd; |
| | | } |
| | | |
| | | } |
| | |
| | | using LB_VisionControl; |
| | | using OpenCvSharp.Flann; |
| | | using System; |
| | | using LB_SmartVision.Forms.Pages.ProcessPage; |
| | | using LB_SmartVision.ProcessRun; |
| | | using LB_VisionControl; |
| | | using LB_VisionProcesses; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Serialization; |
| | | using System.Collections.Concurrent; |
| | | using System.Data; |
| | | using System.Text; |
| | | using VisionControl.Forms; |
| | | using LB_SmartVision.Forms.Pages.SettingPage; |
| | | using LB_SmartVisionCommon; |
| | | using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel; |
| | | using LB_SmartVision.Forms.Pages.CameraPage; |
| | | using System.Security.Principal; |
| | | using System.Windows.Forms; |
| | | using System.Xml.Linq; |
| | | |
| | | namespace LB_SmartVision.Forms.Pages.UserManagementPage |
| | | { |
| | | public partial class UserManagementEditPage : UserControl |
| | | { |
| | | public Action<string, LogInfoType> LogInfo; |
| | | |
| | | |
| | | RunSettingPage RunSettingPage = new RunSettingPage(); |
| | | LayoutPage LayoutPage = new LayoutPage(); |
| | | CsvPage CsvPage = new CsvPage(); |
| | | public UserManagementEditPage() |
| | | { |
| | | InitializeComponent(); |
| | | |
| | | Name = "UserManagementEditPage"; |
| | | Name = "UserManagementEditPage"; |
| | | Text = "ç¨æ·ç®¡ç设置"; |
| | | |
| | | InitializeComponent(); |
| | | InitializeDataGridView(); |
| | | InitializeComboBox(); |
| | | } |
| | | |
| | | private void MESEditPage_Paint(object sender, PaintEventArgs e) |
| | | private void InitializeDataGridView() |
| | | { |
| | | uiFlowLayoutPanel1.Controls.Clear(); |
| | | // 设置DataGridViewå宽 |
| | | dataGridViewUM.ColumnCount = 5; |
| | | |
| | | int totalWidth = dataGridViewUM.ClientSize.Width; |
| | | int columnCount = dataGridViewUM.ColumnCount; |
| | | int columnWidth = totalWidth / columnCount; |
| | | |
| | | // 设置æå°å®½åº¦ |
| | | int minWidth = 100; // æå°å®½åº¦ |
| | | if (columnWidth < minWidth) |
| | | { |
| | | columnWidth = minWidth; |
| | | } |
| | | |
| | | for (int i = 0; i < columnCount; i++) |
| | | { |
| | | dataGridViewUM.Columns[i].Width = columnWidth; |
| | | } |
| | | |
| | | // è®¾ç½®åæ é¢ |
| | | dataGridViewUM.Columns[0].Name = "ç¨æ·å"; |
| | | dataGridViewUM.Columns[1].Name = "å¯ç "; |
| | | dataGridViewUM.Columns[2].Name = "å§å"; |
| | | dataGridViewUM.Columns[3].Name = "å·¥å·"; |
| | | dataGridViewUM.Columns[4].Name = "æé"; |
| | | |
| | | dataGridViewUM.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; |
| | | |
| | | // ç¦æ¢ç¼è¾åå
æ ¼ï¼å¯éï¼ |
| | | dataGridViewUM.ReadOnly = true; |
| | | |
| | | // å
许å¤è¡éæ©ï¼å¯éï¼ |
| | | dataGridViewUM.MultiSelect = false; |
| | | |
| | | // æ¾ç¤ºè¡æ é¢ï¼å¯éï¼ |
| | | dataGridViewUM.RowHeadersVisible = true; |
| | | } |
| | | |
| | | private void InitializeComboBox() |
| | | { |
| | | // æ·»å æéé项 |
| | | comboBoxPermission.Items.Add("管çå"); |
| | | comboBoxPermission.Items.Add("æä½å"); |
| | | |
| | | // 设置é»è®¤éæ©é¡¹ |
| | | comboBoxPermission.SelectedIndex = 1; |
| | | } |
| | | |
| | | private void ClearInputFields() |
| | | { |
| | | textBoxUsername.Clear(); |
| | | textBoxPassword.Clear(); |
| | | textBoxName.Clear(); |
| | | textBoxEmployeeID.Clear(); |
| | | comboBoxPermission.SelectedIndex = 1; |
| | | textBoxUsername.Focus(); // å°ç¦ç¹è®¾ç½®åç¨æ·åè¾å
¥æ¡ |
| | | } |
| | | private void btnAdd_Click(object sender, EventArgs e) |
| | | { |
| | | // éªè¯è¾å
¥ |
| | | if (string.IsNullOrWhiteSpace(textBoxUsername.Text) || |
| | | string.IsNullOrWhiteSpace(textBoxPassword.Text) || |
| | | string.IsNullOrWhiteSpace(textBoxName.Text) || |
| | | string.IsNullOrWhiteSpace(textBoxEmployeeID.Text)) |
| | | { |
| | | MessageBox.Show("è¯·å¡«åææå¿
å¡«åæ®µï¼", "æç¤º", |
| | | MessageBoxButtons.OK, MessageBoxIcon.Warning); |
| | | return; |
| | | } |
| | | |
| | | // å建æ°è¡æ°æ® |
| | | string[] row = new string[] |
| | | { |
| | | textBoxUsername.Text, |
| | | textBoxPassword.Text, // å®é
åºç¨ä¸å¯ç åºè¯¥å å¯ |
| | | textBoxName.Text, |
| | | textBoxEmployeeID.Text, |
| | | comboBoxPermission.SelectedItem.ToString() |
| | | }; |
| | | |
| | | // 设置æ´ä¸ªDataGridViewçé»è®¤åä½åé¢è² |
| | | dataGridViewUM.DefaultCellStyle.Font = new Font("å®ä½", 12); |
| | | dataGridViewUM.DefaultCellStyle.ForeColor = Color.Black; // åä½é¢è² |
| | | dataGridViewUM.DefaultCellStyle.BackColor = Color.White; // èæ¯é¢è² |
| | | |
| | | // æ·»å æ°è¡å°DataGridView |
| | | dataGridViewUM.Rows.Add(row); |
| | | |
| | | // æ¸
空è¾å
¥æ¡ |
| | | ClearInputFields(); |
| | | } |
| | | |
| | | private void btnDel_Click(object sender, EventArgs e) |
| | | { |
| | | if (dataGridViewUM.SelectedRows.Count > 0) |
| | | { |
| | | // 确认å é¤ |
| | | DialogResult result = MessageBox.Show("ç¡®å®è¦å é¤éä¸çè¡åï¼", |
| | | "确认å é¤", MessageBoxButtons.YesNo, MessageBoxIcon.Question); |
| | | |
| | | if (result == DialogResult.Yes) |
| | | { |
| | | foreach (DataGridViewRow row in dataGridViewUM.SelectedRows) |
| | | { |
| | | dataGridViewUM.Rows.Remove(row); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | MessageBox.Show("请å
éæ©è¦å é¤çè¡ï¼", "æç¤º", |
| | | MessageBoxButtons.OK, MessageBoxIcon.Information); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | using LB_VisionProcesses.Processes.ScriptTool; |
| | | using OpenCvSharp; |
| | | using System.Collections.Concurrent; |
| | | using System.Windows.Media.Media3D; |
| | | |
| | | namespace LB_SmartVision.ProcessRun |
| | | { |
| | |
| | | return res; |
| | | } |
| | | |
| | | public bool GetImage(Layout layout, out HImage InputImage, out HObject RecordImage) |
| | | public bool GetImage(Layout layout, out HObject InputImage, out HObject RecordImage) |
| | | { |
| | | InputImage = null; RecordImage = null; |
| | | try |
| | |
| | | IndexValueName = arrOutputs[2]; |
| | | |
| | | object o_InputImage = ((IProcess)dicContext[IndexProcessName]).OutputImage; |
| | | if (o_InputImage != null && o_InputImage is HImage ho_image && ho_image.IsInitialized()) |
| | | { |
| | | InputImage = ho_image.Clone(); |
| | | ho_image.Dispose(); |
| | | } |
| | | else if (o_InputImage != null && o_InputImage is Bitmap) |
| | | if (o_InputImage is HObject ho_image && ho_image.IsInitialized()) |
| | | InputImage = ho_image; |
| | | else if (o_InputImage is Bitmap) |
| | | { |
| | | //å°Mat转æ¢ä¸ºHObject |
| | | using (HImage ho_RecordImage = TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage)) |
| | | { |
| | | if (ho_RecordImage != null) |
| | | { |
| | | InputImage = ho_RecordImage.Clone(); |
| | | } |
| | | } |
| | | TAlgorithm.Bitmap2HObject((Bitmap)o_InputImage, out HObject ho_RecordImage); |
| | | InputImage = ho_RecordImage; |
| | | } |
| | | else if (o_InputImage != null && o_InputImage is Mat) |
| | | else if (o_InputImage is Mat) |
| | | { |
| | | //å°Mat转æ¢ä¸ºHObject |
| | | using (HImage ho_RecordImage = TAlgorithm.Mat2HObject((Mat)o_InputImage)) |
| | | { |
| | | if (ho_RecordImage != null) |
| | | { |
| | | InputImage = ho_RecordImage.Clone(); |
| | | } |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)o_InputImage, out HObject ho_RecordImage); |
| | | InputImage = ho_RecordImage; |
| | | } |
| | | |
| | | if (InputImage != null && InputImage.IsInitialized()) |
| | | { |
| | | InputImage.GetImageSize(out ho_ImageWidth, out ho_ImageHeight); |
| | | HOperatorSet.GetImageSize(InputImage, out ho_ImageWidth, out ho_ImageHeight); |
| | | |
| | | //å¾ç尺寸ååææ´æ°çªå£å°ºå¯¸[æé«é度] |
| | | if ((ho_ImageWidth.Length > 0 && ho_ImageWidth.TupleInt() != hWindowControl.Size.Width) |
| | |
| | | if (dicContext.TryGetValue(ProcessName, out IProcess obj) |
| | | && obj is IProcess process) |
| | | { |
| | | //process.InputImage = null; |
| | | |
| | | if (process.InputImage != null) |
| | | { |
| | | if (process.InputImage is HObject) |
| | | { |
| | | ((HObject)process.InputImage).Dispose(); |
| | | } |
| | | else if (process.InputImage is Mat) |
| | | { |
| | | ((Mat)process.InputImage).Dispose(); |
| | | } |
| | | else if (process.InputImage is Bitmap) |
| | | { |
| | | ((Bitmap)process.InputImage).Dispose(); |
| | | } |
| | | |
| | | process.InputImage = null; |
| | | } |
| | | |
| | | if (process.OutputImage != null) |
| | | { |
| | | if (process.OutputImage is HObject) |
| | | { |
| | | ((HObject)process.OutputImage).Dispose(); |
| | | } |
| | | else if (process.OutputImage is Mat) |
| | | { |
| | | ((Mat)process.OutputImage).Dispose(); |
| | | } |
| | | else if (process.OutputImage is Bitmap) |
| | | { |
| | | ((Bitmap)process.OutputImage).Dispose(); |
| | | } |
| | | |
| | | process.OutputImage = null; |
| | | } |
| | | |
| | | if (process.Record != null) |
| | | { |
| | | process.Record.Dispose(); |
| | | process.Record = null; |
| | | } |
| | | UpdateInputs(process); |
| | | |
| | |
| | | [Node("ç¸æºåå¾", "ååå·¥å
·", "Basic", "ç¸æºåå¾")] |
| | | public void ç¸æºåå¾(FlowNode node) { RunNodeAsync(node); } |
| | | |
| | | [Node("Halcon2Dæç¹å·¥å
·", "Halcon2Då·¥å
·", "Basic", "Halcon2Dæç¹å·¥å
·")] |
| | | [Node("Halcon2Dæç¹å·¥å
·", "Haclon2Då·¥å
·", "Basic", "Halcon2Dæç¹å·¥å
·")] |
| | | public void Halcon2Dæç¹å·¥å
·(FlowNode node) { RunNodeAsync(node); } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | |
| | |
| | | |
| | | public static string Node2ToolClassName(string NodeName) |
| | | { |
| | | |
| | | foreach (var item in IProcess.dicProcesses) |
| | | { |
| | | if (NodeName.StartsWith(item.Key)) |
| | |
| | | /// </summary> |
| | | public double RunTime = 0; |
| | | |
| | | public bool GetImage(Forms.Pages.SettingPage.Layout layout, out HImage InputImage, out HObject RecordImage) |
| | | public bool GetImage(Forms.Pages.SettingPage.Layout layout, out HObject InputImage, out HObject RecordImage) |
| | | { |
| | | return ProcessContext.GetImage(layout, out InputImage, out RecordImage); |
| | | } |
| | | |
| | | public bool GetImage(out HImage InputImage, out HObject RecordImage) |
| | | public bool GetImage(out HObject InputImage, out HObject RecordImage) |
| | | { |
| | | InputImage = null; |
| | | RecordImage = null; |
| | |
| | | using LB_SmartVisionLoginUI; |
| | | using System.Text; |
| | | |
| | | namespace LB_SmartVision |
| | | { |
| | | internal static class Program |
| | |
| | | [STAThread] |
| | | static void Main() |
| | | { |
| | | // To customize application configuration such as set high DPI settings or default font, |
| | | // see https://aka.ms/applicationconfiguration. |
| | | ApplicationConfiguration.Initialize(); |
| | | Application.Run(new VisionForm()); |
| | | try |
| | | { |
| | | string halconDir = Environment.GetEnvironmentVariable("HALCONROOT"); |
| | | if (string.IsNullOrEmpty(halconDir) || !Directory.Exists(halconDir)) |
| | | { |
| | | System.Windows.Forms.MessageBox.Show("ç¯å¢åé缺å°HALCONROOT,请确认æ¯å¦å®è£
æ£ç¡®!"); |
| | | } |
| | | else |
| | | { |
| | | bool ret; |
| | | System.Threading.Mutex mutex = new System.Threading.Mutex(true, System.Windows.Forms.Application.ProductName, out ret); |
| | | if (ret) |
| | | { |
| | | ////ç»å½éªè¯æé |
| | | MainWindow.InstanceLoginandConfirmation().ShowDialog(); |
| | | if (!MainWindow.InstanceLoginandConfirmation().isQuit && MainWindow.InstanceLoginandConfirmation().correctUser) |
| | | { |
| | | MainWindow.InstanceLoginandConfirmation().closeLoginFrm(); |
| | | } |
| | | else |
| | | { |
| | | MainWindow.InstanceLoginandConfirmation().closeLoginFrm(); |
| | | } |
| | | //// Main ä¸ºä½ ç¨åºç主çªä½ï¼å¦ææ¯æ§å¶å°ç¨åºä¸ç¨è¿å¥ |
| | | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); |
| | | System.Windows.Forms.Application.EnableVisualStyles(); |
| | | System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); |
| | | System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); |
| | | System.Windows.Forms.Application.ThreadException += (sender, e) => HandleException(e.Exception); |
| | | AppDomain.CurrentDomain.UnhandledException += (sender, e) => HandleException(e.ExceptionObject as Exception); |
| | | //// To customize application configuration such as set high DPI settings or default font, |
| | | //// see https://aka.ms/applicationconfiguration. |
| | | System.Windows.Forms.Application.Run(new VisionForm()); |
| | | mutex.ReleaseMutex(); |
| | | } |
| | | else |
| | | { |
| | | System.Windows.Forms.MessageBox.Show("æä¸ä¸ªåæ¬ç¨åºç¸åçåºç¨ç¨åºå·²ç»å¨è¿è¡ï¼è¯·ä¸è¦åæ¶è¿è¡å¤ä¸ªæ¬ç¨åºã\r\nè¿ä¸ªç¨åºå³å°éåºã", System.Windows.Forms.Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
| | | // æç¤ºä¿¡æ¯ï¼å¯ä»¥å é¤ã |
| | | System.Windows.Forms.Application.Exit();//éåºç¨åº |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | if (null != ex) |
| | | { |
| | | string strMsg = "InitControl failed. Error Code: " + ex.Message; |
| | | System.Windows.Forms.MessageBox.Show(strMsg); |
| | | } |
| | | else |
| | | { |
| | | return; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | static void HandleException(Exception ex) |
| | | { |
| | | // è®°å½å¼å¸¸ä¿¡æ¯ |
| | | string logPath = @"\Logs\app_crash.log"; |
| | | Directory.CreateDirectory(Path.GetDirectoryName(logPath)); |
| | | File.AppendAllText(logPath, $"{DateTime.Now}: {ex}\n"); |
| | | |
| | | // æ¾ç¤ºé误信æ¯ï¼å¯éï¼ |
| | | System.Windows.Forms.MessageBox.Show($"ç¨åºåçé误: {ex.Message}", "é误", MessageBoxButtons.OK, MessageBoxIcon.Error); |
| | | |
| | | // éåºç¨åº |
| | | Environment.Exit(1); |
| | | } |
| | | } |
| | | } |
| | |
| | | theme_VisionForm.Padding = new Padding(10, 70, 10, 9); |
| | | theme_VisionForm.RoundCorners = true; |
| | | theme_VisionForm.Sizable = true; |
| | | theme_VisionForm.Size = new Size(1440, 880); |
| | | theme_VisionForm.Size = new Size(1152, 704); |
| | | theme_VisionForm.SmartBounds = true; |
| | | theme_VisionForm.StartPosition = FormStartPosition.WindowsDefaultLocation; |
| | | theme_VisionForm.TabIndex = 0; |
| | |
| | | // sc_VisionForm.Panel2 |
| | | // |
| | | sc_VisionForm.Panel2.Controls.Add(grb_Info); |
| | | sc_VisionForm.Size = new Size(1420, 801); |
| | | sc_VisionForm.SplitterDistance = 618; |
| | | sc_VisionForm.Size = new Size(1132, 625); |
| | | sc_VisionForm.SplitterDistance = 478; |
| | | sc_VisionForm.TabIndex = 1; |
| | | // |
| | | // tlp_MainView |
| | |
| | | tlp_MainView.Controls.Add(materialTabSelector, 0, 0); |
| | | tlp_MainView.Dock = DockStyle.Fill; |
| | | tlp_MainView.Location = new Point(0, 0); |
| | | tlp_MainView.Margin = new Padding(2); |
| | | tlp_MainView.Name = "tlp_MainView"; |
| | | tlp_MainView.RowCount = 3; |
| | | tlp_MainView.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F)); |
| | | tlp_MainView.RowStyles.Add(new RowStyle(SizeType.Absolute, 39F)); |
| | | tlp_MainView.RowStyles.Add(new RowStyle(SizeType.Absolute, 48F)); |
| | | tlp_MainView.RowStyles.Add(new RowStyle(SizeType.Absolute, 31F)); |
| | | tlp_MainView.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); |
| | | tlp_MainView.Size = new Size(1420, 618); |
| | | tlp_MainView.Size = new Size(1132, 478); |
| | | tlp_MainView.TabIndex = 1; |
| | | tlp_MainView.TagString = null; |
| | | // |
| | | // materialTabControl |
| | | // |
| | | materialTabControl.AccessibleRole = AccessibleRole.Sound; |
| | | materialTabControl.Depth = 0; |
| | | materialTabControl.Dock = DockStyle.Fill; |
| | | materialTabControl.Location = new Point(3, 102); |
| | | materialTabControl.Location = new Point(2, 81); |
| | | materialTabControl.Margin = new Padding(2); |
| | | materialTabControl.MouseState = MaterialSkin.MouseState.HOVER; |
| | | materialTabControl.Name = "materialTabControl"; |
| | | materialTabControl.SelectedIndex = 0; |
| | | materialTabControl.Size = new Size(1414, 513); |
| | | materialTabControl.Size = new Size(1128, 395); |
| | | materialTabControl.TabIndex = 0; |
| | | // |
| | | // tlp_VisionMainOperator |
| | |
| | | tlp_VisionMainOperator.Controls.Add(btn_GlobalVar, 7, 0); |
| | | tlp_VisionMainOperator.Controls.Add(com_ProductName, 8, 0); |
| | | tlp_VisionMainOperator.Dock = DockStyle.Fill; |
| | | tlp_VisionMainOperator.Location = new Point(3, 63); |
| | | tlp_VisionMainOperator.Location = new Point(3, 51); |
| | | tlp_VisionMainOperator.Name = "tlp_VisionMainOperator"; |
| | | tlp_VisionMainOperator.RowCount = 1; |
| | | tlp_VisionMainOperator.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); |
| | | tlp_VisionMainOperator.Size = new Size(1414, 33); |
| | | tlp_VisionMainOperator.Size = new Size(1126, 25); |
| | | tlp_VisionMainOperator.TabIndex = 0; |
| | | tlp_VisionMainOperator.TagString = null; |
| | | // |
| | |
| | | ckb_AllowRun.Location = new Point(3, 3); |
| | | ckb_AllowRun.MinimumSize = new Size(1, 1); |
| | | ckb_AllowRun.Name = "ckb_AllowRun"; |
| | | ckb_AllowRun.Size = new Size(151, 27); |
| | | ckb_AllowRun.Size = new Size(119, 19); |
| | | ckb_AllowRun.TabIndex = 2; |
| | | ckb_AllowRun.Text = "è¿è¡æ¨¡å¼"; |
| | | // |
| | |
| | | btn_Login.Image = null; |
| | | btn_Login.ImageAlign = ContentAlignment.MiddleLeft; |
| | | btn_Login.InactiveColor = Color.FromArgb(32, 34, 37); |
| | | btn_Login.Location = new Point(160, 3); |
| | | btn_Login.Location = new Point(128, 3); |
| | | btn_Login.Name = "btn_Login"; |
| | | btn_Login.PressedBorderColor = Color.FromArgb(165, 37, 37); |
| | | btn_Login.PressedColor = Color.FromArgb(165, 37, 37); |
| | | btn_Login.Size = new Size(151, 27); |
| | | btn_Login.Size = new Size(119, 19); |
| | | btn_Login.TabIndex = 3; |
| | | btn_Login.Text = "ç¨æ·ç»å½"; |
| | | btn_Login.TextAlignment = StringAlignment.Center; |
| | |
| | | btn_GlobalVar.Image = null; |
| | | btn_GlobalVar.ImageAlign = ContentAlignment.MiddleLeft; |
| | | btn_GlobalVar.InactiveColor = Color.FromArgb(32, 34, 37); |
| | | btn_GlobalVar.Location = new Point(1102, 3); |
| | | btn_GlobalVar.Location = new Point(878, 3); |
| | | btn_GlobalVar.Name = "btn_GlobalVar"; |
| | | btn_GlobalVar.PressedBorderColor = Color.FromArgb(165, 37, 37); |
| | | btn_GlobalVar.PressedColor = Color.FromArgb(165, 37, 37); |
| | | btn_GlobalVar.Size = new Size(151, 27); |
| | | btn_GlobalVar.Size = new Size(119, 19); |
| | | btn_GlobalVar.TabIndex = 4; |
| | | btn_GlobalVar.Text = "å
¨å±åé"; |
| | | btn_GlobalVar.TextAlignment = StringAlignment.Center; |
| | |
| | | com_ProductName.EnabledCalc = true; |
| | | com_ProductName.FormattingEnabled = true; |
| | | com_ProductName.ItemHeight = 20; |
| | | com_ProductName.Location = new Point(1259, 3); |
| | | com_ProductName.Location = new Point(1003, 3); |
| | | com_ProductName.Name = "com_ProductName"; |
| | | com_ProductName.Size = new Size(152, 26); |
| | | com_ProductName.Size = new Size(120, 26); |
| | | com_ProductName.TabIndex = 5; |
| | | com_ProductName.SelectedValueChanged += com_ProductName_SelectedValueChanged; |
| | | // |
| | |
| | | materialTabSelector.Location = new Point(3, 3); |
| | | materialTabSelector.MouseState = MaterialSkin.MouseState.HOVER; |
| | | materialTabSelector.Name = "materialTabSelector"; |
| | | materialTabSelector.Size = new Size(1414, 54); |
| | | materialTabSelector.Size = new Size(1126, 42); |
| | | materialTabSelector.TabIndex = 1; |
| | | // |
| | | // grb_Info |
| | |
| | | grb_Info.MinimumSize = new Size(1, 1); |
| | | grb_Info.Name = "grb_Info"; |
| | | grb_Info.Padding = new Padding(0, 32, 0, 0); |
| | | grb_Info.Size = new Size(1420, 179); |
| | | grb_Info.Size = new Size(1132, 143); |
| | | grb_Info.TabIndex = 1; |
| | | grb_Info.Text = "æ¥å¿æ¾ç¤ºåºï¼"; |
| | | grb_Info.TextAlignment = ContentAlignment.MiddleLeft; |
| | |
| | | rich_Info.Name = "rich_Info"; |
| | | rich_Info.Padding = new Padding(2); |
| | | rich_Info.ShowText = false; |
| | | rich_Info.Size = new Size(1420, 147); |
| | | rich_Info.Size = new Size(1132, 111); |
| | | rich_Info.TabIndex = 0; |
| | | rich_Info.TextAlignment = ContentAlignment.MiddleLeft; |
| | | // |
| | |
| | | cb_VisionForm.EnableMaximizeButton = true; |
| | | cb_VisionForm.EnableMinimizeButton = true; |
| | | cb_VisionForm.ForeColor = Color.FromArgb(155, 155, 155); |
| | | cb_VisionForm.Location = new Point(1360, 14); |
| | | cb_VisionForm.Location = new Point(1052, 18); |
| | | cb_VisionForm.MaximizeHoverColor = Color.FromArgb(74, 74, 74); |
| | | cb_VisionForm.MinimizeHoverColor = Color.FromArgb(63, 63, 65); |
| | | cb_VisionForm.Name = "cb_VisionForm"; |
| | |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | ClientSize = new Size(1440, 880); |
| | | ClientSize = new Size(1152, 704); |
| | | Controls.Add(theme_VisionForm); |
| | | FormBorderStyle = FormBorderStyle.None; |
| | | Icon = (Icon)resources.GetObject("$this.Icon"); |
| | |
| | | catch { } |
| | | } |
| | | // çæå¾çå¹¶æ¾ç¤ºå°æ§ä»¶ä¸ |
| | | HImage InputImage = null; |
| | | HObject InputImage = null; |
| | | HObject RecordImage = null; |
| | | |
| | | foreach (var layout in GlobalVar.dicLayout.Values |
| | |
| | | /// <summary> |
| | | /// App.xaml ç交äºé»è¾ |
| | | /// </summary> |
| | | public partial class App : Application |
| | | public partial class App : System.Windows.Application |
| | | { |
| | | } |
| | | } |
| | |
| | | <Nullable>enable</Nullable> |
| | | <ImplicitUsings>enable</ImplicitUsings> |
| | | <UseWPF>true</UseWPF> |
| | | <UseWindowsForms>True</UseWindowsForms> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <None Remove="favicon.ico" /> |
| | | <None Remove="images\01.JPG" /> |
| | | <None Remove="images\02.png" /> |
| | | <None Remove="images\03.png" /> |
| | | <None Remove="images\04.png" /> |
| | | <None Remove="images\05.png" /> |
| | | <None Remove="images\06.png" /> |
| | | <None Remove="images\07.png" /> |
| | | <None Remove="images\favicon.ico" /> |
| | | <None Remove="images\lanbao.jpg" /> |
| | | <None Remove="images\logo.ico" /> |
| | | <None Remove="images\logo_h.png" /> |
| | | <None Remove="images\é®ç.ico" /> |
| | | <None Remove="lanbao.jpg" /> |
| | | <None Remove="logo.ico" /> |
| | | <None Remove="logo_h.png" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Resource Include="favicon.ico"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\01.JPG"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\02.png"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\03.png"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\04.png"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\05.png"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\06.png"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\07.png"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\favicon.ico"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\lanbao.jpg"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\logo.ico"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\logo_h.png"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="images\é®ç.ico"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\LB_SmartVisionCommon\LB_SmartVisionCommon.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Resource Include="lanbao.jpg"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="logo.ico"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="logo_h.png"> |
| | | <CopyToOutputDirectory></CopyToOutputDirectory> |
| | | </Resource> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
| | |
| | | |
| | | <Grid x:Name="test" Width="800" Height="460" Opacity="1.0"> |
| | | <Grid.Background> |
| | | <ImageBrush ImageSource="./images/lanbao.jpg" |
| | | Stretch="UniformToFill"/> |
| | | <ImageBrush ImageSource="lanbao.jpg"/> |
| | | </Grid.Background> |
| | | <!--<Grid.Background> |
| | | <ImageBrush ImageSource="/lanbao.jpg" |
| | | Stretch="UniformToFill"/> |
| | | </Grid.Background>--> |
| | | <!--æ é¢--> |
| | | <Border BorderBrush="LightBlue" BorderThickness="3" Height="60" VerticalAlignment="Top" CornerRadius="30" Margin="116,2,102,0" Background="#72F5DEB3"> |
| | | <Label x:Name="Lbl_Title" BorderBrush="Red" Background="Transparent" Content="è½®èå¤è§è§è§æ£æµç³»ç»" HorizontalAlignment="Center" Foreground="Black" FontFamily="楷ä½" FontSize="36" Margin="31,2,91,-2" Width="454"></Label> |
| | | </Border> |
| | | |
| | | <!--å
³éç³»ç»--> |
| | | <Image Source="./images/05.png" Height="30" MouseDown="test_Close" Margin="644,15,116,415" ToolTip="å
³éç³»ç»" /> |
| | | <Image Source="/05.png" Height="30" MouseDown="test_Close" Margin="644,15,116,415" ToolTip="å
³éç³»ç»" /> |
| | | <!--æå°åç³»ç»--> |
| | | <Image Source="./images/06.png" Height="30" Margin="603,15,157,415" MouseDown="test_Min" ToolTip="æå°å"/> |
| | | <Image Source="/06.png" Height="30" Margin="603,15,157,415" MouseDown="test_Min" ToolTip="æå°å"/> |
| | | |
| | | <Border BorderBrush="LightBlue" Width="700" Height="325" Background="Transparent" BorderThickness="3" CornerRadius="80" Padding="13" > |
| | | |
| | | <Border Width="655" BorderThickness="3" CornerRadius="80" BorderBrush="LightBlue" Padding="23" > |
| | | <!--<Border.Background> |
| | | <ImageBrush ImageSource="./images/lanbao.jpg" Stretch="UniformToFill"/> |
| | | </Border.Background>--> |
| | | <!--<Image Height="161" Width="162" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="-5,40,0,0" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Source="./images/logo.ico"/>--> |
| | | <!--<Image Source="/images/logo_h.png" Height="161" Width="162" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="-5,40,0,0" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Visibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Auto" StretchDirection="DownOnly">--> |
| | | <!--<Image.RenderTransform> |
| | | <TransformGroup> |
| | | <ScaleTransform/> |
| | | <SkewTransform AngleX="0.149"/> |
| | | <RotateTransform/> |
| | | <TranslateTransform X="-0.469"/> |
| | | </TransformGroup> |
| | | </Image.RenderTransform> |
| | | </Image>--> |
| | | |
| | | </Border> |
| | | </Border> |
| | |
| | | </TransformGroup> |
| | | </Border.RenderTransform> |
| | | <Button x:Name="Btn_KeyBoard" Margin="283,67,-16,67" Content="" FontFamily="楷ä½" FontSize="36" Foreground="Black" Click="Btn_KeyBoard_Click" Visibility="Hidden" > |
| | | <Button.Background> |
| | | <ImageBrush ImageSource="images/é®ç.ico"/> |
| | | </Button.Background> |
| | | <!--<Button.Background> |
| | | --><!--<ImageBrush ImageSource="images/é®ç.ico"/>--><!-- |
| | | </Button.Background>--> |
| | | </Button> |
| | | </Border> |
| | | <!--ç¨æ·å¯ç æ ç¾å ææ¬æ¡--> |
| | |
| | | using HalconDotNet; |
| | | using Sunny.UI.Win32; |
| | | using System.Diagnostics; |
| | | |
| | | namespace LB_VisionControl |
| | |
| | | context.CurrentBranchName = $"{currentNode.Text}-Branch{currentNode.BranchIndex}"; |
| | | bool result = Context.ExecuteNode(currentNode); |
| | | #if DEBUG |
| | | Debug.WriteLine($"æ§è¡èç¹[{currentNode.Text}],ç»æä¸º{result}"); |
| | | Debug.WriteLine(DateTime.Now.ToString("[yyyy:MM:dd:HH:mm:ss:fff] ") + $"æ§è¡èç¹[{currentNode.Text}],ç»æä¸º{result}"); |
| | | #endif |
| | | context.BranchResults.TryAdd(context.CurrentBranchName, currentNode.Result); |
| | | currentNode.Result = result; |
| | |
| | | /// <summary> |
| | | /// 读åé |
| | | /// </summary> |
| | | public readonly object lockObj = new object(); |
| | | public static readonly object lockObj = new object(); |
| | | |
| | | /// <summary> |
| | | /// è£åå¾ç为hoDomainImage(ä¿çååæ ç³»,å
¶ä½å¡«å
为空) |
| | |
| | | { |
| | | if (InputImage is Bitmap) |
| | | { |
| | | Bitmap2Mat((Bitmap)InputImage, out Mat src); |
| | | TAlgorithm.Bitmap2Mat((Bitmap)InputImage, out Mat src); |
| | | |
| | | if (Params.Fixture == null) |
| | | Params.Fixture = new Fixture(); |
| | |
| | | |
| | | // 4. å建ä¸åå¾å¤§å°ç¸åçMatï¼å¹¶åå§åæ æå¼ |
| | | image = new Mat(src.Size(), src.Type()); |
| | | ((Mat)image).SetTo(GetInvalidValueForMat(src)); // å
¨é¨åå§åä¸ºæ æå¼ |
| | | ((Mat)image).SetTo(TAlgorithm.GetInvalidValueForMat(src)); // å
¨é¨åå§åä¸ºæ æå¼ |
| | | |
| | | // 5. å建é®ç½©ï¼å¨resultä¸ç»å¶æè½¬ç©å½¢ï¼ç½è²å¡«å
ï¼ |
| | | using (Mat cropped = new Mat(src, boundingRect)) |
| | |
| | | |
| | | // 2. å建ä¸åå¾å¤§å°ç¸åçMatï¼å¹¶åå§åæ æå¼ |
| | | image = new Mat(src.Size(), src.Type()); |
| | | ((Mat)image).SetTo(GetInvalidValueForMat(src)); // å
¨é¨åå§åä¸ºæ æå¼ |
| | | ((Mat)image).SetTo(TAlgorithm.GetInvalidValueForMat(src)); // å
¨é¨åå§åä¸ºæ æå¼ |
| | | |
| | | // 3. å建åå½¢é®ç½© |
| | | using (Mat mask = Mat.Zeros(src.Rows, src.Cols, MatType.CV_8UC1)) |
| | |
| | | image = ((Bitmap)InputImage)?.Clone(); |
| | | return true; |
| | | } |
| | | Mat2Bitmap((Mat)image, out Bitmap bmp); |
| | | TAlgorithm.Mat2Bitmap((Mat)image, out Bitmap bmp); |
| | | image = bmp; |
| | | return true; |
| | | } |
| | | else if (InputImage is HObject ho_image) |
| | | { |
| | | if (!ho_image.IsInitialized()) |
| | | return false; |
| | | |
| | | if (Params.Fixture == null) |
| | | Params.Fixture = new Fixture(); |
| | | |
| | | HObject hoDomainImage = null; |
| | | |
| | | switch (Params.ROI?.GetType().Name) |
| | | { |
| | | case "HRectangle2": |
| | | HOperatorSet.GenRectangle2(out HObject hRectangle2, (HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column) |
| | | , (HTuple)(Params.ROI.Phi + Params.Fixture.Phi), (HTuple)((HRectangle2)Params.ROI).SemiLength1, (HTuple)((HRectangle2)Params.ROI).SemiLength2); |
| | | HOperatorSet.ReduceDomain(ho_image, hRectangle2, out hoDomainImage); |
| | | break; |
| | | case "HCircle": |
| | | HOperatorSet.GenCircle(out HObject hCircle, (HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column) |
| | | , (HTuple)((HCircle)Params.ROI).Radius); |
| | | HOperatorSet.ReduceDomain(ho_image, hCircle, out hoDomainImage); |
| | | break; |
| | | case "ROI": |
| | | default: |
| | | image = ho_image.CopyObj(1, -1); |
| | | return true; |
| | | } |
| | | |
| | | image = hoDomainImage; |
| | | return true; |
| | | } |
| | | else if (InputImage is Mat) |
| | |
| | | |
| | | // 4. å建ä¸åå¾å¤§å°ç¸åçMatï¼å¹¶åå§åæ æå¼ |
| | | image = new Mat(src.Size(), src.Type()); |
| | | ((Mat)image).SetTo(GetInvalidValueForMat(src)); // å
¨é¨åå§åä¸ºæ æå¼ |
| | | ((Mat)image).SetTo(TAlgorithm.GetInvalidValueForMat(src)); // å
¨é¨åå§åä¸ºæ æå¼ |
| | | |
| | | // 5. å建é®ç½©ï¼å¨resultä¸ç»å¶æè½¬ç©å½¢ï¼ç½è²å¡«å
ï¼ |
| | | using (Mat cropped = new Mat(src, boundingRect)) |
| | |
| | | |
| | | // 2. å建ä¸åå¾å¤§å°ç¸åçMatï¼å¹¶åå§åæ æå¼ |
| | | image = new Mat(src.Size(), src.Type()); |
| | | ((Mat)image).SetTo(GetInvalidValueForMat(src)); // å
¨é¨åå§åä¸ºæ æå¼ |
| | | ((Mat)image).SetTo(TAlgorithm.GetInvalidValueForMat(src)); // å
¨é¨åå§åä¸ºæ æå¼ |
| | | |
| | | // 3. å建åå½¢é®ç½© |
| | | using (Mat mask = Mat.Zeros(src.Rows, src.Cols, MatType.CV_8UC1)) |
| | |
| | | } |
| | | } |
| | | |
| | | public virtual bool ReduceDomainImage(object InputImage, ref HImage image) |
| | | { |
| | | image = null; |
| | | if (InputImage == null) |
| | | { |
| | | image = null; |
| | | Msg = "è¾å
¥å¾ç为空"; |
| | | Result = false; |
| | | return false; |
| | | } |
| | | |
| | | lock (InputImage) |
| | | { |
| | | try |
| | | { |
| | | if (InputImage is HImage ho_image) |
| | | { |
| | | if (!ho_image.IsInitialized()) |
| | | return false; |
| | | |
| | | if (Params.Fixture == null) |
| | | Params.Fixture = new Fixture(); |
| | | |
| | | HImage hoDomainImage = null; |
| | | |
| | | switch (Params.ROI?.GetType().Name) |
| | | { |
| | | case "HRectangle2": |
| | | using (HRegion hRectangle2 = new HRegion()) |
| | | { |
| | | hRectangle2.GenRectangle2((HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column) |
| | | , (HTuple)(Params.ROI.Phi + Params.Fixture.Phi), (HTuple)((HRectangle2)Params.ROI).SemiLength1, (HTuple)((HRectangle2)Params.ROI).SemiLength2); |
| | | hoDomainImage = ho_image.ReduceDomain(hRectangle2); |
| | | } |
| | | break; |
| | | case "HCircle": |
| | | using (HRegion hCircle = new HRegion()) |
| | | { |
| | | hCircle.GenCircle((HTuple)(Params.ROI.Row + Params.Fixture.Row), (HTuple)(Params.ROI.Column + Params.Fixture.Column) |
| | | , (HTuple)((HCircle)Params.ROI).Radius); |
| | | hoDomainImage = ho_image.ReduceDomain(hCircle); |
| | | } |
| | | break; |
| | | case "ROI": |
| | | default: |
| | | image = ho_image.CopyObj(1, -1); |
| | | return true; |
| | | } |
| | | |
| | | image = hoDomainImage; |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | image = null; |
| | | Msg = $"è¾å
¥æ ¼å¼ä¸æ£ç¡®{InputImage.GetType()}"; |
| | | Result = false; |
| | | return false; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | image = null; |
| | | Msg = $"è£åªåºå失败,åå æ¯:{ex.ToString()}"; |
| | | Result = false; |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public override void Dispose() |
| | | { |
| | | if (InputImage != null) |
| | | { |
| | | if (InputImage is HObject) |
| | | { |
| | | ((HObject)InputImage).Dispose(); |
| | | } |
| | | else if (InputImage is Mat) |
| | | { |
| | | ((Mat)InputImage).Dispose(); |
| | | } |
| | | else if (InputImage is Bitmap) |
| | | { |
| | | ((Bitmap)InputImage).Dispose(); |
| | | } |
| | | |
| | | InputImage = null; |
| | | } |
| | | |
| | | if (OutputImage != null) |
| | | { |
| | | if (OutputImage is HObject) |
| | | { |
| | | ((HObject)OutputImage).Dispose(); |
| | | } |
| | | else if (OutputImage is Mat) |
| | | { |
| | | ((Mat)OutputImage).Dispose(); |
| | | } |
| | | else if (OutputImage is Bitmap) |
| | | { |
| | | ((Bitmap)OutputImage).Dispose(); |
| | | } |
| | | |
| | | OutputImage = null; |
| | | } |
| | | |
| | | if (Record != null) |
| | | { |
| | | Record.Dispose(); |
| | |
| | | if (InputImage != null) |
| | | { |
| | | if (InputImage is HObject ho_image && ho_image.IsInitialized()) |
| | | { |
| | | obj.InputImage = ho_image.CopyObj(1, -1); |
| | | } |
| | | else if (InputImage is Mat mat && !mat.Empty()) |
| | | { |
| | | obj.InputImage = mat.Clone(); |
| | | } |
| | | else if (InputImage is Bitmap bitmap) |
| | | { |
| | | obj.InputImage = bitmap.Clone(); |
| | | } |
| | | } |
| | | |
| | | return obj; |
| | | } |
| | | catch { return (TAlgorithm)MemberwiseClone(); } |
| | |
| | | { |
| | | Result = true; |
| | | bCompleted = false; |
| | | Msg = string.Empty; |
| | | //if (InputImage != null) |
| | | //{ |
| | | // if (InputImage is HObject) |
| | | // { |
| | | // ((HObject)InputImage).Dispose(); |
| | | // } |
| | | // else if (InputImage is Mat) |
| | | // { |
| | | // ((Mat)InputImage).Dispose(); |
| | | // } |
| | | // else if (InputImage is Bitmap) |
| | | // { |
| | | // ((Bitmap)InputImage).Dispose(); |
| | | // } |
| | | // InputImage = null; |
| | | //} |
| | | if (Record != null) |
| | | Msg = ""; |
| | | if (OutputImage != null) |
| | | { |
| | | Record.Dispose(); |
| | | if (OutputImage is HObject) |
| | | ((HObject)OutputImage).Dispose(); |
| | | else if (OutputImage is Mat) |
| | | ((Mat)OutputImage).Dispose(); |
| | | else if (OutputImage is Bitmap) |
| | | ((Bitmap)OutputImage).Dispose(); |
| | | OutputImage = null; |
| | | } |
| | | |
| | | if (Record != null) |
| | | Record.Dispose(); |
| | | } |
| | | |
| | | public override bool Run() |
| | | { |
| | | DateTime StartTime = DateTime.Now; |
| | | |
| | | InitRunParams(); |
| | | HOperatorSet.GenEmptyObj(out HObject EmptyObj); |
| | | OutputImage = EmptyObj; |
| | |
| | | |
| | | Thread.Sleep(30); |
| | | } |
| | | |
| | | Msg = "è¿è¡è¶
æ¶"; |
| | | Result = false; |
| | | RunTime = (DateTime.Now - StartTime).TotalMilliseconds; |
| | |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(fullPath)) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | if (!fullPath.Contains(".json")) |
| | | { |
| | | Debug.WriteLine("æä»¶è·¯å¾ä¸å®æ´"); |
| | |
| | | Debug.WriteLine("æä»¶è·¯å¾ä¸å®æ´"); |
| | | return false; |
| | | } |
| | | |
| | | // è·åä¸å¸¦æä»¶åçç®å½è·¯å¾ |
| | | string directoryPath = Path.GetDirectoryName(fullPath); |
| | | strProcessName = Path.GetFileNameWithoutExtension(fullPath); |
| | |
| | | Save(directoryPath); |
| | | return true; |
| | | } |
| | | |
| | | string strJson = string.Empty; |
| | | using (StreamReader streamReader = new StreamReader(fullPath, Encoding.UTF8)) |
| | | { |
| | |
| | | } |
| | | Params = JsonConvert.DeserializeObject<ProcessParams>(strJson); |
| | | if (Params == null) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | Params.FixDeserializedData(); |
| | | return true; |
| | | } |
| | |
| | | return value; |
| | | } |
| | | |
| | | public static HImage Bitmap2HObject(Bitmap bmp) |
| | | public static void Bitmap2HObject(Bitmap bmp, out HObject image) |
| | | { |
| | | BitmapData srcBmpData; |
| | | HImage image = null; |
| | | |
| | | try |
| | | { |
| | | if (bmp.Tag != null && bmp == null || bmp.Width == 0 || bmp.Height == 0) |
| | | if (bmp == null || bmp.Width == 0 || bmp.Height == 0) |
| | | { |
| | | image = null; |
| | | return image; |
| | | return; |
| | | } |
| | | |
| | | lock (bmp) |
| | | { |
| | | image = new HImage(); |
| | | switch (bmp.PixelFormat) |
| | | { |
| | | case PixelFormat.Format24bppRgb: |
| | |
| | | int width = bmp.Width; |
| | | int height = bmp.Height; |
| | | int stride = srcBmpData.Stride; |
| | | |
| | | if (stride == width * 3) |
| | | { |
| | | image.GenImageInterleaved(srcBmpData.Scan0, "bgr", bmp.Width, bmp.Height, 0, "byte", 0, 0, 0, 0, -1, 0); |
| | | } |
| | | HOperatorSet.GenImageInterleaved(out image, srcBmpData.Scan0, "bgr", bmp.Width, bmp.Height, 0, "byte", 0, 0, 0, 0, -1, 0); |
| | | else |
| | | { |
| | | image = HandleStrideAlignmentBest(srcBmpData.Scan0, width, height, stride); |
| | | } |
| | | |
| | | bmp.UnlockBits(srcBmpData); |
| | | break; |
| | | default: |
| | | srcBmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed); |
| | | image.GenImage1("byte", bmp.Width, bmp.Height, srcBmpData.Scan0); |
| | | HOperatorSet.GenImage1(out image, "byte", bmp.Width, bmp.Height, srcBmpData.Scan0); |
| | | bmp.UnlockBits(srcBmpData); |
| | | break; |
| | | } |
| | | } |
| | | return image; |
| | | return; |
| | | } |
| | | catch |
| | | { |
| | | if (image != null) |
| | | { |
| | | image.Dispose(); |
| | | } |
| | | image = null; |
| | | return image; |
| | | return; |
| | | } |
| | | } |
| | | |
| | | private static HImage HandleStrideAlignmentBest(IntPtr scan0, int width, int height, int stride) |
| | | private static HObject HandleStrideAlignmentBest(IntPtr scan0, int width, int height, int stride) |
| | | { |
| | | int expectedStride = width * 3; |
| | | byte[] alignedData = new byte[width * height * 3]; |
| | | HImage image = new HImage(); |
| | | |
| | | unsafe |
| | | { |
| | | byte* srcPtr = (byte*)scan0; |
| | |
| | | expectedStride |
| | | ); |
| | | } |
| | | image.GenImageInterleaved(new IntPtr(dstPtr), "bgr", width, height, 0, "byte", width, height, 0, 0, -1, 0); |
| | | return image; |
| | | HOperatorSet.GenImageInterleaved(out HObject ho_img, new IntPtr(dstPtr), "bgr", width, height, 0, "byte", width, height, 0, 0, -1, 0); |
| | | return ho_img; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static unsafe void HObject2Bitmap(HImage hImage, out Bitmap bmp) |
| | | public static unsafe void HObject2Bitmap(HObject hObject, out Bitmap bmp) |
| | | { |
| | | try |
| | | { |
| | | if (hImage == null || !hImage.IsInitialized()) |
| | | if (hObject == null || !hObject.IsInitialized()) |
| | | { |
| | | bmp = null; |
| | | return; |
| | | } |
| | | |
| | | // è·åå¾åä¿¡æ¯ |
| | | hImage.GetImageSize(out HTuple width, out HTuple height); |
| | | HTuple channels = hImage.CountChannels(); |
| | | HOperatorSet.GetImageSize(hObject, out HTuple width, out HTuple height); |
| | | HOperatorSet.CountChannels(hObject, out HTuple channels); |
| | | |
| | | if (channels.I == 1) |
| | | { |
| | | // ç°åº¦å¾å¤ç |
| | | HTuple ptr, type; |
| | | ptr = hImage.GetImagePointer1(out type, out width, out height); |
| | | HOperatorSet.GetImagePointer1(hObject, out ptr, out type, out width, out height); |
| | | |
| | | bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed); |
| | | |
| | |
| | | { |
| | | // 彩è²å¾å¤çï¼BGR顺åºï¼ |
| | | HTuple ptrR, ptrG, ptrB, type; |
| | | hImage.GetImagePointer3(out ptrR, out ptrG, out ptrB, out type, out width, out height); |
| | | HOperatorSet.GetImagePointer3(hObject, out ptrR, out ptrG, out ptrB, out type, out width, out height); |
| | | |
| | | bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb); |
| | | BitmapData bmpData = bmp.LockBits( |
| | |
| | | } |
| | | } |
| | | |
| | | public static HImage Mat2HObject(Mat mat) |
| | | public static void Mat2HObject(Mat mat, out HObject image) |
| | | { |
| | | HImage image = null; |
| | | try |
| | | { |
| | | if (mat == null || mat.Empty()) |
| | | { |
| | | return image; |
| | | image = null; |
| | | return; |
| | | } |
| | | |
| | | if (mat.Type() == MatType.CV_8UC3) // 彩è²å¾å (BGR) |
| | | { |
| | | image = new HImage(); |
| | | image.GenImageInterleaved( |
| | | HOperatorSet.GenImageInterleaved( |
| | | out image, |
| | | mat.Data, |
| | | "bgr", |
| | | mat.Width, |
| | |
| | | } |
| | | else if (mat.Type() == MatType.CV_8UC1) // ç°åº¦å¾å |
| | | { |
| | | image = new HImage(); |
| | | image.GenImage1( |
| | | HOperatorSet.GenImage1( |
| | | out image, |
| | | "byte", |
| | | mat.Width, |
| | | mat.Height, |
| | |
| | | else |
| | | { |
| | | throw new ArgumentException($"Mat2HObject䏿¯æçå¾åæ ¼å¼ï¼{mat.Type()}"); |
| | | return; |
| | | } |
| | | return image; |
| | | return; |
| | | } |
| | | catch |
| | | { |
| | | image = null; |
| | | return image; |
| | | return; |
| | | } |
| | | } |
| | | |
| | |
| | | HOperatorSet.GenImageConst(out image, "real", hv_xMax + 1, hv_yMax + 1); |
| | | HOperatorSet.SetGrayval(image, hv_y, hv_x, hv_z); |
| | | |
| | | //hoperatorset.getimagesize(ho_image, out htuple hv_width, out htuple hv_height); |
| | | //hoperatorset.genrectangle1(out hobject ho_rectangle, 0, 0, hv_height - 1, hv_width - 1); |
| | | //hoperatorset.getregionpoints(ho_rectangle, out htuple hv_rows, out htuple hv_columns); |
| | | //hoperatorset.getgrayval(ho_image, hv_rows, hv_columns, out htuple hv_z); |
| | | //HOperatorSet.GetImageSize(ho_Image, out HTuple hv_Width, out HTuple hv_Height); |
| | | //HOperatorSet.GenRectangle1(out HObject ho_Rectangle, 0, 0, hv_Height - 1, hv_Width - 1); |
| | | //HOperatorSet.GetRegionPoints(ho_Rectangle, out HTuple hv_Rows, out HTuple hv_Columns); |
| | | //HOperatorSet.GetGrayval(ho_Image, hv_Rows, hv_Columns, out HTuple hv_Z); |
| | | } |
| | | catch { image = null; } |
| | | } |
| | |
| | | /// <param name="startPoint"></param> |
| | | /// <param name="endPoint"></param> |
| | | /// <returns></returns> |
| | | public double GetDistanceP2P(HPoint startPoint, HPoint endPoint) |
| | | public static double GetDistanceP2P(HPoint startPoint, HPoint endPoint) |
| | | { |
| | | try |
| | | { |
| | |
| | | catch { return 9994; } |
| | | } |
| | | |
| | | public double GetDistanceP2P(Point startPoint, Point endPoint) |
| | | public static double GetDistanceP2P(Point startPoint, Point endPoint) |
| | | { |
| | | return GetDistanceP2P(new HPoint(startPoint), new HPoint(endPoint)); |
| | | } |
| | | |
| | | public double DistanceP2P(double startX, double startY, double endX, double endY) |
| | | public static double DistanceP2P(double startX, double startY, double endX, double endY) |
| | | { |
| | | return GetDistanceP2P(new HPoint(startX, startY), new HPoint(endX, endY)); |
| | | } |
| | |
| | | /// <param name="startPoint"></param> |
| | | /// <param name="endPoint"></param> |
| | | /// <returns></returns> |
| | | public HPoint GetMidPoint(HPoint startPoint, HPoint endPoint) |
| | | public static HPoint GetMidPoint(HPoint startPoint, HPoint endPoint) |
| | | { |
| | | return new HPoint((startPoint.X + endPoint.X) / 2, (startPoint.Y + endPoint.Y) / 2); |
| | | } |
| | | |
| | | public Point GetMidPoint(Point startPoint, Point endPoint) |
| | | public static Point GetMidPoint(Point startPoint, Point endPoint) |
| | | { |
| | | return new Point((startPoint.X + endPoint.X) / 2, (startPoint.Y + endPoint.Y) / 2); |
| | | } |
| | | |
| | | public System.Drawing.Point GetMidPoint(System.Drawing.Point startPoint, System.Drawing.Point endPoint) |
| | | public static System.Drawing.Point GetMidPoint(System.Drawing.Point startPoint, System.Drawing.Point endPoint) |
| | | { |
| | | return new System.Drawing.Point((startPoint.X + endPoint.X) / 2, (startPoint.Y + endPoint.Y) / 2); |
| | | } |
| | |
| | | /// <param name="point"></param> |
| | | /// <param name="segment"></param> |
| | | /// <returns></returns> |
| | | public bool IsPointOnSegment(HPoint pt, HSegment segment, double tolerance = 1e-3) |
| | | public static bool IsPointOnSegment(HPoint pt, HSegment segment, double tolerance = 1e-3) |
| | | { |
| | | // 计ç®ç´çº¿æ¹ç¨çç³»æ° |
| | | double A = segment.EndY - segment.StartX; |
| | |
| | | return false; |
| | | } |
| | | |
| | | public bool IsPointOnSegment(double px, double py, double x1, double y1, double x2, double y2) |
| | | public static bool IsPointOnSegment(double px, double py, double x1, double y1, double x2, double y2) |
| | | { |
| | | return IsPointOnSegment(new HPoint(px, py), new HSegment(x1, y1, x2, y2)); |
| | | } |
| | |
| | | catch { return false; } |
| | | } |
| | | |
| | | public bool IsPointNearRectangleSilde(HPoint pt, HRectangle2 rect, double tolerance = 100) |
| | | public static bool IsPointNearRectangleSilde(HPoint pt, HRectangle2 rect, double tolerance = 100) |
| | | { |
| | | return IsPointNearRectangleSilde(new System.Drawing.Point((int)pt.X, (int)pt.Y), new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), tolerance); |
| | | } |
| | |
| | | /// <param name="pt2"></param> |
| | | /// <param name="tolerance"></param> |
| | | /// <returns></returns> |
| | | public bool IsPointNearPoint(HPoint pt1, HPoint pt2, double tolerance = 100) |
| | | public static bool IsPointNearPoint(HPoint pt1, HPoint pt2, double tolerance = 100) |
| | | { |
| | | if (GetDistanceP2P(pt1, pt2) <= tolerance) |
| | | return true; |
| | | return false; |
| | | } |
| | | |
| | | public bool IsPointNearPoint(Point pt1, Point pt2, double tolerance = 100) |
| | | public static bool IsPointNearPoint(Point pt1, Point pt2, double tolerance = 100) |
| | | { |
| | | if (GetDistanceP2P(pt1, pt2) <= tolerance) |
| | | return true; |
| | | return false; |
| | | } |
| | | |
| | | public bool IsPointNearPoint(double x1, double y1, double x2, double y2, int tolerance = 100) |
| | | public static bool IsPointNearPoint(double x1, double y1, double x2, double y2, int tolerance = 100) |
| | | { |
| | | return IsPointNearPoint(new HPoint(x1, y1), new HPoint(x2, y2), tolerance); |
| | | } |
| | |
| | | /// <param name="corner"></param> |
| | | /// <param name="tolerance"></param> |
| | | /// <returns></returns> |
| | | public bool IsPointNearRectangleCorner(Point pt, Rectangle rect, out string corner, double tolerance = 10) |
| | | public static bool IsPointNearRectangleCorner(Point pt, Rectangle rect, out string corner, double tolerance = 10) |
| | | { |
| | | try |
| | | { |
| | |
| | | catch { corner = ""; return false; } |
| | | } |
| | | |
| | | public bool IsPointNearRectangleCorner(HPoint pt, HRectangle2 rect, out string corner, double tolerance = 10) |
| | | public static bool IsPointNearRectangleCorner(HPoint pt, HRectangle2 rect, out string corner, double tolerance = 10) |
| | | { |
| | | try |
| | | { |
| | |
| | | /// <param name="p3">线2èµ·å§ç¹</param> |
| | | /// <param name="p4"></param> |
| | | /// <returns></returns> |
| | | public Point2d? GetLineIntersection(Point2d p1, Point2d p2, Point2d p3, Point2d p4, bool bOnSegment = false) |
| | | public static Point2d? GetLineIntersection(Point2d p1, Point2d p2, Point2d p3, Point2d p4, bool bOnSegment = false) |
| | | { |
| | | // ç´çº¿1çåé |
| | | double x1 = p1.X, y1 = p1.Y; |
| | |
| | | #region Halcon |
| | | // Chapter: Graphics / Output |
| | | // Short Description: Display 3D object models |
| | | public void visualize_object_model_3d(HTuple hv_WindowHandle, HTuple hv_ObjectModel3D, |
| | | public static void visualize_object_model_3d(HTuple hv_WindowHandle, HTuple hv_ObjectModel3D, |
| | | HTuple hv_CamParam, HTuple hv_PoseIn, HTuple hv_GenParamName, HTuple hv_GenParamValue, |
| | | HTuple hv_Title, HTuple hv_Label, HTuple hv_Information, out HTuple hv_PoseOut) |
| | | { |
| | |
| | | |
| | | // Chapter: Calibration / Camera Parameters |
| | | // Short Description: Set the value of a specified camera parameter in the camera parameter tuple. |
| | | public void set_cam_par_data(HTuple hv_CameraParamIn, HTuple hv_ParamName, HTuple hv_ParamValue, |
| | | public static void set_cam_par_data(HTuple hv_CameraParamIn, HTuple hv_ParamName, HTuple hv_ParamValue, |
| | | out HTuple hv_CameraParamOut) |
| | | { |
| | | // Local iconic variables |
| | |
| | | } |
| | | } |
| | | |
| | | public void gen_arrow_contour_xld(out HObject ho_Arrow, HTuple hv_Row1, HTuple hv_Column1, |
| | | public static void gen_arrow_contour_xld(out HObject ho_Arrow, HTuple hv_Row1, HTuple hv_Column1, |
| | | HTuple hv_Row2, HTuple hv_Column2, HTuple hv_HeadLength, HTuple hv_HeadWidth) |
| | | { |
| | | // Stack for temporary objects |
| | |
| | | } |
| | | } |
| | | |
| | | public void get_rect2_vertex(HTuple hv_Row, HTuple hv_Column, HTuple hv_Phi, HTuple hv_Length1, |
| | | public static void get_rect2_vertex(HTuple hv_Row, HTuple hv_Column, HTuple hv_Phi, HTuple hv_Length1, |
| | | HTuple hv_Length2, out HTuple hv_TopLeft_Row, out HTuple hv_TopLeft_Col, out HTuple hv_TopRight_Row, |
| | | out HTuple hv_TopRight_Col, out HTuple hv_LowLeft_Row, out HTuple hv_LowLeft_Col, |
| | | out HTuple hv_LowRight_Row, out HTuple hv_LowRight_Col) |
| | |
| | | } |
| | | } |
| | | |
| | | public void pts_to_best_line(out HObject ho_LineXld, HTuple hv_Rows, HTuple hv_Columns, |
| | | public static void pts_to_best_line(out HObject ho_LineXld, HTuple hv_Rows, HTuple hv_Columns, |
| | | HTuple hv_IgnoreNum, out HTuple hv_Row1, out HTuple hv_Column1, out HTuple hv_Row2, |
| | | out HTuple hv_Column2) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | public (double, double) CalculateTailValues(HTuple minValue, HTuple maxValue, HTuple mean, HTuple deviation, double tailPercentage = 0.3) |
| | | public static (double, double) CalculateTailValues(HTuple minValue, HTuple maxValue, HTuple mean, HTuple deviation, double tailPercentage = 0.3) |
| | | { |
| | | // 计ç®ä½å°¾ç°åº¦å¼ |
| | | double lowTailValue = minValue.TupleReal() + (mean.TupleReal() - minValue.TupleReal()) * tailPercentage; |
| | |
| | | /// <param name="hv_Column2">ç»ææ¨ªåæ </param> |
| | | /// <param name="hv_ResultRow">ç»æç¹éåçºµåæ </param> |
| | | /// <param name="hv_ResultColumn">ç»æç¹é忍ªåæ </param> |
| | | public void Rake(HObject ho_Image, out HObject ho_Regions, HTuple hv_Elements, |
| | | public static void Rake(HObject ho_Image, out HObject ho_Regions, HTuple hv_Elements, |
| | | HTuple hv_DetectHeight, HTuple hv_DetectWidth, HTuple hv_Sigma, HTuple hv_Threshold, |
| | | HTuple hv_Transition, HTuple hv_Select, HTuple hv_Row1, HTuple hv_Column1, HTuple hv_Row2, |
| | | HTuple hv_Column2, out HTuple hv_ResultRow, out HTuple hv_ResultColumn) |
| | |
| | | catch { } |
| | | } |
| | | |
| | | public void scale_gray_map(HObject ho_Image, out HObject ho_Image1, HTuple hv_Min, HTuple hv_Max) |
| | | public static void scale_gray_map(HObject ho_Image, out HObject ho_Image1, HTuple hv_Min, HTuple hv_Max) |
| | | { |
| | | HTuple hv_Mult = new HTuple(), hv_Add = new HTuple(); |
| | | HOperatorSet.GenEmptyObj(out ho_Image1); |
| | |
| | | |
| | | #region OpenCVSharp |
| | | // æ ¹æ®Matç±»åè¿å对åºçæ æå¼ |
| | | public Scalar GetInvalidValueForMat(Mat mat) |
| | | public static Scalar GetInvalidValueForMat(Mat mat) |
| | | { |
| | | MatType type = mat.Type(); |
| | | if (type == MatType.CV_8UC1 || type == MatType.CV_8UC3) |
| | |
| | | return new Scalar(0); // 对äº8使 符å·ç±»åï¼0æ¯å®å
¨çæ æå¼ |
| | | } |
| | | |
| | | public void RGB2XYZ(double sR, double sG, double sB, out double X, out double Y, out double Z) |
| | | public static void RGB2XYZ(double sR, double sG, double sB, out double X, out double Y, out double Z) |
| | | { |
| | | // è¾å
¥çé¢è²å¼ (sR, sG, sB) åºä¸º 0 å° 255 ä¹é´çå¼ |
| | | |
| | |
| | | Z = Math.Round(var_Z / (var_X + var_Y + var_Z), 3); |
| | | } |
| | | |
| | | public void ExtractFrames(string videoPath, string outputDir) |
| | | public static void ExtractFrames(string videoPath, string outputDir) |
| | | { |
| | | // æ£æ¥è§é¢æä»¶æ¯å¦åå¨ |
| | | if (!File.Exists(videoPath)) |
| | |
| | | get |
| | | { |
| | | if (Subject == null) |
| | | { |
| | | return null; |
| | | } |
| | | return Subject.InputImage; |
| | | } |
| | | set |
| | | { |
| | | Subject.InputImage = value; |
| | | |
| | | if (InputImage == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (InputImage is HObject) |
| | | { |
| | | inputImageHSmartWindowControl.ShowHoImage((HObject)value); |
| | | } |
| | | else if (InputImage is Bitmap) |
| | | { |
| | | using (HImage image = TAlgorithm.Bitmap2HObject((Bitmap)value)) |
| | | { |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | TAlgorithm.Bitmap2HObject((Bitmap)value, out HObject image); |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | else if (InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)value)) |
| | | { |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)value, out HObject image); |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (Subject.OutputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)Subject.OutputImage)) |
| | | { |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)Subject.OutputImage, out HObject image); |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | else if (Subject.OutputImage is Bitmap) |
| | | { |
| | | using (HImage image = TAlgorithm.Bitmap2HObject((Bitmap)Subject.OutputImage)) |
| | | { |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | TAlgorithm.Bitmap2HObject((Bitmap)Subject.OutputImage, out HObject image); |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | else if (Subject.OutputImage is HObject) |
| | | { |
| | |
| | | BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb); |
| | | hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0); |
| | | ((Bitmap)InputImage).UnlockBits(srcBmpData); |
| | | ((Bitmap)InputImage).Dispose(); |
| | | InputImage = null; |
| | | InputImage = hImage.Clone(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Msg = "转å¾åºéï¼" + ex.Message; |
| | | Result = false; |
| | | return; |
| | | } |
| | | } |
| | | if (!(InputImage is HObject)) |
| | |
| | | } |
| | | |
| | | #region è£åªåºå |
| | | HImage DomainImage = null; |
| | | object DomainImage = null; |
| | | if (!ReduceDomainImage(InputImage, ref DomainImage)) |
| | | { |
| | | Msg = "è£åªåºå失败"; |
| | |
| | | // |
| | | // HBlobToolEdit |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | AutoScaleDimensions = new SizeF(7F, 17F); |
| | | AutoScaleMode = AutoScaleMode.Font; |
| | | Controls.Add(splitContainer1); |
| | | Controls.Add(BtmStatusStrip); |
| | | Controls.Add(TopToolStrip); |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Drawing; |
| | | using System.Drawing.Imaging; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | Msg = "è¾å
¥å¾ç为空"; |
| | | Result = false; |
| | | return; |
| | | } |
| | | if (InputImage is Bitmap) |
| | | { |
| | | try |
| | | { |
| | | using (HImage hImage = new HImage()) |
| | | { |
| | | Rectangle rect = new Rectangle(0, 0, ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height); |
| | | BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb); |
| | | hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0); |
| | | ((Bitmap)InputImage).UnlockBits(srcBmpData); |
| | | ((Bitmap)InputImage).Dispose(); |
| | | InputImage = hImage.Clone(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Msg = "转å¾åºéï¼" + ex.Message; |
| | | Result = false; |
| | | return; |
| | | } |
| | | } |
| | | if (!(InputImage is HObject)) |
| | | { |
| | |
| | | // |
| | | // HFindCode2dToolEdit |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | AutoScaleDimensions = new SizeF(7F, 17F); |
| | | AutoScaleMode = AutoScaleMode.Font; |
| | | Controls.Add(MainTableLayoutPanel); |
| | | Controls.Add(BtmStatusStrip); |
| | | Controls.Add(TopToolStrip); |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | |
| | | mimetype: application/x-microsoft.net.object.soap.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
| | |
| | | <resheader name="writer"> |
| | | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | <metadata name="lblMsgToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
| | | <metadata name="TopToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
| | | <value>17, 17</value> |
| | | </metadata> |
| | | <metadata name="TopToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
| | | <value>156, 17</value> |
| | | </metadata> |
| | | <metadata name="BtmStatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
| | | <value>287, 17</value> |
| | | <value>148, 17</value> |
| | | </metadata> |
| | | </root> |
| | |
| | | using LB_VisionProcesses.Alogrithms.Halcon; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Drawing.Imaging; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | Result = false; |
| | | return; |
| | | } |
| | | if (InputImage is Bitmap) |
| | | { |
| | | try |
| | | { |
| | | using (HImage hImage = new HImage()) |
| | | { |
| | | Rectangle rect = new Rectangle(0, 0, ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height); |
| | | BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb); |
| | | hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0); |
| | | ((Bitmap)InputImage).UnlockBits(srcBmpData); |
| | | ((Bitmap)InputImage).Dispose(); |
| | | InputImage = hImage.Clone(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Msg = "转å¾åºéï¼" + ex.Message; |
| | | Result = false; |
| | | return; |
| | | } |
| | | } |
| | | if (!(InputImage is HObject)) |
| | | { |
| | | Msg = "è¾å
¥å¾çæ ¼å¼ä¸ä¸ºMat"; |
| | | Result = false; |
| | | return; |
| | | } |
| | | |
| | | #region è£åªåºå |
| | | if (!(Params.ROI is HSegment)) |
| | | { |
| | |
| | | label13 = new Label(); |
| | | cmbTransition = new ComboBox(); |
| | | cmbSelect = new ComboBox(); |
| | | btnShowROI = new Button(); |
| | | pnlInputImage = new Panel(); |
| | | TopToolStrip = new ToolStrip(); |
| | | btnRun = new ToolStripButton(); |
| | |
| | | tabPageInputImage = new TabPage(); |
| | | tabPageRecordImage = new TabPage(); |
| | | pnlRecordImage = new Panel(); |
| | | btnShowROI = new Button(); |
| | | tablePanelParas.SuspendLayout(); |
| | | TopToolStrip.SuspendLayout(); |
| | | BtmStatusStrip.SuspendLayout(); |
| | |
| | | cmbSelect.Name = "cmbSelect"; |
| | | cmbSelect.Size = new Size(103, 25); |
| | | cmbSelect.TabIndex = 14; |
| | | // |
| | | // btnShowROI |
| | | // |
| | | btnShowROI.Dock = DockStyle.Fill; |
| | | btnShowROI.Location = new Point(3, 207); |
| | | btnShowROI.Name = "btnShowROI"; |
| | | btnShowROI.Size = new Size(84, 45); |
| | | btnShowROI.TabIndex = 15; |
| | | btnShowROI.Text = "æ¾ç¤ºæ¾çº¿åºå"; |
| | | btnShowROI.UseVisualStyleBackColor = true; |
| | | btnShowROI.Click += btnShowROI_Click; |
| | | // |
| | | // pnlInputImage |
| | | // |
| | |
| | | pnlRecordImage.Size = new Size(607, 510); |
| | | pnlRecordImage.TabIndex = 45; |
| | | // |
| | | // btnShowROI |
| | | // |
| | | btnShowROI.Dock = DockStyle.Fill; |
| | | btnShowROI.Location = new Point(3, 207); |
| | | btnShowROI.Name = "btnShowROI"; |
| | | btnShowROI.Size = new Size(84, 45); |
| | | btnShowROI.TabIndex = 15; |
| | | btnShowROI.Text = "æ¾ç¤ºæ¾çº¿åºå"; |
| | | btnShowROI.UseVisualStyleBackColor = true; |
| | | btnShowROI.Click += btnShowROI_Click; |
| | | // |
| | | // HFindLineToolEdit |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | AutoScaleDimensions = new SizeF(7F, 17F); |
| | | AutoScaleMode = AutoScaleMode.Font; |
| | | Controls.Add(MainTableLayoutPanel); |
| | | Controls.Add(BtmStatusStrip); |
| | | Controls.Add(TopToolStrip); |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | |
| | | mimetype: application/x-microsoft.net.object.soap.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
| | |
| | | <resheader name="writer"> |
| | | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | <metadata name="lblMsgToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
| | | <metadata name="TopToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
| | | <value>17, 17</value> |
| | | </metadata> |
| | | <metadata name="TopToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
| | | <value>156, 17</value> |
| | | </metadata> |
| | | <metadata name="BtmStatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
| | | <value>287, 17</value> |
| | | <value>129, 17</value> |
| | | </metadata> |
| | | </root> |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics; |
| | | using System.Drawing.Imaging; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | Msg = "è¾å
¥å¾ç为空"; |
| | | Result = false; |
| | | return; |
| | | } |
| | | if (InputImage is Bitmap) |
| | | { |
| | | try |
| | | { |
| | | using (HImage hImage = new HImage()) |
| | | { |
| | | Rectangle rect = new Rectangle(0, 0, ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height); |
| | | BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb); |
| | | hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0); |
| | | ((Bitmap)InputImage).UnlockBits(srcBmpData); |
| | | ((Bitmap)InputImage).Dispose(); |
| | | InputImage = hImage.Clone(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Msg = "转å¾åºéï¼" + ex.Message; |
| | | Result = false; |
| | | return; |
| | | } |
| | | } |
| | | if (!(InputImage is HObject)) |
| | | { |
| | |
| | | // |
| | | // HFindModelToolEdit |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | AutoScaleDimensions = new SizeF(7F, 17F); |
| | | AutoScaleMode = AutoScaleMode.Font; |
| | | Controls.Add(MainTableLayoutPanel); |
| | | Controls.Add(BtmStatusStrip); |
| | | Controls.Add(TopToolStrip); |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | |
| | | mimetype: application/x-microsoft.net.object.soap.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics; |
| | | using System.Drawing.Imaging; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | Msg = "è¾å
¥å¾ç为空"; |
| | | Result = false; |
| | | return; |
| | | } |
| | | if (InputImage is Bitmap) |
| | | { |
| | | try |
| | | { |
| | | using (HImage hImage = new HImage()) |
| | | { |
| | | Rectangle rect = new Rectangle(0, 0, ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height); |
| | | BitmapData srcBmpData = ((Bitmap)InputImage).LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb); |
| | | hImage.GenImageInterleaved(srcBmpData.Scan0, "rgbx", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, "byte", ((Bitmap)InputImage).Width, ((Bitmap)InputImage).Height, 0, 0, -1, 0); |
| | | ((Bitmap)InputImage).UnlockBits(srcBmpData); |
| | | ((Bitmap)InputImage).Dispose(); |
| | | InputImage = hImage.Clone(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Msg = "转å¾åºéï¼"+ ex.Message; |
| | | Result = false; |
| | | return; |
| | | } |
| | | } |
| | | if (!(InputImage is HObject)) |
| | | { |
| | |
| | | tabPage1.Controls.Add(splitContainer1); |
| | | tabPage1.Location = new Point(4, 26); |
| | | tabPage1.Name = "tabPage1"; |
| | | tabPage1.Padding = new Padding(3); |
| | | tabPage1.Padding = new Padding(3, 3, 3, 3); |
| | | tabPage1.Size = new Size(403, 516); |
| | | tabPage1.TabIndex = 0; |
| | | tabPage1.Text = "è¾å
¥åæ°"; |
| | |
| | | tabPage2.Controls.Add(tableLayoutResults); |
| | | tabPage2.Location = new Point(4, 26); |
| | | tabPage2.Name = "tabPage2"; |
| | | tabPage2.Padding = new Padding(3); |
| | | tabPage2.Size = new Size(403, 516); |
| | | tabPage2.Padding = new Padding(3, 3, 3, 3); |
| | | tabPage2.Size = new Size(404, 519); |
| | | tabPage2.TabIndex = 1; |
| | | tabPage2.Text = "è¾åºç»æ"; |
| | | tabPage2.UseVisualStyleBackColor = true; |
| | |
| | | tableLayoutResults.RowStyles.Add(new RowStyle(SizeType.Percent, 10F)); |
| | | tableLayoutResults.RowStyles.Add(new RowStyle(SizeType.Percent, 10F)); |
| | | tableLayoutResults.RowStyles.Add(new RowStyle(SizeType.Percent, 10F)); |
| | | tableLayoutResults.Size = new Size(397, 510); |
| | | tableLayoutResults.Size = new Size(398, 513); |
| | | tableLayoutResults.TabIndex = 1; |
| | | // |
| | | // label5 |
| | |
| | | dtxtCenterX.Margin = new Padding(2, 3, 2, 3); |
| | | dtxtCenterX.Name = "dtxtCenterX"; |
| | | dtxtCenterX.ReadOnly = true; |
| | | dtxtCenterX.Size = new Size(293, 23); |
| | | dtxtCenterX.Size = new Size(294, 23); |
| | | dtxtCenterX.TabIndex = 5; |
| | | // |
| | | // dtxtCenterY |
| | |
| | | dtxtCenterY.Margin = new Padding(2, 3, 2, 3); |
| | | dtxtCenterY.Name = "dtxtCenterY"; |
| | | dtxtCenterY.ReadOnly = true; |
| | | dtxtCenterY.Size = new Size(293, 23); |
| | | dtxtCenterY.Size = new Size(294, 23); |
| | | dtxtCenterY.TabIndex = 6; |
| | | // |
| | | // dtxtAngle |
| | |
| | | dtxtAngle.Margin = new Padding(2, 3, 2, 3); |
| | | dtxtAngle.Name = "dtxtAngle"; |
| | | dtxtAngle.ReadOnly = true; |
| | | dtxtAngle.Size = new Size(293, 23); |
| | | dtxtAngle.Size = new Size(294, 23); |
| | | dtxtAngle.TabIndex = 7; |
| | | // |
| | | // label8 |
| | |
| | | dtxtScore.Location = new Point(103, 156); |
| | | dtxtScore.Name = "dtxtScore"; |
| | | dtxtScore.ReadOnly = true; |
| | | dtxtScore.Size = new Size(291, 23); |
| | | dtxtScore.Size = new Size(292, 23); |
| | | dtxtScore.TabIndex = 9; |
| | | // |
| | | // dtxtCount |
| | |
| | | tabPageInputImage.Controls.Add(pnlInputImage); |
| | | tabPageInputImage.Location = new Point(4, 26); |
| | | tabPageInputImage.Name = "tabPageInputImage"; |
| | | tabPageInputImage.Padding = new Padding(3); |
| | | tabPageInputImage.Padding = new Padding(3, 3, 3, 3); |
| | | tabPageInputImage.Size = new Size(613, 516); |
| | | tabPageInputImage.TabIndex = 0; |
| | | tabPageInputImage.Text = "è¾å
¥å¾å"; |
| | |
| | | // |
| | | pnlInputImage.Dock = DockStyle.Fill; |
| | | pnlInputImage.Location = new Point(3, 3); |
| | | pnlInputImage.Margin = new Padding(4); |
| | | pnlInputImage.Margin = new Padding(4, 4, 4, 4); |
| | | pnlInputImage.Name = "pnlInputImage"; |
| | | pnlInputImage.Size = new Size(607, 510); |
| | | pnlInputImage.TabIndex = 44; |
| | |
| | | tabPageRecordImage.Controls.Add(pnlRecordImage); |
| | | tabPageRecordImage.Location = new Point(4, 26); |
| | | tabPageRecordImage.Name = "tabPageRecordImage"; |
| | | tabPageRecordImage.Padding = new Padding(3); |
| | | tabPageRecordImage.Size = new Size(613, 516); |
| | | tabPageRecordImage.Padding = new Padding(3, 3, 3, 3); |
| | | tabPageRecordImage.Size = new Size(613, 519); |
| | | tabPageRecordImage.TabIndex = 1; |
| | | tabPageRecordImage.Text = "ç»æå¾å"; |
| | | tabPageRecordImage.UseVisualStyleBackColor = true; |
| | |
| | | // |
| | | pnlRecordImage.Dock = DockStyle.Fill; |
| | | pnlRecordImage.Location = new Point(3, 3); |
| | | pnlRecordImage.Margin = new Padding(4); |
| | | pnlRecordImage.Margin = new Padding(4, 4, 4, 4); |
| | | pnlRecordImage.Name = "pnlRecordImage"; |
| | | pnlRecordImage.Size = new Size(607, 510); |
| | | pnlRecordImage.Size = new Size(607, 513); |
| | | pnlRecordImage.TabIndex = 45; |
| | | // |
| | | // HFindMultiModelToolEdit |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | AutoScaleDimensions = new SizeF(7F, 17F); |
| | | AutoScaleMode = AutoScaleMode.Font; |
| | | Controls.Add(MainTableLayoutPanel); |
| | | Controls.Add(BtmStatusStrip); |
| | | Controls.Add(TopToolStrip); |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | |
| | | mimetype: application/x-microsoft.net.object.soap.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
| | |
| | | // |
| | | // HMulitModelControl |
| | | // |
| | | AutoScaleDimensions = new SizeF(96F, 96F); |
| | | AutoScaleMode = AutoScaleMode.Dpi; |
| | | AutoScaleDimensions = new SizeF(7F, 17F); |
| | | AutoScaleMode = AutoScaleMode.Font; |
| | | Controls.Add(tableLayoutPanel1); |
| | | Name = "HMulitModelControl"; |
| | | Size = new Size(399, 157); |
| | |
| | | |
| | | if (Subject.InputImage != null && Subject.InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)Subject.InputImage)) |
| | | { |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image); |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | |
| | | Type type = Subject.Params.ROI?.GetType(); |
| | | if (Subject.Params.ROI != null) |
| | | { |
| | |
| | | |
| | | if (Subject.InputImage != null && Subject.InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)Subject.InputImage)) |
| | | { |
| | | HOperatorSet.GetImageSize(image, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight); |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image); |
| | | HOperatorSet.GetImageSize(image, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight); |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | |
| | | //å
夿åç±»å夿ç¶ç±» |
| | |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false); |
| | | |
| | | for (int i = 0; i < msgRecord.Msg.Length; i++) |
| | | { |
| | | recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i] |
| | | , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]); |
| | | } |
| | | } |
| | | else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord) |
| | | { |
| | |
| | | HTuple hv_imageHeight = 0; |
| | | if (InputImage != null && InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)InputImage)) |
| | | { |
| | | image.GetImageSize(out hv_imageWidth, out hv_imageHeight); |
| | | switch (type) |
| | | { |
| | | case RoiType.Rectangle2: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0 |
| | | , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Circle: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4); |
| | | break; |
| | | //case RoiType.Ellipse: |
| | | // inputImageHSmartWindowControl.oRoi |
| | | // = new HEllipse(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2,0, hv_imageHeight.TupleReal() / 4, hv_imageWidth.TupleReal() / 4); |
| | | // break; |
| | | //case RoiType.Segment: |
| | | // inputImageHSmartWindowControl.oRoi |
| | | // = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | // break; |
| | | case RoiType.None: |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)InputImage, out HObject image); |
| | | HOperatorSet.GetImageSize(image, out hv_imageWidth, out hv_imageHeight); |
| | | } |
| | | switch (type) |
| | | { |
| | | case RoiType.Rectangle2: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0 |
| | | , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Circle: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4); |
| | | break; |
| | | //case RoiType.Ellipse: |
| | | // inputImageHSmartWindowControl.oRoi |
| | | // = new HEllipse(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2,0, hv_imageHeight.TupleReal() / 4, hv_imageWidth.TupleReal() / 4); |
| | | // break; |
| | | //case RoiType.Segment: |
| | | // inputImageHSmartWindowControl.oRoi |
| | | // = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | // break; |
| | | case RoiType.None: |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (Subject.InputImage != null && Subject.InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)Subject.InputImage)) |
| | | TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image); |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | |
| | | Type type = Subject.Params.ROI?.GetType(); |
| | | if (Subject.Params.ROI != null) |
| | | { |
| | | switch (type) |
| | | { |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | Type type = Subject.Params.ROI?.GetType(); |
| | | if (Subject.Params.ROI != null) |
| | | { |
| | | switch (type) |
| | | { |
| | | case Type t when t == typeof(HRectangle2): |
| | | cmbTypeRoi.Text = RoiType.Rectangle2.ToString(); |
| | | break; |
| | | case Type t when t == typeof(HCircle): |
| | | cmbTypeRoi.Text = RoiType.Circle.ToString(); |
| | | break; |
| | | case Type t when t == typeof(HSegment): |
| | | cmbTypeRoi.Text = RoiType.Segment.ToString(); |
| | | break; |
| | | default: |
| | | cmbTypeRoi.Text = RoiType.None.ToString(); |
| | | break; |
| | | } |
| | | if (cmbTypeRoi.Text.ToString() != "None") |
| | | ckbDrawRoi.Checked = true; |
| | | else |
| | | ckbDrawRoi.Checked = false; |
| | | |
| | | inputImageHSmartWindowControl.oRoi = Subject.Params.ROI; |
| | | } |
| | | |
| | | if (Subject.Params.Fixture != null) |
| | | cmbFixture.Text = Subject.Params.Fixture.strName; |
| | | else |
| | | cmbFixture.Text = ""; |
| | | |
| | | switch (type) |
| | | { |
| | | case Type t when t == typeof(HRectangle2): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y |
| | | , Subject.Params.ROI.Phi + Subject.Params.Fixture.Phi, ((HRectangle2)Subject.Params.ROI).Width, ((HRectangle2)Subject.Params.ROI).Height); |
| | | break; |
| | | case Type t when t == typeof(HCircle): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y |
| | | , ((HCircle)Subject.Params.ROI).Radius); |
| | | break; |
| | | case Type t when t == typeof(HSegment): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HSegment(((HSegment)Subject.Params.ROI).StartX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).StartY + Subject.Params.Fixture.Y |
| | | , ((HSegment)Subject.Params.ROI).EndX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).EndY + Subject.Params.Fixture.Y); |
| | | break; |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | case Type t when t == typeof(HRectangle2): |
| | | cmbTypeRoi.Text = RoiType.Rectangle2.ToString(); |
| | | break; |
| | | case Type t when t == typeof(HCircle): |
| | | cmbTypeRoi.Text = RoiType.Circle.ToString(); |
| | | break; |
| | | case Type t when t == typeof(HSegment): |
| | | cmbTypeRoi.Text = RoiType.Segment.ToString(); |
| | | break; |
| | | default: |
| | | cmbTypeRoi.Text = RoiType.None.ToString(); |
| | | break; |
| | | } |
| | | if (cmbTypeRoi.Text.ToString() != "None") |
| | | ckbDrawRoi.Checked = true; |
| | | else |
| | | ckbDrawRoi.Checked = false; |
| | | |
| | | inputImageHSmartWindowControl.oRoi = Subject.Params.ROI; |
| | | } |
| | | |
| | | if (Subject.Params.Fixture != null) |
| | | cmbFixture.Text = Subject.Params.Fixture.strName; |
| | | else |
| | | cmbFixture.Text = ""; |
| | | |
| | | switch (type) |
| | | { |
| | | case Type t when t == typeof(HRectangle2): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y |
| | | , Subject.Params.ROI.Phi + Subject.Params.Fixture.Phi, ((HRectangle2)Subject.Params.ROI).Width, ((HRectangle2)Subject.Params.ROI).Height); |
| | | break; |
| | | case Type t when t == typeof(HCircle): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y |
| | | , ((HCircle)Subject.Params.ROI).Radius); |
| | | break; |
| | | case Type t when t == typeof(HSegment): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HSegment(((HSegment)Subject.Params.ROI).StartX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).StartY + Subject.Params.Fixture.Y |
| | | , ((HSegment)Subject.Params.ROI).EndX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).EndY + Subject.Params.Fixture.Y); |
| | | break; |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | })); |
| | | } |
| | |
| | | |
| | | if (Subject.InputImage != null && Subject.InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)Subject.InputImage)) |
| | | { |
| | | image.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight); |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | //å
夿åç±»å夿ç¶ç±» |
| | | if (Subject.Record != null && Subject.Record is MsgRecord msgRecord) |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false); |
| | | |
| | | for (int i = 0; i < msgRecord.Msg.Length; i++) |
| | | recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i] |
| | | , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]); |
| | | } |
| | | else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord) |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_NG, false); |
| | | } |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image); |
| | | HOperatorSet.GetImageSize(image, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight); |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | |
| | | //å
夿åç±»å夿ç¶ç±» |
| | | if (Subject.Record != null && Subject.Record is MsgRecord msgRecord) |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false); |
| | | |
| | | for (int i = 0; i < msgRecord.Msg.Length; i++) |
| | | recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i] |
| | | , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]); |
| | | } |
| | | else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord) |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_NG, false); |
| | | } |
| | | |
| | | GC.Collect(); |
| | | })); |
| | | } |
| | |
| | | HTuple hv_imageHeight = 0; |
| | | if (InputImage != null && InputImage is Mat) |
| | | { |
| | | using (HImage image=TAlgorithm.Mat2HObject((Mat)InputImage)) |
| | | { |
| | | image.GetImageSize(out hv_imageWidth, out hv_imageHeight); |
| | | switch (type) |
| | | { |
| | | case RoiType.Rectangle2: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0 |
| | | , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Circle: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Segment: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.None: |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)InputImage, out HObject image); |
| | | HOperatorSet.GetImageSize(image, out hv_imageWidth, out hv_imageHeight); |
| | | } |
| | | switch (type) |
| | | { |
| | | case RoiType.Rectangle2: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0 |
| | | , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Circle: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Segment: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.None: |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (InputImage != null && InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)InputImage)) |
| | | { |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | int hv_Elements = Convert.ToInt16(itxtCaliperCount.Text); |
| | | double hv_DetectHeight = Convert.ToDouble(dtxtCaliperHeight.Text); |
| | | double hv_DetectWidth = Convert.ToDouble(dtxtCaliperWidth.Text); |
| | | |
| | | double hv_Row1 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).BeginRow + Subject.Params.Fixture.Row); |
| | | double hv_Column1 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).BeginColumn + Subject.Params.Fixture.Column); |
| | | double hv_Row2 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).EndRow + Subject.Params.Fixture.Row); |
| | | double hv_Column2 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).EndColumn + Subject.Params.Fixture.Column); |
| | | |
| | | TAlgorithm.GetRakeRegions(null, out HObject ho_Regions, hv_Elements, hv_DetectHeight, hv_DetectWidth |
| | | , new HTuple(), new HTuple(), new HTuple(), new HTuple() |
| | | , hv_Row1, hv_Column1, hv_Row2, hv_Column2 |
| | | , out HTuple hv_ResultRow, out HTuple hv_ResultColumn); |
| | | |
| | | inputImageHSmartWindowControl.DispObj(ho_Regions); |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)InputImage, out HObject image); |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | |
| | | int hv_Elements = Convert.ToInt16(itxtCaliperCount.Text); |
| | | double hv_DetectHeight = Convert.ToDouble(dtxtCaliperHeight.Text); |
| | | double hv_DetectWidth = Convert.ToDouble(dtxtCaliperWidth.Text); |
| | | |
| | | double hv_Row1 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).BeginRow + Subject.Params.Fixture.Row); |
| | | double hv_Column1 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).BeginColumn + Subject.Params.Fixture.Column); |
| | | double hv_Row2 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).EndRow + Subject.Params.Fixture.Row); |
| | | double hv_Column2 = Convert.ToDouble(((HSegment)inputImageHSmartWindowControl.oRoi).EndColumn + Subject.Params.Fixture.Column); |
| | | |
| | | TAlgorithm.GetRakeRegions(null, out HObject ho_Regions, hv_Elements, hv_DetectHeight, hv_DetectWidth |
| | | , new HTuple(), new HTuple(), new HTuple(), new HTuple() |
| | | , hv_Row1, hv_Column1, hv_Row2, hv_Column2 |
| | | , out HTuple hv_ResultRow, out HTuple hv_ResultColumn); |
| | | |
| | | inputImageHSmartWindowControl.DispObj(ho_Regions); |
| | | } |
| | | catch { } |
| | | })); |
| | |
| | | |
| | | if (Subject.InputImage != null && Subject.InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)Subject.InputImage)) |
| | | { |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | Type type = Subject.Params.ROI?.GetType(); |
| | | if (Subject.Params.ROI != null) |
| | | { |
| | | switch (type) |
| | | { |
| | | case Type t when t == typeof(HRectangle2): |
| | | cmbTypeRoi.Text = RoiType.Rectangle2.ToString(); |
| | | break; |
| | | case Type t when t == typeof(HCircle): |
| | | cmbTypeRoi.Text = RoiType.Circle.ToString(); |
| | | break; |
| | | case Type t when t == typeof(HSegment): |
| | | cmbTypeRoi.Text = RoiType.Segment.ToString(); |
| | | break; |
| | | default: |
| | | cmbTypeRoi.Text = RoiType.None.ToString(); |
| | | break; |
| | | } |
| | | if (cmbTypeRoi.Text.ToString() != "None") |
| | | ckbDrawRoi.Checked = true; |
| | | else |
| | | ckbDrawRoi.Checked = false; |
| | | |
| | | inputImageHSmartWindowControl.oRoi = Subject.Params.ROI; |
| | | } |
| | | |
| | | if (Subject.Params.Fixture != null) |
| | | cmbFixture.Text = Subject.Params.Fixture.strName; |
| | | else |
| | | cmbFixture.Text = ""; |
| | | |
| | | switch (type) |
| | | { |
| | | case Type t when t == typeof(HRectangle2): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y |
| | | , Subject.Params.ROI.Phi + Subject.Params.Fixture.Phi, ((HRectangle2)Subject.Params.ROI).Width, ((HRectangle2)Subject.Params.ROI).Height); |
| | | break; |
| | | case Type t when t == typeof(HCircle): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y |
| | | , ((HCircle)Subject.Params.ROI).Radius); |
| | | break; |
| | | case Type t when t == typeof(HSegment): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HSegment(((HSegment)Subject.Params.ROI).StartX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).StartY + Subject.Params.Fixture.Y |
| | | , ((HSegment)Subject.Params.ROI).EndX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).EndY + Subject.Params.Fixture.Y); |
| | | break; |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | |
| | | ShowModel(((FindModelTool)Subject).ModelID); |
| | | |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image); |
| | | inputImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | |
| | | Type type = Subject.Params.ROI?.GetType(); |
| | | if (Subject.Params.ROI != null) |
| | | { |
| | | switch (type) |
| | | { |
| | | case Type t when t == typeof(HRectangle2): |
| | | cmbTypeRoi.Text = RoiType.Rectangle2.ToString(); |
| | | break; |
| | | case Type t when t == typeof(HCircle): |
| | | cmbTypeRoi.Text = RoiType.Circle.ToString(); |
| | | break; |
| | | case Type t when t == typeof(HSegment): |
| | | cmbTypeRoi.Text = RoiType.Segment.ToString(); |
| | | break; |
| | | default: |
| | | cmbTypeRoi.Text = RoiType.None.ToString(); |
| | | break; |
| | | } |
| | | if (cmbTypeRoi.Text.ToString() != "None") |
| | | ckbDrawRoi.Checked = true; |
| | | else |
| | | ckbDrawRoi.Checked = false; |
| | | |
| | | inputImageHSmartWindowControl.oRoi = Subject.Params.ROI; |
| | | } |
| | | |
| | | if (Subject.Params.Fixture != null) |
| | | cmbFixture.Text = Subject.Params.Fixture.strName; |
| | | else |
| | | cmbFixture.Text = ""; |
| | | |
| | | switch (type) |
| | | { |
| | | case Type t when t == typeof(HRectangle2): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y |
| | | , Subject.Params.ROI.Phi + Subject.Params.Fixture.Phi, ((HRectangle2)Subject.Params.ROI).Width, ((HRectangle2)Subject.Params.ROI).Height); |
| | | break; |
| | | case Type t when t == typeof(HCircle): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(Subject.Params.ROI.X + Subject.Params.Fixture.X, Subject.Params.ROI.Y + Subject.Params.Fixture.Y |
| | | , ((HCircle)Subject.Params.ROI).Radius); |
| | | break; |
| | | case Type t when t == typeof(HSegment): |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HSegment(((HSegment)Subject.Params.ROI).StartX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).StartY + Subject.Params.Fixture.Y |
| | | , ((HSegment)Subject.Params.ROI).EndX + Subject.Params.Fixture.X, ((HSegment)Subject.Params.ROI).EndY + Subject.Params.Fixture.Y); |
| | | break; |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | |
| | | ShowModel(((FindModelTool)Subject).ModelID); |
| | | })); |
| | | } |
| | | |
| | |
| | | |
| | | if (Subject.InputImage != null && Subject.InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)Subject.InputImage)) |
| | | { |
| | | image.GetImageSize(out HTuple ho_ImageWidth, out HTuple ho_ImageHeight); |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | //å
夿åç±»å夿ç¶ç±» |
| | | if (Subject.Record != null && Subject.Record is MsgRecord msgRecord) |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false); |
| | | TAlgorithm.Mat2HObject((Mat)Subject.InputImage, out HObject image); |
| | | HOperatorSet.GetImageSize(image, out HTuple ho_ImageWidth, out HTuple ho_ImageHeight); |
| | | recordImageHSmartWindowControl.ShowHoImage(image); |
| | | } |
| | | |
| | | for (int i = 0; i < msgRecord.Msg.Length; i++) |
| | | recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i] |
| | | , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]); |
| | | } |
| | | else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord) |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_NG, false); |
| | | } |
| | | //å
夿åç±»å夿ç¶ç±» |
| | | if (Subject.Record != null && Subject.Record is MsgRecord msgRecord) |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(msgRecord.RecordObject_NG, false); |
| | | |
| | | } |
| | | for (int i = 0; i < msgRecord.Msg.Length; i++) |
| | | recordImageHSmartWindowControl.ShowMsg(msgRecord.Msg[i] |
| | | , 1 == msgRecord.Result[i] ? true : false, msgRecord.Column[i], msgRecord.Row[i]); |
| | | } |
| | | else if (Subject.Record != null && Subject.Record is ObjectRecord objRecord) |
| | | { |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_OK, true); |
| | | recordImageHSmartWindowControl.DispObj(objRecord.RecordObject_NG, false); |
| | | } |
| | | |
| | | GC.Collect(); |
| | |
| | | HTuple hv_imageHeight = 0; |
| | | if (InputImage != null && InputImage is Mat) |
| | | { |
| | | using (HImage image = TAlgorithm.Mat2HObject((Mat)InputImage)) |
| | | { |
| | | HOperatorSet.GetImageSize(image, out hv_imageWidth, out hv_imageHeight); |
| | | switch (type) |
| | | { |
| | | case RoiType.Rectangle2: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0 |
| | | , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Circle: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Segment: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.None: |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)InputImage, out HObject image); |
| | | HOperatorSet.GetImageSize(image, out hv_imageWidth, out hv_imageHeight); |
| | | } |
| | | switch (type) |
| | | { |
| | | case RoiType.Rectangle2: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, 0 |
| | | , hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Circle: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HCircle(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2, hv_imageWidth.TupleReal() / 4); |
| | | break; |
| | | case RoiType.Segment: |
| | | inputImageHSmartWindowControl.oRoi |
| | | = new HSegment(0, 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | break; |
| | | case RoiType.None: |
| | | default: |
| | | inputImageHSmartWindowControl.oRoi = null; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | if (InputImage != null && InputImage is Mat) |
| | | { |
| | | imgTabControl.SelectedTab = tabPageModelImage; |
| | | using (HImage hoDomainImage = TAlgorithm.Mat2HObject((Mat)InputImage)) |
| | | { |
| | | HOperatorSet.GetImageSize(hoDomainImage, out HTuple hv_imageWidth, out HTuple hv_imageHeight); |
| | | createModelImageHSmartWindowControl.ShowHoImage((HObject)hoDomainImage); |
| | | createModelImageHSmartWindowControl.bAollowDraw = true; |
| | | createModelImageHSmartWindowControl.oRoi = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2 |
| | | , 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | } |
| | | TAlgorithm.Mat2HObject((Mat)InputImage, out HObject hoDomainImage); |
| | | |
| | | HOperatorSet.GetImageSize(hoDomainImage, out HTuple hv_imageWidth, out HTuple hv_imageHeight); |
| | | createModelImageHSmartWindowControl.ShowHoImage((HObject)hoDomainImage); |
| | | createModelImageHSmartWindowControl.bAollowDraw = true; |
| | | createModelImageHSmartWindowControl.oRoi = new HRectangle2(hv_imageWidth.TupleReal() / 2, hv_imageHeight.TupleReal() / 2 |
| | | , 0, hv_imageWidth.TupleReal() / 4, hv_imageHeight.TupleReal() / 4); |
| | | } |
| | | } |
| | | |
| | |
| | | if (InputImage != null && InputImage is Mat) |
| | | { |
| | | double result = 0; |
| | | |
| | | if (Enum.TryParse(cmbModelType.Text, out ModelType modelType)) |
| | | { |
| | | string NumLevels = this.dtxtModelParam1.Text; |
| | |
| | | string Contrast = this.dtxtModelParam11.Text; |
| | | int MinContrast = Convert.ToInt16(this.dtxtModelParam12.Text); |
| | | HRectangle2 ROI = (HRectangle2)createModelImageHSmartWindowControl.oRoi; |
| | | using (HRegion hRectangle = new HRegion()) |
| | | |
| | | HOperatorSet.GenRectangle2(out HObject hRectangle, ROI.Row, ROI.Column, ROI.Phi, ROI.SemiLength1, ROI.SemiLength2); |
| | | TAlgorithm.Mat2HObject((Mat)InputImage, out HObject hoDomainImage); |
| | | HTuple hv_Channels = new HTuple(); |
| | | //夿æ¯å¦ä¸ºç°åº¦å¾ |
| | | using (HDevDisposeHelper dh = new HDevDisposeHelper()) |
| | | { |
| | | hRectangle.GenRectangle2(ROI.Row, ROI.Column, ROI.Phi, ROI.SemiLength1, ROI.SemiLength2); |
| | | using (HImage hoDomainImage = TAlgorithm.Mat2HObject((Mat)InputImage)) |
| | | try |
| | | { |
| | | HTuple hv_Channels = new HTuple(); |
| | | //夿æ¯å¦ä¸ºç°åº¦å¾ |
| | | using (HDevDisposeHelper dh = new HDevDisposeHelper()) |
| | | { |
| | | try |
| | | { |
| | | //hv_Channels = hoDomainImage.CountChannels(); |
| | | //if (hv_Channels.TupleInt() != 1) |
| | | // HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage); |
| | | HOperatorSet.CountChannels(hoDomainImage, out hv_Channels); |
| | | if (hv_Channels.TupleInt() != 1) |
| | | HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage); |
| | | |
| | | ////转æ¢å忬¡æ£æ¥æ¯å¦ä¸ºç°åº¦å¾ |
| | | //HOperatorSet.CountChannels(hoDomainImage, out hv_Channels); |
| | | //if (hv_Channels.TupleInt() != 1) |
| | | // HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage); |
| | | } |
| | | catch { } |
| | | } |
| | | HObject hoImageReduced = hoDomainImage.Rgb1ToGray().ReduceDomain(hRectangle); |
| | | HOperatorSet.CropDomain(hoImageReduced, out hoImageReduced); |
| | | TAlgorithm.HObject2Mat(hoImageReduced, out Mat hoModelImage); |
| | | bool bCreateModel = false; |
| | | |
| | | switch (modelType) |
| | | { |
| | | case ModelType.ç°åº¦å¹é
: |
| | | bCreateModel = ((FindModelTool)Subject).CreateModel |
| | | (hoModelImage, modelType, NumLevels |
| | | , AngleStart, AngleExtent, AngleStep |
| | | , ScaleRMin, ScaleRMax, "auto" |
| | | , ScaleCMin, ScaleCMax, "auto" |
| | | , Optimization, Metric, Contrast, MinContrast); |
| | | break; |
| | | default: |
| | | bCreateModel = ((FindModelTool)Subject).CreateModel |
| | | (hoModelImage, modelType, NumLevels |
| | | , AngleStart, AngleExtent, AngleStep |
| | | , ScaleRMin, ScaleRMax, "auto" |
| | | , ScaleCMin, ScaleCMax, "auto" |
| | | , Optimization, Metric, Contrast, MinContrast); |
| | | break; |
| | | } |
| | | |
| | | if (bCreateModel) |
| | | { |
| | | using (HObject ho_ModelContours = new HObject()) |
| | | { |
| | | //switch (((FindModelTool)Subject).ModelID.Type) |
| | | //{ |
| | | // case ModelType.å±é¨å形模æ¿: |
| | | // HOperatorSet.GetDeformableModelContours(out ho_ModelContours, ((HFindModelTool)Subject).ModelID.hvModel, 1); |
| | | // break; |
| | | // case ModelType.ååå¼å½¢æ¨¡æ¿: |
| | | // default: |
| | | // HOperatorSet.GetShapeModelContours(out ho_ModelContours, ((HFindModelTool)Subject).ModelID.hvModel, 1); |
| | | // break; |
| | | //} |
| | | //HOperatorSet.GetImageSize(((HFindModelTool)Subject).ModelID.hoImage, out HTuple hv_Width, out HTuple hv_Height); |
| | | //HOperatorSet.VectorAngleToRigid(-hv_Height / 2, -hv_Width / 2, 0, 0, 0, 0, out HTuple hv_HomMat2D); |
| | | //HOperatorSet.AffineTransContourXld(ho_ModelContours, out ho_ModelContours, hv_HomMat2D); |
| | | |
| | | //建模æå导èªå°å页 |
| | | parasTabControl.SelectedTab = tabPageRunParas; |
| | | //modelImageHSmartWindowControl.ShowHoImage(((HFindModelTool)Subject).ModelID.hoImage); |
| | | using (HImage modelImage = TAlgorithm.Mat2HObject(((FindModelTool)Subject).ModelID.hoImage)) |
| | | { |
| | | modelImageHSmartWindowControl.ShowHoImage(modelImage); |
| | | modelImageHSmartWindowControl.DispObj(ho_ModelContours, false); |
| | | modelImageHSmartWindowControl.ShowMsg("åå»ºæ¨¡æ¿æå", true); |
| | | } |
| | | } |
| | | } |
| | | //转æ¢å忬¡æ£æ¥æ¯å¦ä¸ºç°åº¦å¾ |
| | | HOperatorSet.CountChannels(hoDomainImage, out hv_Channels); |
| | | if (hv_Channels.TupleInt() != 1) |
| | | HOperatorSet.Rgb1ToGray(hoDomainImage, out hoDomainImage); |
| | | } |
| | | catch { } |
| | | } |
| | | HOperatorSet.ReduceDomain(hoDomainImage, hRectangle, out HObject hoImageReduced); |
| | | HOperatorSet.CropDomain(hoImageReduced, out hoImageReduced); |
| | | TAlgorithm.HObject2Mat(hoImageReduced, out Mat hoModelImage); |
| | | bool bCreateModel = false; |
| | | |
| | | switch (modelType) |
| | | { |
| | | case ModelType.ç°åº¦å¹é
: |
| | | bCreateModel = ((FindModelTool)Subject).CreateModel |
| | | (hoModelImage, modelType, NumLevels |
| | | , AngleStart, AngleExtent, AngleStep |
| | | , ScaleRMin, ScaleRMax, "auto" |
| | | , ScaleCMin, ScaleCMax, "auto" |
| | | , Optimization, Metric, Contrast, MinContrast); |
| | | break; |
| | | default: |
| | | bCreateModel = ((FindModelTool)Subject).CreateModel |
| | | (hoModelImage, modelType, NumLevels |
| | | , AngleStart, AngleExtent, AngleStep |
| | | , ScaleRMin, ScaleRMax, "auto" |
| | | , ScaleCMin, ScaleCMax, "auto" |
| | | , Optimization, Metric, Contrast, MinContrast); |
| | | break; |
| | | } |
| | | |
| | | if (bCreateModel) |
| | | { |
| | | HObject ho_ModelContours = new HObject(); |
| | | //switch (((FindModelTool)Subject).ModelID.Type) |
| | | //{ |
| | | // case ModelType.å±é¨å形模æ¿: |
| | | // HOperatorSet.GetDeformableModelContours(out ho_ModelContours, ((HFindModelTool)Subject).ModelID.hvModel, 1); |
| | | // break; |
| | | // case ModelType.ååå¼å½¢æ¨¡æ¿: |
| | | // default: |
| | | // HOperatorSet.GetShapeModelContours(out ho_ModelContours, ((HFindModelTool)Subject).ModelID.hvModel, 1); |
| | | // break; |
| | | //} |
| | | //HOperatorSet.GetImageSize(((HFindModelTool)Subject).ModelID.hoImage, out HTuple hv_Width, out HTuple hv_Height); |
| | | //HOperatorSet.VectorAngleToRigid(-hv_Height / 2, -hv_Width / 2, 0, 0, 0, 0, out HTuple hv_HomMat2D); |
| | | //HOperatorSet.AffineTransContourXld(ho_ModelContours, out ho_ModelContours, hv_HomMat2D); |
| | | |
| | | //建模æå导èªå°å页 |
| | | parasTabControl.SelectedTab = tabPageRunParas; |
| | | //modelImageHSmartWindowControl.ShowHoImage(((HFindModelTool)Subject).ModelID.hoImage); |
| | | TAlgorithm.Mat2HObject(((FindModelTool)Subject).ModelID.hoImage, out HObject modelImage); |
| | | modelImageHSmartWindowControl.ShowHoImage(modelImage); |
| | | modelImageHSmartWindowControl.DispObj(ho_ModelContours, false); |
| | | modelImageHSmartWindowControl.ShowMsg("åå»ºæ¨¡æ¿æå", true); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (ModelID != null && ModelID.Width > 0) |
| | | { |
| | | //HOperatorSet.GenEmptyObj(out HObject ho_ModelContours); |
| | | using (HRegion ho_ModelContours = new HRegion()) |
| | | { |
| | | //switch (ModelID.Type) |
| | | //{ |
| | | // case ModelType.ååå¼å½¢æ¨¡æ¿: |
| | | // HOperatorSet.GetDeformableModelContours(out ho_ModelContours, ModelID.hvModel, 1); |
| | | // break; |
| | | // default: |
| | | // HOperatorSet.GetShapeModelContours(out ho_ModelContours, ModelID.hvModel, 1); |
| | | // break; |
| | | //} |
| | | HOperatorSet.GenEmptyObj(out HObject ho_ModelContours); |
| | | //switch (ModelID.Type) |
| | | //{ |
| | | // case ModelType.ååå¼å½¢æ¨¡æ¿: |
| | | // HOperatorSet.GetDeformableModelContours(out ho_ModelContours, ModelID.hvModel, 1); |
| | | // break; |
| | | // default: |
| | | // HOperatorSet.GetShapeModelContours(out ho_ModelContours, ModelID.hvModel, 1); |
| | | // break; |
| | | //} |
| | | |
| | | //HOperatorSet.GetImageSize(ModelID.hoImage, out HTuple hv_Width, out HTuple hv_Height); |
| | | //HOperatorSet.VectorAngleToRigid(-hv_Height / 2, -hv_Width / 2, 0, 0, 0, 0, out HTuple hv_HomMat2D); |
| | | //HOperatorSet.AffineTransContourXld(ho_ModelContours, out ho_ModelContours, hv_HomMat2D); |
| | | //HOperatorSet.GetImageSize(ModelID.hoImage, out HTuple hv_Width, out HTuple hv_Height); |
| | | //HOperatorSet.VectorAngleToRigid(-hv_Height / 2, -hv_Width / 2, 0, 0, 0, 0, out HTuple hv_HomMat2D); |
| | | //HOperatorSet.AffineTransContourXld(ho_ModelContours, out ho_ModelContours, hv_HomMat2D); |
| | | |
| | | modelImageHSmartWindowControl.ClearObj(); |
| | | using (HImage hoImage = TAlgorithm.Mat2HObject(ModelID.hoImage)) |
| | | { |
| | | //modelImageHSmartWindowControl.ShowHoImage(ModelID.hoImage); |
| | | modelImageHSmartWindowControl.ShowHoImage(hoImage); |
| | | modelImageHSmartWindowControl.DispObj(ho_ModelContours, false); |
| | | modelImageHSmartWindowControl.ShowMsg("åå»ºæ¨¡æ¿æå", true); |
| | | } |
| | | } |
| | | modelImageHSmartWindowControl.ClearObj(); |
| | | TAlgorithm.Mat2HObject(ModelID.hoImage, out HObject hoImage); |
| | | //modelImageHSmartWindowControl.ShowHoImage(ModelID.hoImage); |
| | | modelImageHSmartWindowControl.ShowHoImage(hoImage); |
| | | modelImageHSmartWindowControl.DispObj(ho_ModelContours, false); |
| | | modelImageHSmartWindowControl.ShowMsg("åå»ºæ¨¡æ¿æå", true); |
| | | } |
| | | } |
| | | catch { } |
| | |
| | | using Newtonsoft.Json; |
| | | using HalconDotNet; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Serialization; |
| | | using OpenCvSharp; |
| | | using OpenCvSharp.Extensions; |
| | | using System; |
| | | using System.Collections.Concurrent; |
| | | using System.Diagnostics; |
| | | using System.Text; |
| | |
| | | Msg = ""; |
| | | if (OutputImage != null) |
| | | { |
| | | if (OutputImage is Bitmap) |
| | | { |
| | | if (OutputImage is HObject) |
| | | ((HObject)OutputImage).Dispose(); |
| | | else if (OutputImage is Mat) |
| | | ((Mat)OutputImage).Dispose(); |
| | | else if (OutputImage is Bitmap) |
| | | ((Bitmap)OutputImage).Dispose(); |
| | | } |
| | | |
| | | OutputImage = null; |
| | | } |
| | | if (Record != null) |
| | | { |
| | | Record.Dispose(); |
| | | Record = null; |
| | | } |
| | | } |
| | | |
| | | public override void Dispose() |
| | | { |
| | | if (InputImage != null) |
| | | { |
| | | if (InputImage is HObject) |
| | | ((HObject)InputImage).Dispose(); |
| | | else if (InputImage is Mat) |
| | | ((Mat)InputImage).Dispose(); |
| | | else if (InputImage is Bitmap) |
| | | ((Bitmap)InputImage).Dispose(); |
| | | |
| | | InputImage = null; |
| | | } |
| | | |
| | | if (OutputImage != null) |
| | | { |
| | | if (OutputImage is HObject) |
| | | ((HObject)OutputImage).Dispose(); |
| | | else if (OutputImage is Mat) |
| | | ((Mat)OutputImage).Dispose(); |
| | | else if (OutputImage is Bitmap) |
| | | ((Bitmap)OutputImage).Dispose(); |
| | | |
| | | OutputImage = null; |
| | | } |
| | | return; |
| | | } |
| | | |
| | |
| | | /// <summary> |
| | | /// è¾å
¥å¾ç |
| | | /// </summary> |
| | | public object InputImage; |
| | | public object InputImage = null; |
| | | |
| | | /// <summary> |
| | | /// è¾åºå¾ç |
| | | /// </summary> |
| | | public object OutputImage; |
| | | public object OutputImage = null; |
| | | |
| | | /// <summary> |
| | | /// ç»æåºå |
| | |
| | | DateTime StartTime = DateTime.Now; |
| | | |
| | | InitRunParams(); |
| | | HOperatorSet.GenEmptyObj(out HObject EmptyObj); |
| | | OutputImage = EmptyObj; |
| | | //HOperatorSet.GenEmptyObj(out HObject EmptyObj); |
| | | //OutputImage = EmptyObj; |
| | | |
| | | #region è¿è¡é»è¾ |
| | | |