当前位置:网站首页>【OCR】AspriseOCR C# 英文、数字识别(中文不行)
【OCR】AspriseOCR C# 英文、数字识别(中文不行)
2022-06-12 14:11: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
边栏推荐
- 注重点击,追求更多用户进入网站,可以选择什么出价策略?
- Player practice 26 adding slider and window maximization
- SystemC:SC_ Thread and SC_ METHOD
- [video lesson] a full set of tutorials on the design and production of Android studio Internet of things app -- all mastered during the National Day
- Backtracking: Prime Rings
- chapter19 Allocation
- Player actual combat 22 to solve the problems of flower screen and Caton
- Lua callinfo structure, stkid structure resolution
- Visual studio common shortcuts
- Write policy of cache
猜你喜欢

Alicloud development board vscode development environment setup

Dismantle and modify the advertising machine - Amateur decompression

Printing colored messages on the console with printf

【活动早知道】LiveVideoStack近期活动一览

如何使用android studio制作一个阿里云物联网APP

TestEngine with ID ‘junit-vintage‘ failed to discover tests

Player practice 15 xdemux and avcodecparameters

Tcp/ip network communication knowledge record

Program analysis and Optimization - 6 loop optimization

C語言中主函數調用另外一個函數,匯編代碼理解
随机推荐
Llvm pass-- virtual function protection
Program analysis and Optimization - 6 loop optimization
拆改广告机---业余解压
Player practice 17 xvideowidget
[video lesson] a full set of tutorials on the design and production of Android studio Internet of things app -- all mastered during the National Day
Introduction to functions (inline functions and function overloading)
Pay attention to click and pursue more users to enter the website. What bidding strategy can you choose?
QA of some high frequency problems in oauth2 learning
公司运营中更注重转化的出价策略,如何实现? —Google sem
测试工程师如何转型测开
Lua common built-in functions
TestEngine with ID ‘junit-vintage‘ failed to discover tests
Mold and remainder
OAuth2学习中的一些高频问题的QA
Dynamic search advertising intelligent search for matching keywords
肝了一个月的原创小袁个人博客项目开源啦(博客基本功能都有,还包含后台管理)
Knowledge of wireless card driver
Socket model of punctual atom stm32f429 core board
chrome://tracing Performance analysis artifact
To SystemC Beginners: the first program