Add LibDataBase

This commit is contained in:
2025-12-23 10:35:27 +08:00
parent 2a6e5cb0d0
commit fed944a3cf
8 changed files with 143 additions and 19 deletions

View File

@@ -38,6 +38,7 @@ using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Forms;
using ThridLibray;
using LibDataBase;
namespace TetraPackOCR
{
@@ -1230,14 +1231,14 @@ namespace TetraPackOCR
#endregion
#region
List<Point> paixu(List<Point> points)
List<TextPoint> paixu(List<TextPoint> points)
{
int rowDistance = 50;
List<List<Point>> rows = new List<List<Point>>();
List<List<TextPoint>> rows = new List<List<TextPoint>>();
for (int i = 0; i < points.Count; i++)
{
List<Point> row = new List<Point>();
List<TextPoint> row = new List<TextPoint>();
row.Add(points[i]);
for (int j = i + 1; j < points.Count; j++)
@@ -1250,12 +1251,12 @@ namespace TetraPackOCR
rows.Add(row);
}
List<Point> sortedPoints = new List<Point>();
List<TextPoint> sortedPoints = new List<TextPoint>();
foreach (List<Point> row in rows)
foreach (List<TextPoint> row in rows)
{
row.Sort((x, y) => x.x - y.x);
foreach (Point point in row)
foreach (TextPoint point in row)
{
if (!sortedPoints.Contains(point))
{
@@ -1460,18 +1461,18 @@ namespace TetraPackOCR
OCRTextResult result = new OCRTextResult();
List<string> lastocr = new List<string>();
OCRResult ocrResult = Engine.DetectText(ocrimagebyte);
List<Point> pointsList = new List<Point>();
List<TextPoint> pointsList = new List<TextPoint>();
foreach (var item in ocrResult.TextBlocks)
{
if (item.Text.Contains(ocrTextDesign[mMatchingStr]))
{
result.points.Add(item.BoxPoints.Select(x => new PointF() { X = x.X, Y = x.Y }).ToArray());
pointsList.Add(new Point(item.BoxPoints[0].X, item.BoxPoints[0].Y, item.Text));
pointsList.Add(new TextPoint(item.BoxPoints[0].X, item.BoxPoints[0].Y, item.Text));
}
}
List<Point> paixujeguo = paixu(pointsList);
List<TextPoint> paixujeguo = paixu(pointsList);
foreach (var it in paixujeguo)
{
lastocr.Add(it.txt);