From 57baeaf849b8eb606d4742b53d2a10e91714a990 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Sat, 20 Feb 2021 11:14:44 +0100 Subject: [PATCH] eliminazione trasf BN inutilizzata --- Thermo.Cam.Setup.sln | 4 +- Thermo.Cam.Setup/MainForm.Designer.cs | 62 ++++++++++++------------ Thermo.Cam.Setup/MainForm.cs | 29 +++++------ Thermo.Cam.Utils/TCContr.cs | 70 +++++++++++++-------------- 4 files changed, 81 insertions(+), 84 deletions(-) diff --git a/Thermo.Cam.Setup.sln b/Thermo.Cam.Setup.sln index 3ba53cd2..be7e9136 100644 --- a/Thermo.Cam.Setup.sln +++ b/Thermo.Cam.Setup.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30611.23 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThermalImageStreamerDemo", "Thermo.Cam.Setup\Thermo.Cam.Setup.csproj", "{009978D9-A2D0-4354-A4C1-E181D7F34919}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thermo.Cam.Setup", "Thermo.Cam.Setup\Thermo.Cam.Setup.csproj", "{009978D9-A2D0-4354-A4C1-E181D7F34919}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thermo.Cam.Utils", "Thermo.Cam.Utils\Thermo.Cam.Utils.csproj", "{E4587942-498B-4AA7-9CC9-9304EB2D05C8}" EndProject @@ -18,11 +18,13 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {009978D9-A2D0-4354-A4C1-E181D7F34919}.Debug|Any CPU.ActiveCfg = Debug|x86 + {009978D9-A2D0-4354-A4C1-E181D7F34919}.Debug|Any CPU.Build.0 = Debug|x86 {009978D9-A2D0-4354-A4C1-E181D7F34919}.Debug|x64.ActiveCfg = Debug|x64 {009978D9-A2D0-4354-A4C1-E181D7F34919}.Debug|x64.Build.0 = Debug|x64 {009978D9-A2D0-4354-A4C1-E181D7F34919}.Debug|x86.ActiveCfg = Debug|x86 {009978D9-A2D0-4354-A4C1-E181D7F34919}.Debug|x86.Build.0 = Debug|x86 {009978D9-A2D0-4354-A4C1-E181D7F34919}.Release|Any CPU.ActiveCfg = Release|x86 + {009978D9-A2D0-4354-A4C1-E181D7F34919}.Release|Any CPU.Build.0 = Release|x86 {009978D9-A2D0-4354-A4C1-E181D7F34919}.Release|x64.ActiveCfg = Release|x64 {009978D9-A2D0-4354-A4C1-E181D7F34919}.Release|x64.Build.0 = Release|x64 {009978D9-A2D0-4354-A4C1-E181D7F34919}.Release|x86.ActiveCfg = Release|x86 diff --git a/Thermo.Cam.Setup/MainForm.Designer.cs b/Thermo.Cam.Setup/MainForm.Designer.cs index a68c60bd..b6fd9201 100644 --- a/Thermo.Cam.Setup/MainForm.Designer.cs +++ b/Thermo.Cam.Setup/MainForm.Designer.cs @@ -69,12 +69,12 @@ this.labelTitle = new System.Windows.Forms.Label(); this.lblPoint = new System.Windows.Forms.Label(); this.pBoxB = new System.Windows.Forms.PictureBox(); - this.pBoxC = new System.Windows.Forms.PictureBox(); this.lblImgA = new System.Windows.Forms.Label(); this.lblImgB = new System.Windows.Forms.Label(); - this.lblImgC = new System.Windows.Forms.Label(); this.chkShowTransfBig = new System.Windows.Forms.CheckBox(); this.timerUI = new System.Windows.Forms.Timer(this.components); + this.lstView = new System.Windows.Forms.ListView(); + this.btnResetPoint = new System.Windows.Forms.Button(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pBoxA)).BeginInit(); @@ -83,7 +83,6 @@ this.groupBox2.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pBoxB)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pBoxC)).BeginInit(); this.SuspendLayout(); // // menuStrip1 @@ -212,6 +211,7 @@ // // groupBox3 // + this.groupBox3.Controls.Add(this.btnResetPoint); this.groupBox3.Controls.Add(this.lblMaxTemp); this.groupBox3.Controls.Add(this.lblMinTemp); this.groupBox3.Controls.Add(this.label6); @@ -219,7 +219,6 @@ this.groupBox3.Controls.Add(this.label7); this.groupBox3.Controls.Add(this.txtMinScale); this.groupBox3.Controls.Add(this.chkReadTemp); - this.groupBox3.Controls.Add(this.lblReadTemp); this.groupBox3.Location = new System.Drawing.Point(8, 269); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(175, 119); @@ -293,16 +292,16 @@ this.chkReadTemp.AutoSize = true; this.chkReadTemp.Location = new System.Drawing.Point(4, 19); this.chkReadTemp.Name = "chkReadTemp"; - this.chkReadTemp.Size = new System.Drawing.Size(80, 17); + this.chkReadTemp.Size = new System.Drawing.Size(83, 17); this.chkReadTemp.TabIndex = 7; - this.chkReadTemp.Text = "Set R-Point"; + this.chkReadTemp.Text = "Add R-Point"; this.chkReadTemp.UseVisualStyleBackColor = true; this.chkReadTemp.CheckedChanged += new System.EventHandler(this.chkReadTemp_CheckedChanged); // // lblReadTemp // this.lblReadTemp.AutoSize = true; - this.lblReadTemp.Location = new System.Drawing.Point(89, 20); + this.lblReadTemp.Location = new System.Drawing.Point(1185, 364); this.lblReadTemp.MinimumSize = new System.Drawing.Size(80, 0); this.lblReadTemp.Name = "lblReadTemp"; this.lblReadTemp.Size = new System.Drawing.Size(80, 13); @@ -473,7 +472,7 @@ // this.lblPoint.AutoSize = true; this.lblPoint.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblPoint.Location = new System.Drawing.Point(1104, 343); + this.lblPoint.Location = new System.Drawing.Point(1104, 316); this.lblPoint.MinimumSize = new System.Drawing.Size(170, 0); this.lblPoint.Name = "lblPoint"; this.lblPoint.Size = new System.Drawing.Size(170, 13); @@ -490,15 +489,6 @@ this.pBoxB.TabIndex = 7; this.pBoxB.TabStop = false; // - // pBoxC - // - this.pBoxC.Location = new System.Drawing.Point(954, 401); - this.pBoxC.Name = "pBoxC"; - this.pBoxC.Size = new System.Drawing.Size(320, 256); - this.pBoxC.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.pBoxC.TabIndex = 8; - this.pBoxC.TabStop = false; - // // lblImgA // this.lblImgA.AutoSize = true; @@ -519,16 +509,6 @@ this.lblImgB.TabIndex = 10; this.lblImgB.Text = "RECOLORED image"; // - // lblImgC - // - this.lblImgC.AutoSize = true; - this.lblImgC.Font = new System.Drawing.Font("Verdana", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblImgC.Location = new System.Drawing.Point(950, 375); - this.lblImgC.Name = "lblImgC"; - this.lblImgC.Size = new System.Drawing.Size(177, 23); - this.lblImgC.TabIndex = 11; - this.lblImgC.Text = "RESCALED image"; - // // chkShowTransfBig // this.chkShowTransfBig.AutoSize = true; @@ -544,19 +524,38 @@ // this.timerUI.Tick += new System.EventHandler(this.timerUI_Tick); // + // lstView + // + this.lstView.HideSelection = false; + this.lstView.Location = new System.Drawing.Point(954, 380); + this.lstView.Name = "lstView"; + this.lstView.Size = new System.Drawing.Size(311, 277); + this.lstView.TabIndex = 13; + this.lstView.UseCompatibleStateImageBehavior = false; + // + // btnResetPoint + // + this.btnResetPoint.Location = new System.Drawing.Point(120, 13); + this.btnResetPoint.Name = "btnResetPoint"; + this.btnResetPoint.Size = new System.Drawing.Size(49, 23); + this.btnResetPoint.TabIndex = 18; + this.btnResetPoint.Text = "Reset"; + this.btnResetPoint.UseVisualStyleBackColor = true; + this.btnResetPoint.Click += new System.EventHandler(this.btnResetPoint_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1290, 695); + this.Controls.Add(this.lstView); this.Controls.Add(this.chkShowTransfBig); - this.Controls.Add(this.lblImgC); this.Controls.Add(this.lblImgB); this.Controls.Add(this.lblImgA); - this.Controls.Add(this.pBoxC); this.Controls.Add(this.pBoxB); this.Controls.Add(this.pBoxA); this.Controls.Add(this.lblPoint); + this.Controls.Add(this.lblReadTemp); this.Controls.Add(this.panelCmd); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.menuStrip1); @@ -580,7 +579,6 @@ this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pBoxB)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pBoxC)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -615,10 +613,8 @@ private System.Windows.Forms.CheckBox chkReadTemp; private System.Windows.Forms.Label lblReadTemp; private System.Windows.Forms.PictureBox pBoxB; - private System.Windows.Forms.PictureBox pBoxC; private System.Windows.Forms.Label lblImgA; private System.Windows.Forms.Label lblImgB; - private System.Windows.Forms.Label lblImgC; private System.Windows.Forms.ToolStripProgressBar progBar; private System.Windows.Forms.ToolStripStatusLabel lblStats; private System.Windows.Forms.GroupBox groupBox3; @@ -634,6 +630,8 @@ private System.Windows.Forms.Label lblMaxTemp; private System.Windows.Forms.Label lblMinTemp; private System.Windows.Forms.Timer timerUI; + private System.Windows.Forms.ListView lstView; + private System.Windows.Forms.Button btnResetPoint; } } diff --git a/Thermo.Cam.Setup/MainForm.cs b/Thermo.Cam.Setup/MainForm.cs index 6dc75a8a..a99b4425 100644 --- a/Thermo.Cam.Setup/MainForm.cs +++ b/Thermo.Cam.Setup/MainForm.cs @@ -23,12 +23,16 @@ namespace Thermo.Cam.Setup /// /// Classe gestione ThermoCam (oggetti Image, metodi processing...) x FlirCam /// - protected TCContr ThermoCamCont = new TCContr(); - - protected bool userDiscoveryHelper = true; + protected TCContr ThermoCamCont = new TCContr(BASE_PATH, BASE_PATH); #endregion Protected Fields + #region Public Fields + + public static readonly string BASE_PATH = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + + #endregion Public Fields + #region Public Constructors public MainForm() @@ -42,13 +46,6 @@ namespace Thermo.Cam.Setup ThermoCamCont.eh_CameraConnStatusChanged += ImgData_eh_CameraConnStatusChanged; // cerco se ho un set di parametri giĆ  impostati... ThermoCamCont.tryReloadConf(); -#if false - // avvio l'autoconnessione - if (!string.IsNullOrEmpty(ThermoCamCont.currConf.CameraName)) - { - discoveryCamera(); - } -#endif // sistemo le conf temp setRangeTemp(); // calcolo i currConf.destPoints @@ -203,6 +200,11 @@ namespace Thermo.Cam.Setup ThermoCamCont.currConf.OrigPoints = new SetPoints(); } + private void btnResetPoint_Click(object sender, EventArgs e) + { + ThermoCamCont.resetMeasurePoints(); + } + private void btnSave_Click(object sender, EventArgs e) { ThermoCamCont.takePicture(true); @@ -269,7 +271,6 @@ namespace Thermo.Cam.Setup pBoxA.Image = showTransfBig ? ThermoCamCont.ColorTransf : ThermoCamCont.Decorated; pBoxB.Image = showTransfBig ? ThermoCamCont.Decorated : ThermoCamCont.ColorTransf; - pBoxC.Image = ThermoCamCont.GrayTransf; } } @@ -398,8 +399,8 @@ namespace Thermo.Cam.Setup } else if (readTemp) { - // x ora fisso 1 solo valore... - ThermoCamCont.saveMeasurePoint(false); + // accodo! + ThermoCamCont.saveMeasurePoint(true); // aggiorno visualizzazione processImage(); refreshDisplay(); @@ -556,7 +557,7 @@ namespace Thermo.Cam.Setup { try { - lblStats.Text = $"Camera: {ThermoCamCont.lastStatTime("ImageAcquisition")}ms | Persp {ThermoCamCont.lastStatTime("ImageTransf")}ms | Color {ThermoCamCont.lastStatTime("ImageColor")}ms | Points {ThermoCamCont.lastStatTime("AddPoints")}ms | Measures {ThermoCamCont.lastStatTime("GetAllTemperatures")}ms"; + lblStats.Text = $"Camera: {ThermoCamCont.lastStatTime("ImageAcquisition")}ms | Color + Persp {ThermoCamCont.lastStatTime("ImageColor")}ms | Points {ThermoCamCont.lastStatTime("AddPoints")}ms | Measures {ThermoCamCont.lastStatTime("GetAllTemperatures")}ms"; } catch { } diff --git a/Thermo.Cam.Utils/TCContr.cs b/Thermo.Cam.Utils/TCContr.cs index 1d8e0c14..61a2d01a 100644 --- a/Thermo.Cam.Utils/TCContr.cs +++ b/Thermo.Cam.Utils/TCContr.cs @@ -26,16 +26,15 @@ namespace Thermo.Cam.Utils protected const string dataPath = "images\\data"; protected const string imgFormat = "jpg"; protected const string thermPath = "images\\original"; - protected const string transPath = "images\\transformed"; + protected string _confBasePath = ""; + protected string _imgBasePath = ""; protected string dirDataTemp = ""; protected string dirImgColor = ""; - protected string dirImgGrTra = ""; protected string dirImgOrigi = ""; protected DiscoveryHelper DiscoThread; protected string fileColorPath = ""; protected string fileDataPath = ""; - protected string fileGrTraPath = ""; protected string fileOrigiPath = ""; /// @@ -52,8 +51,6 @@ namespace Thermo.Cam.Utils #region Public Fields - public static readonly string BASE_PATH = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - /// /// Array completo immagine /// @@ -86,13 +83,14 @@ namespace Thermo.Cam.Utils /// /// Setup oggetto e variabili /// - public TCContr() + public TCContr(string imgBasePath, string confBasePath) { + _imgBasePath = imgBasePath; + _confBasePath = confBasePath; // setup folder varie - dirDataTemp = $"{BASE_PATH}\\{dataPath}"; - dirImgColor = $"{BASE_PATH}\\{colorPath}"; - dirImgOrigi = $"{BASE_PATH}\\{thermPath}"; - dirImgGrTra = $"{BASE_PATH}\\{transPath}"; + dirDataTemp = $"{_imgBasePath}\\{dataPath}"; + dirImgColor = $"{_imgBasePath}\\{colorPath}"; + dirImgOrigi = $"{_imgBasePath}\\{thermPath}"; checkLocadOutDir(); // gestione evento discovery camera! @@ -130,7 +128,7 @@ namespace Thermo.Cam.Utils string answ = confFileName; if (!Path.IsPathRooted(answ)) { - answ = BASE_PATH + "\\" + confFileName; + answ = _confBasePath + "\\" + confFileName; } return answ; } @@ -155,11 +153,6 @@ namespace Thermo.Cam.Utils /// public Bitmap Decorated { get; set; } - /// - /// Ultima immagine post trasformazione (perspective) - /// - public Bitmap GrayTransf { get; set; } - /// /// Ultima bitmap acquisita /// @@ -197,10 +190,6 @@ namespace Thermo.Cam.Utils { Directory.CreateDirectory(dirImgOrigi); } - if (!Directory.Exists(dirImgGrTra)) - { - Directory.CreateDirectory(dirImgGrTra); - } } private void DiscoThread_eh_CameraFound(object sender, EventArgs e) @@ -240,7 +229,9 @@ namespace Thermo.Cam.Utils } } catch (Exception exc) - { } + { + Console.WriteLine($"EXCEPTION: {exc}"); + } } private void Image_Changed(object sender, Flir.Atlas.Image.ImageChangedEventArgs e) @@ -324,15 +315,8 @@ namespace Thermo.Cam.Utils { try { - // genero immagine BN sw.Restart(); var pTransf = new PerspTrans(currConf.OrigPoints.Coords, currConf.DestPoints.Coords); - var transfImg = pTransf.convertImage(Origin, currConf.TargetSize.X, currConf.TargetSize.Y); - GrayTransf = transfImg; - sw.Stop(); - ExTime.recordData("ImageTransf", sw.ElapsedMilliseconds); - - sw.Restart(); var rTrasf = new ReColorize(currConf.TargetRange.Min, currConf.TargetRange.Max); // ora calcolo ricolorazione da immagine originale var colImg = rTrasf.process(Origin, lastFlirData.Values); @@ -344,6 +328,7 @@ namespace Thermo.Cam.Utils } catch (Exception exc) { + Console.WriteLine($"EXCEPTION: {exc}"); } } } @@ -457,7 +442,6 @@ namespace Thermo.Cam.Utils fileDataPath = $"{dirDataTemp}\\{fileName}.{dataFormat}"; fileColorPath = $"{dirImgColor}\\{fileName}.{imgFormat}"; fileOrigiPath = $"{dirImgOrigi}\\{fileName}.{imgFormat}"; - fileGrTraPath = $"{dirImgGrTra}\\{fileName}.{imgFormat}"; // se trovo i files... if (File.Exists(fileOrigiPath)) @@ -501,7 +485,9 @@ namespace Thermo.Cam.Utils } } catch (Exception exc) - { } + { + Console.WriteLine($"EXCEPTION: {exc}"); + } } return answ; @@ -523,13 +509,10 @@ namespace Thermo.Cam.Utils fileDataPath = $"{dirDataTemp}\\{currName}.{dataFormat}"; fileColorPath = $"{dirImgColor}\\{currName}.{imgFormat}"; fileOrigiPath = $"{dirImgOrigi}\\{currName}.{imgFormat}"; - fileGrTraPath = $"{dirImgGrTra}\\{currName}.{imgFormat}"; // salvo thermo! Thermal.Scale.IsAutoAdjustEnabled = true; Thermal.SaveSnapshot(fileOrigiPath); - // salvo trasformata - GrayTransf.Save(fileGrTraPath); // salvo colorata ColorTransf.Save(fileColorPath); @@ -541,12 +524,13 @@ namespace Thermo.Cam.Utils string uniqueName = $"{DateTime.Now:yyyyMMdd_HHmmss}"; File.Copy(fileOrigiPath, fileOrigiPath.Replace(currName, uniqueName)); File.Copy(fileColorPath, fileColorPath.Replace(currName, uniqueName)); - File.Copy(fileGrTraPath, fileGrTraPath.Replace(currName, uniqueName)); File.Copy(fileDataPath, fileDataPath.Replace(currName, uniqueName)); answ = uniqueName; } catch (Exception exc) - { } + { + Console.WriteLine($"EXCEPTION: {exc}"); + } return answ; } @@ -574,7 +558,9 @@ namespace Thermo.Cam.Utils ExTime.recordData("GetPoints", sw.ElapsedMilliseconds); } catch (Exception exc) - { } + { + Console.WriteLine($"EXCEPTION: {exc}"); + } } } } @@ -648,6 +634,14 @@ namespace Thermo.Cam.Utils ExTime.recordData("GetAllTemperatures", sw.ElapsedMilliseconds); } + /// + /// Resetta i punti di misura + /// + public void resetMeasurePoints() + { + currConf.MeasPoints = new List(); + } + /// /// Calcola punti con antitrasformata prospettica /// @@ -763,7 +757,9 @@ namespace Thermo.Cam.Utils } } catch (Exception exc) - { } + { + Console.WriteLine($"EXCEPTION: {exc}"); + } } } }