Version Error Message

Using pattern ...
Tests passed
2023-01-24
Bug in yml
dotnet tool
PackageReference arrangement
nuget ^
Assembly Version
Not verified
Infineon.EAF.Runtime 2.49.0
MesEntity Placeholder
Not Tested
connectionCount
AssemblyVersion
SRP2100 = 53, //Largest
Better errror message
v2.49.2
IDescription.GetDescriptions with body
Viewer support
tasks.json
kanbn initialize
WSRequest alignment
Back to x64
mesfs.infineon.com
Infineon.EAF.Runtime 2.49.3
pool name
Kanban
net8.0
v2_52_0-Tests
editorconfig
dotnet_diagnostic
CA1862 and GetWeekOfYear for WritePDSF
gitignore
cellInstanceVersion.EdaConnection.PortNumber
Added Climatec to Test.cs
GetJobIdDirectory
Remove and
5-Other-Small
mesfs.infineon.com
Infineon.EAF.Runtime 2.49.3
pool name
Kanban
Back to x64
IDescription.GetDescriptions with body
Viewer support
tasks.json
kanbn initialize
WSRequest alignment
v2.49.2
Better errror message
SRP2100 = 53, //Largest
AssemblyVersion
connectionCount
MesEntity Placeholder
Infineon.EAF.Runtime 2.49.0
Assembly Version
dotnet tool
2023-01-24
This commit is contained in:
2024-05-22 07:49:57 -07:00
parent c32489b040
commit 255ccf4280
73 changed files with 2069 additions and 966 deletions

View File

