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

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D03A85CC-A53B-4434-A560-7A89563292E8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LibDataBase</RootNamespace>
<AssemblyName>LibDataBase</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TextPoint.cs" />
<Compile Include="OCRTextResult.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -5,9 +5,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TetraPackOCR
namespace LibDataBase
{
internal class OCRTextResult
public class OCRTextResult
{
public bool match;
public string text;

View File

@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("LibDataBase")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("LibDataBase")]
[assembly: AssemblyCopyright("Copyright © HP 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("d03a85cc-a53b-4434-a560-7a89563292e8")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,24 +1,21 @@
using System;
using System.Collections.Generic;
namespace TetraPackOCR
namespace LibDataBase
{
/// <summary>
/// 点
/// </summary>
class Point
public class TextPoint
{
public int x;
public int y;
public string txt;
public Point(int x, int y,string txt)
public TextPoint(int x, int y,string txt)
{
this.x = x;
this.y = y;
this.txt = txt;
}
}
}

View File

@@ -62,5 +62,11 @@
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibDataBase\LibDataBase.csproj">
<Project>{d03a85cc-a53b-4434-a560-7a89563292e8}</Project>
<Name>LibDataBase</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

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);

View File

@@ -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>

View File

@@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dll", "Dll", "{C0079401-F42
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibReadTetraExcel", "LibReadTetraExcel\LibReadTetraExcel.csproj", "{B88B2FA9-0D9D-4EBB-A87A-4DE2DC2DD70F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibDataBase", "LibDataBase\LibDataBase.csproj", "{D03A85CC-A53B-4434-A560-7A89563292E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -43,12 +45,21 @@ Global
{B88B2FA9-0D9D-4EBB-A87A-4DE2DC2DD70F}.Release|Any CPU.Build.0 = Release|Any CPU
{B88B2FA9-0D9D-4EBB-A87A-4DE2DC2DD70F}.Release|x64.ActiveCfg = Release|Any CPU
{B88B2FA9-0D9D-4EBB-A87A-4DE2DC2DD70F}.Release|x64.Build.0 = Release|Any CPU
{D03A85CC-A53B-4434-A560-7A89563292E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D03A85CC-A53B-4434-A560-7A89563292E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D03A85CC-A53B-4434-A560-7A89563292E8}.Debug|x64.ActiveCfg = Debug|x64
{D03A85CC-A53B-4434-A560-7A89563292E8}.Debug|x64.Build.0 = Debug|x64
{D03A85CC-A53B-4434-A560-7A89563292E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D03A85CC-A53B-4434-A560-7A89563292E8}.Release|Any CPU.Build.0 = Release|Any CPU
{D03A85CC-A53B-4434-A560-7A89563292E8}.Release|x64.ActiveCfg = Release|Any CPU
{D03A85CC-A53B-4434-A560-7A89563292E8}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B88B2FA9-0D9D-4EBB-A87A-4DE2DC2DD70F} = {C0079401-F420-4256-B991-3BF16D3296C7}
{D03A85CC-A53B-4434-A560-7A89563292E8} = {C0079401-F420-4256-B991-3BF16D3296C7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F550CA1D-FC09-446C-B501-170B642AAC00}