当前位置:网站首页>【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 actual combat 13 create qtopengl project to promote window control and reload qoopenglwedge
- Copy word content to excel and automatically divide it into multiple columns
- Player actual combat 12 QT playing audio
- [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
- 什么是自动出价?它的优势是什么?
- 程序分析与优化 - 6 循环优化
- 1414. minimum number of Fibonacci numbers with sum K
- Create a small root heap and judge the node relationship (also.C\u str() substr(),atoi(),string. Use of find())
- IAT hook hijacking process API call
- PostgreSQL14安装使用教程
猜你喜欢

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

Player practice 26 adding slider and window maximization

Program analysis and Optimization - 6 loop optimization

动态搜索广告智能查找匹配关键字

Player actual combat 25 unpacking module add close

What is automatic bidding? What are its advantages?

Player practice 18 xresample

Mémoire de l'examen d'entrée à l'université

高考回憶錄

Reverse the encryption parameters of a hot water software
随机推荐
Player practice 19 xaudio turn on audio
Notepad common settings
English learning plan
肝了一个月的原创小袁个人博客项目开源啦(博客基本功能都有,还包含后台管理)
Communication flow analysis
Wait function in SystemC
Player practice 20 unpacking thread
How test engineers transform test and open
Program analysis and Optimization - 6 loop optimization
基于Profibus-DP协议的PLC智能从站设计
Implementation and debug of process hiding under x64
高考回憶錄
如何使用android studio制作一个阿里云物联网APP
[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
Player practice 26 adding slider and window maximization
Lua tvalue structure
2000. reverse word prefix
After reading the question, you will point to offer 16 Integer power of numeric value
Alibaba cloud development board haas510 connects to the Internet of things platform -- Haas essay solicitation
Analysis of lua source code