@ -7,8 +7,10 @@ using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Tesseract;
namespace Adaptation.FileHandlers.jpeg;
@ -32,8 +34,6 @@ public class ProcessData : IProcessData
public ProcessData(IFileRead fileRead, Logistics logistics, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY, Size size, List<Tuple<string, Color[]>> colorCollections)
{
if (logistics is null)
{ }
JobID = logistics.JobID;
fileInfoCollection.Clear();
_Details = new List<object>();
@ -330,4 +330,157 @@ public class ProcessData : IProcessData
return results;
}
#pragma warning disable CA1416
private static MemoryStream GetMemoryStream(System.Drawing.Imaging.ImageFormat imageFormat, Bitmap bitmap, int startX, int startY, int endX, int endY, int offSetX, int offSetY)
{
Color color;
int negitiveGrayScale;
MemoryStream result = new();
int startXValue = startX + offSetX;
int startYValue = startY + offSetY;
int endXValue = endX + offSetX;
int endYValue = endY + offSetY;
using Bitmap selectedBitmap = new(endXValue - startXValue, endYValue - startYValue);
for (int x = startXValue; x < endXValue; x++)
{
for (int y = startYValue; y < endYValue; y++)
{
color = bitmap.GetPixel(x, y);
negitiveGrayScale = 255 - (int)((color.R * 0.3) + (color.G * 0.59) + (color.B * 0.11));
if (negitiveGrayScale < 162)
selectedBitmap.SetPixel(x - startXValue, y - startYValue, Color.FromArgb(color.A, 0, 0, 0));
else
selectedBitmap.SetPixel(x - startXValue, y - startYValue, Color.FromArgb(color.A, 255, 255, 255));
}
}
selectedBitmap.Save(result, imageFormat);
return result;
}
private static List<MemoryStream> GetMemoryStreams(string reportFullPath, string extension)
{
List<MemoryStream> results = new();
System.Drawing.Imaging.ImageFormat imageFormat = Get(extension);
using Bitmap? bitmap = Image.FromFile(reportFullPath) as Bitmap;
if (bitmap is null)
throw new Exception($"Couldn't load image from <{reportFullPath}>");
results.Add(GetMemoryStream(imageFormat, bitmap, 6, 130, 791, 953, 0, 0));
results.Add(GetMemoryStream(imageFormat, bitmap, 48, 795, 359, 869, 0, 0));
results.Add(GetMemoryStream(imageFormat, bitmap, 376, 814, 430, 832, 0, 0));
results.Add(GetMemoryStream(imageFormat, bitmap, 373, 793, 433, 874, 0, 0));
return results;
}
public static List<(float, string, List<string>)> Parse(string reportFullPath)
{
List<(float, string, List<string>)> results = new();
string text;
float pageMeanConfidence;
MemoryStream memoryStream;
List<string> blocks = new();
const string extension = ".tiff";
StringBuilder stringBuilder = new();
using TesseractEngine engine = new(string.Empty, "eng", EngineMode.Default);
List<MemoryStream> memoryStreams = GetMemoryStreams(reportFullPath, extension);
for (int i = 0; i < memoryStreams.Count; i++)
{
_ = stringBuilder.Clear();
memoryStream = memoryStreams[i];
using Pix img = Pix.LoadFromMemory(memoryStream.GetBuffer());
using Page page = engine.Process(img);
text = page.GetText();
pageMeanConfidence = page.GetMeanConfidence();
using ResultIterator iter = page.GetIterator();
iter.Begin();
do
{
do
{
do
{
do
{
_ = stringBuilder.Append(iter.GetText(PageIteratorLevel.Word)).Append(' ');
if (iter.IsAtFinalOf(PageIteratorLevel.TextLine, PageIteratorLevel.Word) && stringBuilder.Length > 0)
{
blocks.Add(stringBuilder.ToString());
_ = stringBuilder.Clear();
}
} while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word));
if (iter.IsAtFinalOf(PageIteratorLevel.Para, PageIteratorLevel.TextLine))
_ = stringBuilder.AppendLine();
} while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine));
} while (iter.Next(PageIteratorLevel.Block, PageIteratorLevel.Para));
} while (iter.Next(PageIteratorLevel.Block));
if (stringBuilder.Length > 0)
blocks.Add(stringBuilder.ToString());
results.Add(new(pageMeanConfidence, text, blocks));
// if (!fileRead.IsEAFHosted)
// {
// fileInfoCollection.Add(new FileInfo(saveFileName));
SaveToFile(extension, $"{reportFullPath}{i}{extension}", memoryStream);
// }
}
return results;
}
#pragma warning restore CA1416
public static (float, string, List<string>) Parse(string reportFullPath, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY)
{
(float, string, List<string>) result;
List<string> blocks = new();
StringBuilder stringBuilder = new();
using TesseractEngine engine = new(string.Empty, "eng", EngineMode.Default);
using Pix img = Pix.LoadFromFile(reportFullPath);
using Page page = engine.Process(img);
string text = page.GetText();
float pageMeanConfidence = page.GetMeanConfidence();
using ResultIterator iter = page.GetIterator();
iter.Begin();
do
{
do
{
do
{
do
{
_ = stringBuilder.Append(iter.GetText(PageIteratorLevel.Word)).Append(' ');
if (iter.IsAtFinalOf(PageIteratorLevel.TextLine, PageIteratorLevel.Word) && stringBuilder.Length > 0)
{
blocks.Add(stringBuilder.ToString());
_ = stringBuilder.Clear();
}
} while (iter.Next(PageIteratorLevel.TextLine, PageIteratorLevel.Word));
if (iter.IsAtFinalOf(PageIteratorLevel.Para, PageIteratorLevel.TextLine))
_ = stringBuilder.AppendLine();
} while (iter.Next(PageIteratorLevel.Para, PageIteratorLevel.TextLine));
} while (iter.Next(PageIteratorLevel.Block, PageIteratorLevel.Para));
} while (iter.Next(PageIteratorLevel.Block));
if (stringBuilder.Length > 0)
blocks.Add(stringBuilder.ToString());
result = new(pageMeanConfidence, text, blocks);
return result;
}
private void Parse(IFileRead fileRead, List<FileInfo> fileInfoCollection, int startX, int startY, int endX, int endY, int offSetX, int offSetY)
{
(float pageMeanConfidence, string text, List<string> blocks) = Parse(fileRead.ReportFullPath, fileInfoCollection, startX, startY, endX, endY, offSetX, offSetY);
_Log.Debug(string.Format("Mean confidence: {0}", pageMeanConfidence));
_Log.Debug(string.Format("Text (GetText): \r\n{0}", text));
_Log.Debug("Text (iterator):");
if (blocks.Count == 0)
_Details.Add(text);
else
{
blocks = (from l in blocks where l.Split(':').Length == 3 select l).ToList();
if (blocks.Count == 0)
_Details.Add(text);
else
_Details.Add(blocks[0]);
}
}
}