sample code commit

main
syneffort 2 years ago
parent 992620e1ce
commit eecfcc25fa
  1. 25
      TessaractTest/TessaractTest.sln
  2. 88
      TessaractTest/TessaractTest/Form1.Designer.cs
  3. 29
      TessaractTest/TessaractTest/Form1.cs
  4. 60
      TessaractTest/TessaractTest/Form1.resx
  5. 17
      TessaractTest/TessaractTest/Program.cs
  6. 19
      TessaractTest/TessaractTest/TessaractTest.csproj
  7. BIN
      TessaractTest/TessaractTest/tessdata/eng.traineddata
  8. BIN
      TessaractTest/TessaractTest/tessdata/kor.traineddata
  9. BIN
      TessaractTest/TessaractTest/tessdata/kor_vert.traineddata

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TessaractTest", "TessaractTest\TessaractTest.csproj", "{18BB9C99-2707-4B65-B535-DED2B3EEC55E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{18BB9C99-2707-4B65-B535-DED2B3EEC55E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18BB9C99-2707-4B65-B535-DED2B3EEC55E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18BB9C99-2707-4B65-B535-DED2B3EEC55E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18BB9C99-2707-4B65-B535-DED2B3EEC55E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9B216018-EAF3-4280-AEBE-2C97FCD6DD6A}
EndGlobalSection
EndGlobal

@ -0,0 +1,88 @@
namespace TessaractTest
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnLoad = new System.Windows.Forms.Button();
this.tbxMain = new System.Windows.Forms.TextBox();
this.pbxMain = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pbxMain)).BeginInit();
this.SuspendLayout();
//
// btnLoad
//
this.btnLoad.Location = new System.Drawing.Point(12, 12);
this.btnLoad.Name = "btnLoad";
this.btnLoad.Size = new System.Drawing.Size(75, 23);
this.btnLoad.TabIndex = 0;
this.btnLoad.Text = "Load";
this.btnLoad.UseVisualStyleBackColor = true;
this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
//
// tbxMain
//
this.tbxMain.Location = new System.Drawing.Point(346, 41);
this.tbxMain.Multiline = true;
this.tbxMain.Name = "tbxMain";
this.tbxMain.ReadOnly = true;
this.tbxMain.Size = new System.Drawing.Size(328, 356);
this.tbxMain.TabIndex = 1;
//
// pbxMain
//
this.pbxMain.Location = new System.Drawing.Point(12, 41);
this.pbxMain.Name = "pbxMain";
this.pbxMain.Size = new System.Drawing.Size(328, 356);
this.pbxMain.TabIndex = 2;
this.pbxMain.TabStop = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(683, 406);
this.Controls.Add(this.pbxMain);
this.Controls.Add(this.tbxMain);
this.Controls.Add(this.btnLoad);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pbxMain)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Button btnLoad;
private TextBox tbxMain;
private PictureBox pbxMain;
}
}

@ -0,0 +1,29 @@
using Tesseract;
namespace TessaractTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnLoad_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() != DialogResult.OK)
return;
string filePath = dlg.FileName;
pbxMain.Load(filePath);
pbxMain.SizeMode = PictureBoxSizeMode.Zoom;
Pix pix = Pix.LoadFromFile(filePath);
TesseractEngine ocr = new TesseractEngine("./tessdata", "kor", EngineMode.Default);
Page page = ocr.Process(pix);
tbxMain.Text = page.GetText();
}
}
}

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -0,0 +1,17 @@
namespace TessaractTest
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Tesseract" Version="5.2.0" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="mkdir &quot;$(SolutionDir)$(SolutionName)\$(OutDir)tessdata&quot;&#xD;&#xA;copy &quot;$(SolutionDir)$(SolutionName)\tessdata\&quot; &quot;$(SolutionDir)$(SolutionName)\$(OutDir)tessdata\&quot;&#xD;&#xA;" />
</Target>
</Project>
Loading…
Cancel
Save