当前位置:网站首页>【OCR】AspriseOCR C# 英文、數字識別(中文不行)
【OCR】AspriseOCR C# 英文、數字識別(中文不行)
2022-06-12 14:20:00 【十年一夢實驗室】

原圖
一、AspriseOCR 4.0 破解版

識別效果

x86
C#源碼
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace ToText
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region DllImport
[DllImport("AspriseOCR.dll", EntryPoint = "OCR", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr OCR(string file, int type);
[DllImport("AspriseOCR.dll", EntryPoint = "OCRpart", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height);
[DllImport("AspriseOCR.dll", EntryPoint = "OCRBarCodes", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr OCRBarCodes(string file, int type);
[DllImport("AspriseOCR.dll", EntryPoint = "OCRpartBarCodes", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr OCRpartBarCodes(string file, int type, int startX, int startY, int width, int height);
#endregion
#region 轉換按鈕事件
// 轉換按鈕事件
private void button2_Click(object sender, EventArgs e)
{
int startX = 0;
int startY = 0;
int width = -1;
int height = -1;
string img_path = txt_imgpath.Text; // 圖片路徑
if (String.IsNullOrEmpty(img_path)) // 圖片非空驗證
{
MessageBox.Show("請先選擇圖片!");
return;
}
try
{
Image img = Image.FromFile(img_path);
width = img.Width;
height = img.Height;
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace);
}
txt_result.Text = Marshal.PtrToStringAnsi(OCRpart(img_path, -1, startX, startY, width, height));
}
#endregion
#region 瀏覽事件
// 瀏覽事件
private void btn_imgpath_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
txt_imgpath.Text = openFileDialog1.FileName;
}
// 瀏覽圖片
private void txt_imgpath_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
txt_imgpath.Text = openFileDialog1.FileName;
}
#endregion
}
}
二、AspriseOCR 15.3



識別效果(x64)
源碼:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using asprise_ocr_api;
namespace ToText
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region DllImport
[DllImport("AspriseOCR.dll", EntryPoint = "OCR", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr OCR(string file, int type);
[DllImport("AspriseOCR.dll", EntryPoint = "OCRpart", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height);
[DllImport("AspriseOCR.dll", EntryPoint = "OCRBarCodes", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr OCRBarCodes(string file, int type);
[DllImport("AspriseOCR.dll", EntryPoint = "OCRpartBarCodes", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr OCRpartBarCodes(string file, int type, int startX, int startY, int width, int height);
#endregion
#region 轉換按鈕事件
// 轉換按鈕事件
private void button2_Click(object sender, EventArgs e)
{
int startX = 0;
int startY = 0;
int width = -1;
int height = -1;
string img_path = txt_imgpath.Text; // 圖片路徑
if (String.IsNullOrEmpty(img_path)) // 圖片非空驗證
{
MessageBox.Show("請先選擇圖片!");
return;
}
try
{
Image img = Image.FromFile(img_path);
width = img.Width;
height = img.Height;
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace);
}
// txt_result.Text = Marshal.PtrToStringAnsi(OCRpart(img_path, -1, startX, startY, width, height));
AspriseOCR.SetUp();
AspriseOCR ocr = new AspriseOCR();
ocr.StartEngine("eng", AspriseOCR.SPEED_FASTEST);
string s = ocr.Recognize(img_path, -1, -1, -1, -1, -1, AspriseOCR.RECOGNIZE_TYPE_ALL, AspriseOCR.OUTPUT_FORMAT_PLAINTEXT);
ocr.StopEngine();
txt_result.Text = s;
}
#endregion
#region 瀏覽事件
// 瀏覽事件
private void btn_imgpath_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
txt_imgpath.Text = openFileDialog1.FileName;
}
// 瀏覽圖片
private void txt_imgpath_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
txt_imgpath.Text = openFileDialog1.FileName;
}
#endregion
}
}
參考:
LanTenggit/orc: orc圖片識別(MODI) (github.com)
https://github.com/LanTenggit/orc
边栏推荐
- Mémoire de l'examen d'entrée à l'université
- QT multi thread drawing and real-time refreshing method
- Reverse the encryption parameters of a hot water software
- Vs2012: cannot assign a value of type 'char *' to an entity of type 'lpwstr'
- 通信流量分析
- C語言中主函數調用另外一個函數,匯編代碼理解
- Compile and install lamp architecture of WordPress and discuz for multi virtual hosts based on fastcgi mode
- chapter19 Allocation
- 单总线温度传感器18B20数据上云(阿里云)
- Player actual combat 22 to solve the problems of flower screen and Caton
猜你喜欢

Alicloud development board vscode development environment setup

Server concurrency - note 1

En langage C, la fonction principale appelle une autre fonction et assemble le Code pour comprendre

Player practice 11 audio resampling

Lua callinfo structure, stkid structure resolution

C語言中主函數調用另外一個函數,匯編代碼理解

通信流量分析

Redis data deletion policy in 2022

华为设备配置BGP AS号替换

In C language, the main function calls another function, which is understood by assembly code
随机推荐
Wait function in SystemC
Analysis of two-dimensional array passing as function parameter (C language)
Display logs in the database through loganalyzer
Notepad common settings
C語言中主函數調用另外一個函數,匯編代碼理解
Llvm pass-- virtual function protection
CSDN博客积分规则
Ppt cannot be opened, always prompt how to fix it
基于Profibus-DP协议的PLC智能从站设计
Getting started alicloud haas510 open board DTU (version 2.0) --510-as
Alicloud development board vscode development environment setup
Write policy of cache
Player actual combat 21 audio and video synchronization
IAT hook hijacking process API call
Player actual combat 23 decoding thread
En langage C, la fonction principale appelle une autre fonction et assemble le Code pour comprendre
Implementation and debug of process hiding under x64
chrome://tracing Performance analysis artifact
公司运营中更注重转化的出价策略,如何实现? —Google sem
If you want to build brand awareness, what bidding strategy can you choose?