using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using AR; #if V22 using Euresys.Open_eVision_22_12; #else using Euresys.Open_eVision_2_11; #endif namespace Project { public partial class fTeach : Form { EImageBW8 img = null; private arCtl.ImageBoxEvision iv1; public fTeach(EBaseROI img_ = null) { InitializeComponent(); this.iv1 = new arCtl.ImageBoxEvision(); this.iv1.BackColor = Color.Black; this.iv1.Dock = DockStyle.Fill; this.panel2.Controls.Add(iv1); iv1.Dock = DockStyle.Fill; if (img_ != null) { img = new EImageBW8(); img.SetSize(img_); img_.CopyTo(this.img); //EasyImage.Copy(img_, img); this.iv1.Image = img; this.iv1.Invalidate(); this.iv1.ZoomFit(); } this.FormClosed += FTeach_FormClosed; } private void FTeach_FormClosed(object sender, FormClosedEventArgs e) { if (this.img != null) img.Dispose(); runtest = false; } private void fTeach_Load(object sender, EventArgs e) { this.tbErode.Text = PUB.setting.erodevaluestr; this.tbGainOff.Text = PUB.setting.GainOffsetListStr; } private void toolStripButton1_Click(object sender, EventArgs e) { //open file OpenFileDialog od = new OpenFileDialog(); if (od.ShowDialog() == DialogResult.OK) { if (this.img != null) this.img.Dispose(); img = new EImageBW8(); img.Load(od.FileName); this.iv1.Image = img; this.iv1.Invalidate(); this.iv1.ZoomFit(); } } private void btFineEvision_Click(object sender, EventArgs e) { string resultMessage; iv1.Shapes.Clear(); //using (EImageBW8 img = new EImageBW8(this.img.Width, this.img.Height)) { //img.SetImagePtr(this.img.Width, this.img.Height, this.img.MIplImage.ImageData); var pccnt = 0; var qrrlt = Util_Vision.DetectQR(img, this.iv1, pccnt++, out resultMessage, tbErode.Text, tbGainOff.Text, PUB.setting.blob_area_min, PUB.setting.blob_area_max, PUB.setting.blob_sigmaxy, PUB.setting.blob_sigmayy, PUB.setting.blob_sigmaxx, PUB.setting.blob_minw, PUB.setting.blob_maxw, PUB.setting.blob_minh, PUB.setting.blob_maxh); var list = qrrlt.Item1; //PUB.ProcessTime[ECalibrationMode] this.tbBarcodeList.Text = string.Join(",", list.Select(t => t.data).ToArray()); // foreach (var item in list.OrderByDescending(t => t.sid)) { Console.WriteLine("sid:" + item.sid); } } this.iv1.ZoomFit(); } Boolean runtest = false; int runcount = 0; private void toolStripButton3_Click(object sender, EventArgs e) { if (runtest) { runtest = false; PUB.log_[0].Add($"Test completed({runcount})"); } else { string resultMessage; iv1.Shapes.Clear(); runcount = 0; runtest = true; PUB.log_[0].Add("Test Evision Start"); Task.Run(() => { while (runtest) { Util_Vision.DetectQR(img, this.iv1, runcount++, out resultMessage, tbErode.Text, tbGainOff.Text, PUB.setting.blob_area_min, PUB.setting.blob_area_max, PUB.setting.blob_sigmaxy, PUB.setting.blob_sigmayy, PUB.setting.blob_sigmaxx, PUB.setting.blob_minw, PUB.setting.blob_maxw, PUB.setting.blob_minh, PUB.setting.blob_maxh); } }); } } private void toolStripButton4_Click(object sender, EventArgs e) { if (this.iv1.Image == null) { UTIL.MsgE("No image"); return; } var sd = new SaveFileDialog(); sd.FileName = "saveimage.bmp"; if (sd.ShowDialog() == DialogResult.OK) this.iv1.Image.Save(sd.FileName); } private void button1_Click(object sender, EventArgs e) { PUB.setting.erodevaluestr = tbErode.Text; PUB.setting.GainOffsetListStr = tbGainOff.Text; PUB.setting.Save(); } private void toolStripButton13_Click(object sender, EventArgs e) { this.iv1.DebugMode = !this.iv1.DebugMode; this.iv1.Invalidate(); } //private void toolStripButton6_Click(object sender, EventArgs e) //{ // string resultMessage; // iv1.ClearShape(); // using (EImageBW8 img = new EImageBW8(this.img.Width, this.img.Height)) // { // img.SetImagePtr(this.img.Width, this.img.Height, this.img.MIplImage.ImageData); // var pccnt = 0; // var list = Util_Vision.DetectQR(img, this.iv1, pccnt++, // out resultMessage, // tbErode.Text, // tbGainOff.Text, // Pub.setting.blob_area_min, // Pub.setting.blob_area_max, // Pub.setting.blob_sigmaxy, // Pub.setting.blob_sigmayy, // Pub.setting.blob_sigmaxx, // Pub.setting.blob_minw, // Pub.setting.blob_maxw, // Pub.setting.blob_minh, // Pub.setting.blob_maxh, // true); // // // foreach (var item in list.OrderByDescending(t => t.sid)) // { // Console.WriteLine("sid:" + item.sid); // } // } // this.iv1.ZoomFit(); //} //private void toolStripButton5_Click(object sender, EventArgs e) //{ // if (runtest) // { // runtest = false; // Pub.log.Add($"테스트 종료({runcount})"); // } // else // { // Pub.log.Add("Test Evision+Softtek Start"); // string resultMessage; // iv1.ClearShape(); // runcount = 0; // runtest = true; // Task.Run(() => // { // using (EImageBW8 img = new EImageBW8(this.img.Width, this.img.Height)) // { // img.SetImagePtr(this.img.Width, this.img.Height, this.img.MIplImage.ImageData); // while (runtest) // { // Util_Vision.DetectQR(img, this.iv1, runcount++, // out resultMessage, // tbErode.Text, // tbGainOff.Text, // Pub.setting.blob_area_min, // Pub.setting.blob_area_max, // Pub.setting.blob_sigmaxy, // Pub.setting.blob_sigmayy, // Pub.setting.blob_sigmaxx, // Pub.setting.blob_minw, // Pub.setting.blob_maxw, // Pub.setting.blob_minh, // Pub.setting.blob_maxh, // true); // } // } // }); // } //} } }