Add LibDataBase
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TetraPackOCR
|
||||
{
|
||||
/// <summary>
|
||||
/// 点
|
||||
/// </summary>
|
||||
class Point
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
public string txt;
|
||||
public Point(int x, int y,string txt)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.txt = txt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TetraPackOCR
|
||||
{
|
||||
internal class OCRTextResult
|
||||
{
|
||||
public bool match;
|
||||
public string text;
|
||||
public List<PointF[]> points = new List<PointF[]>();
|
||||
}
|
||||
}
|
||||
@@ -276,8 +276,6 @@
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="HPoint.cs" />
|
||||
<Compile Include="OCRTextResult.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
@@ -327,6 +325,16 @@
|
||||
<None Include="Resources\ON.png" />
|
||||
<None Include="Resources\OFF.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LibDataBase\LibDataBase.csproj">
|
||||
<Project>{d03a85cc-a53b-4434-a560-7a89563292e8}</Project>
|
||||
<Name>LibDataBase</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\LibReadTetraExcel\LibReadTetraExcel.csproj">
|
||||
<Project>{b88b2fa9-0d9d-4ebb-a87a-4de2dc2dd70f}</Project>
|
||||
<Name>LibReadTetraExcel</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user