copia img unique +code cleanup (2 test...)

This commit is contained in:
Samuele E. Locatelli
2021-02-15 20:17:52 +01:00
parent f073e37254
commit 134f891f03
2 changed files with 10 additions and 141 deletions
-140
View File
@@ -54,17 +54,6 @@ namespace ThermalImageStreamerDemo
protected double msLastCam = 0;
#if false
protected double msLastMsr = 0;
protected double msLastPts = 0;
protected double msLastCol = 0;
protected double msLastTra = 0;
protected Point refTempPoint = new Point();
#endif
protected Stopwatch sw = new Stopwatch();
#endregion Protected Fields
@@ -440,56 +429,6 @@ namespace ThermalImageStreamerDemo
IRCam.ThermoCamera.Dispose();
}
#if false
private void drawCrossAtPoints()
{
if (ImgData.Thermal != null)
{
sw.Restart();
// se ho dei punti x trasformazione --> disegno
if (currConf.origPoints.curr > 0)
{
foreach (var item in currConf.origPoints.Coords)
{
drawPoint(Color.Green, item);
}
}
// se ho punto acquisizione temp --> disegno!
if (refTempPoint != null)
{
drawPoint(Color.Blue, refTempPoint);
}
sw.Stop();
msLastPts = sw.ElapsedMilliseconds;
}
}
private void drawPoint(Color currColor, Point currPoint)
{
// disegno!
using (Graphics gr = Graphics.FromImage(ImgData.Decorated))
{
gr.SmoothingMode = SmoothingMode.AntiAlias;
Point[] crsPoints = new Point[4];
for (int i = 0; i < 4; i++)
{
crsPoints[i] = currPoint;
}
crsPoints[0].X = crsPoints[0].X - 4;
crsPoints[1].X = crsPoints[1].X + 4;
crsPoints[2].Y = crsPoints[2].Y - 4;
crsPoints[3].Y = crsPoints[3].Y + 4;
using (Pen thick_pen = new Pen(currColor, 1))
{
gr.DrawLine(thick_pen, crsPoints[0], crsPoints[1]);
gr.DrawLine(thick_pen, crsPoints[2], crsPoints[3]);
}
}
}
#endif
private void Image_Changed(object sender, Flir.Atlas.Image.ImageChangedEventArgs e)
{
IsDirty = true;
@@ -655,28 +594,6 @@ namespace ThermalImageStreamerDemo
return answ;
}
#if false
private void saveImgFile()
{
try
{
// fix percorsi
string dirPath = $"{BASE_PATH}\\{thermPath}";
string filePath = $"{dirPath}\\{currImgFile}";
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}
// salvo!
ImgData.Thermal.Scale.IsAutoAdjustEnabled = true;
ImgData.Thermal.SaveSnapshot(filePath);
var rawData = JsonConvert.SerializeObject(ImgData.Thermal, Formatting.Indented);
}
catch
{ }
}
#endif
/// <summary>
/// Sistema le temp range min/Max
/// </summary>
@@ -686,44 +603,6 @@ namespace ThermalImageStreamerDemo
currConf.TargetRange.Max = maxRangeTemp;
}
#if false
/// <summary>
/// Ultimo range di temperature osservato
/// </summary>
protected Range<double> lastTempRange
{
get
{
return _lastTempRange;
}
set
{
_lastTempRange = value;
lblMinTemp.Text = $"{value.Minimum:N2}";
lblMaxTemp.Text = $"{value.Maximum:N2}";
}
}
#endif
#if false
private void getTemperatures()
{
if (ImgData.Thermal != null)
{
lastReadTemp = 0;
if (readTemp)
{
// recupero temp da FLIR
lastReadTemp = ImgData.Thermal.GetValueAt(ImgData.lastPoint).Value;
// calcolo temp da RGB considerato limiti minMAX...
//int rgbVal = ImgData.lastImageOrig.Image.GetPixel(ImgData.lastPoint.X, ImgData.lastPoint.Y).R;
int rgbVal = getRSmooth(ImgData.lastPoint);
lastCalcTemp = lastTempRange.Minimum + ((lastTempRange.Maximum - lastTempRange.Minimum) * rgbVal / 255);
}
}
}
#endif
/// <summary>
/// recupera immagine effettuando eventuale salvataggio
/// </summary>
@@ -738,15 +617,6 @@ namespace ThermalImageStreamerDemo
IRCam.ThermoCamera.GetImage().EnterLock();
try
{
// non funziona
#if false
// se richiesto imposto temperature min/max...
if (!chkAutoTemp.Checked)
{
Range<double> limits = new Range<double>(273.1 + minTemp, 273.1 + maxTemp);
IRCam.ThermoCamera.RemoteControl.CameraSettings.SetScaleLimits(limits);
}
#endif
ImgData.Thermal = (ThermalImage)IRCam.ThermoCamera.GetImage();
ImgData.Thermal.TemperatureUnit = TemperatureUnit.Celsius;
ImgData.Thermal.Scale.IsAutoAdjustEnabled = true;
@@ -755,9 +625,6 @@ namespace ThermalImageStreamerDemo
ImgData.Decorated = ImgData.Thermal.Image;
if (doSave)
{
#if false
saveImgFile();
#endif
ImgData.saveImgFiles();
}
}
@@ -772,13 +639,6 @@ namespace ThermalImageStreamerDemo
sw.Stop();
msLastCam = sw.ElapsedMilliseconds;
#if false
ThermalImage myImg = (ThermalImage)_stream.GetImage();
myImg.TemperatureUnit = TemperatureUnit.Celsius;
string currPath = $"{labelOutputPath.Text}\\{DateTime.Now:yyyyMMyy_HHmmss}.jpg";
myImg.SaveSnapshot(currPath);
#endif
}
/// <summary>
+10 -1
View File
@@ -290,8 +290,9 @@ namespace ThermoCamUtils
}
}
public void saveImgFiles()
public string saveImgFiles()
{
string answ = "";
try
{
// fix percorsi
@@ -320,9 +321,17 @@ namespace ThermoCamUtils
// salvo colorata
ColorTransf.Save(colorFilePath);
// copia immagine con nome univoco da rendere a liberia x eventuale salvataggio in area PROD...
string uniqueName = $"{DateTime.Now:yyyyMMdd_HHmmss}";
File.Copy(themoFilePath, themoFilePath.Replace(currImgFile, uniqueName));
File.Copy(themoDataPath, themoDataPath.Replace(currImgFile, uniqueName));
File.Copy(colorFilePath, colorFilePath.Replace(currImgFile, uniqueName));
answ = uniqueName;
}
catch
{ }
return answ;
}
/// <summary>