spostato metodi ricalcolo img in classe libreria
This commit is contained in:
@@ -130,7 +130,17 @@ namespace ThermalImageStreamerDemo
|
||||
}
|
||||
}
|
||||
|
||||
protected ThermoCamConf currConf { get; set; } = new ThermoCamConf();
|
||||
protected ThermoCamConf currConf
|
||||
{
|
||||
get
|
||||
{
|
||||
return ImgData.currConf;
|
||||
}
|
||||
set
|
||||
{
|
||||
ImgData.currConf = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected int dimX
|
||||
{
|
||||
@@ -138,10 +148,12 @@ namespace ThermalImageStreamerDemo
|
||||
{
|
||||
int answ = 100;
|
||||
int.TryParse(txtAB.Text, out answ);
|
||||
currConf.TargetSize.X = answ;
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
currConf.TargetSize.X = value;
|
||||
txtAB.Text = $"{value}";
|
||||
}
|
||||
}
|
||||
@@ -152,10 +164,12 @@ namespace ThermalImageStreamerDemo
|
||||
{
|
||||
int answ = 100;
|
||||
int.TryParse(txtBC.Text, out answ);
|
||||
currConf.TargetSize.Y = answ;
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
currConf.TargetSize.Y = value;
|
||||
txtBC.Text = $"{value}";
|
||||
}
|
||||
}
|
||||
@@ -181,12 +195,14 @@ namespace ThermalImageStreamerDemo
|
||||
{
|
||||
get
|
||||
{
|
||||
double answ = 0;
|
||||
double answ = 1000;
|
||||
double.TryParse(txtMaxScale.Text, out answ);
|
||||
currConf.TargetRange.Max = answ;
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
currConf.TargetRange.Max = value;
|
||||
txtMaxScale.Text = $"{value:N0}";
|
||||
}
|
||||
}
|
||||
@@ -197,10 +213,12 @@ namespace ThermalImageStreamerDemo
|
||||
{
|
||||
double answ = 0;
|
||||
double.TryParse(txtMinScale.Text, out answ);
|
||||
currConf.TargetRange.Min = answ;
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
currConf.TargetRange.Min = value;
|
||||
txtMinScale.Text = $"{value:N0}";
|
||||
}
|
||||
}
|
||||
@@ -322,6 +340,8 @@ namespace ThermalImageStreamerDemo
|
||||
/// </summary>
|
||||
private void calculateTarget()
|
||||
{
|
||||
ImgData.calculateTarget(chkParallel.Checked, chkRevProc.Checked);
|
||||
#if false
|
||||
if (ImgData.Thermal != null)
|
||||
{
|
||||
try
|
||||
@@ -358,6 +378,7 @@ namespace ThermalImageStreamerDemo
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Camera_ConnectionStatusChanged(object sender, Flir.Atlas.Live.ConnectionStatusChangedEventArgs e)
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ThermoCamUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Gestione tempi esecuzione
|
||||
/// </summary>
|
||||
public class ExecTime
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario statistiche tempi di esecuzione
|
||||
/// </summary>
|
||||
public Dictionary<string, double> Stats = new Dictionary<string, double>();
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Memorizza dato statistiche
|
||||
/// </summary>
|
||||
/// <param name="taskName"></param>
|
||||
/// <param name="timeMs"></param>
|
||||
public void recordData(string taskName, double timeMs)
|
||||
{
|
||||
// facico upsert statistiche...
|
||||
if (Stats.ContainsKey(taskName))
|
||||
{
|
||||
Stats[taskName] = timeMs;
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats.Add(taskName, timeMs);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Flir.Atlas.Image;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -13,6 +14,29 @@ namespace ThermoCamUtils
|
||||
/// </summary>
|
||||
public class ImageData
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Ultimo range di temperature osservato
|
||||
/// </summary>
|
||||
protected Range<double> lastTempRange = new Range<double>(0, 5000);
|
||||
|
||||
/// <summary>
|
||||
/// Stopwatch x benchmarking
|
||||
/// </summary>
|
||||
protected Stopwatch sw = new Stopwatch();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Statistiche esecuzione task
|
||||
/// </summary>
|
||||
public ExecTime ExTime = new ExecTime();
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
@@ -20,6 +44,8 @@ namespace ThermoCamUtils
|
||||
/// </summary>
|
||||
public Bitmap ColorTransf { get; set; }
|
||||
|
||||
public ThermoCamConf currConf { get; set; } = new ThermoCamConf();
|
||||
|
||||
/// <summary>
|
||||
/// Ultima bitmap disegnata (con punti)
|
||||
/// </summary>
|
||||
@@ -44,6 +70,51 @@ namespace ThermoCamUtils
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua calcolo e display immagine target
|
||||
/// </summary>
|
||||
/// <param name="fastBitmap">Indica se processare bitmap in memoria (true) o con metodi standard (false)</param>
|
||||
/// <param name="colorizeFirst">Indica se prima fare falsi colori poi trasformazione proiettiva</param>
|
||||
public void calculateTarget(bool fastBitmap, bool colorizeFirst)
|
||||
{
|
||||
if (Thermal != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
//lastTempRange = new Range<double>(lastThermalImage.GetValueFromSignal(lastThermalImage.MinSignalValue), lastThermalImage.GetValueFromSignal(lastThermalImage.MaxSignalValue));
|
||||
lastTempRange = new Range<double>(Thermal.Scale.Range.Minimum, Thermal.Scale.Range.Maximum);
|
||||
|
||||
sw.Restart();
|
||||
var pTransf = new PerspectiveTransform(currConf.origPoints.Coords, currConf.destPoints.Coords);
|
||||
var rTrasf = new ReColorize(lastTempRange.Minimum, lastTempRange.Maximum, currConf.TargetRange.Min, currConf.TargetRange.Max);
|
||||
var transfImg = pTransf.convertImage(Origin, currConf.TargetSize.X, currConf.TargetSize.Y);
|
||||
GrayTransf = transfImg;
|
||||
sw.Stop();
|
||||
ExTime.recordData("ImageTransf", sw.ElapsedMilliseconds);
|
||||
|
||||
sw.Restart();
|
||||
if (colorizeFirst)
|
||||
{
|
||||
// ora calcolo ricolorazione da immagine originale
|
||||
var colImg = rTrasf.process(Origin, fastBitmap);
|
||||
// e faccio la stessa trasformazione di riscalatura
|
||||
var transfColImg = pTransf.convertImage(colImg, currConf.TargetSize.X, currConf.TargetSize.Y);
|
||||
ColorTransf = transfColImg;
|
||||
}
|
||||
else
|
||||
{
|
||||
// old way da immagine BN full size
|
||||
ColorTransf = rTrasf.process(GrayTransf, fastBitmap);
|
||||
}
|
||||
sw.Stop();
|
||||
ExTime.recordData("ImageColor", sw.ElapsedMilliseconds);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init iniziale immagini
|
||||
/// </summary>
|
||||
|
||||
@@ -9,7 +9,11 @@ namespace ThermoCamUtils
|
||||
{
|
||||
public class SetPoints
|
||||
{
|
||||
public int curr { get; set; } = 0;
|
||||
#region Public Properties
|
||||
|
||||
public List<Point> Coords { get; set; } = new List<Point>();
|
||||
public int curr { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Flir.Atlas.Live.Discovery;
|
||||
using Flir.Atlas.Image;
|
||||
using Flir.Atlas.Live.Discovery;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -7,20 +8,69 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ThermoCamUtils
|
||||
{
|
||||
public class ThermoCamConf
|
||||
public class RangeVal
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// VAlore MASSIMO
|
||||
/// </summary>
|
||||
public double Max { get; set; } = 50;
|
||||
|
||||
/// <summary>
|
||||
/// Valore minimo
|
||||
/// </summary>
|
||||
public double Min { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Size
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dimensione X
|
||||
/// </summary>
|
||||
public int X { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Dimensione X
|
||||
/// </summary>
|
||||
public int Y { get; set; } = 100;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class ThermoCamConf
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Camera selezionata x autoconnect ("" = nessun autoconnect)
|
||||
/// </summary>
|
||||
public string CameraName { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Punti su IMG origine
|
||||
/// </summary>
|
||||
public SetPoints origPoints { get; set; } = new SetPoints();
|
||||
|
||||
/// <summary>
|
||||
/// Punti su IMG destinazione
|
||||
/// </summary>
|
||||
public SetPoints destPoints { get; set; } = new SetPoints();
|
||||
|
||||
/// <summary>
|
||||
/// Punti su IMG origine
|
||||
/// </summary>
|
||||
public SetPoints origPoints { get; set; } = new SetPoints();
|
||||
|
||||
/// <summary>
|
||||
/// Range scala colori desiderata
|
||||
/// </summary>
|
||||
public RangeVal TargetRange { get; set; } = new RangeVal();
|
||||
|
||||
/// <summary>
|
||||
/// Target (transformed & colored) image size
|
||||
/// </summary>
|
||||
public Size TargetSize { get; set; } = new Size();
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ExecTime.cs" />
|
||||
<Compile Include="IRCam.cs" />
|
||||
<Compile Include="ImageData.cs" />
|
||||
<Compile Include="ThermoCamConf.cs" />
|
||||
|
||||
Reference in New Issue
Block a user