当前位置:网站首页>【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
边栏推荐
- C語言中主函數調用另外一個函數,匯編代碼理解
- Backtracking: Prime Rings
- How to use Android studio to create an Alibaba cloud Internet of things app
- Shell notes
- 什么是自动出价?它的优势是什么?
- 正点原子STM32F429核心板的插座型号
- Unhandled exception stack overflow
- Codeforces Round #798 (Div. 2)(A~D)
- 3. Hidden processes under the ring
- 对于跨境电商,更侧重收入的出价策略 —Google SEM
猜你喜欢
Create a small root heap and judge the node relationship (also.C\u str() substr(),atoi(),string. Use of find())
Perfect ending | detailed explanation of the implementation principle of go Distributed Link Tracking
Player actual combat 21 audio and video synchronization
Player practice 20 audio thread and video thread
正点原子STM32F429核心板的插座型号
注重点击,追求更多用户进入网站,可以选择什么出价策略?
If you want to build brand awareness, what bidding strategy can you choose?
Player practice 26 adding slider and window maximization
Now you must know the pointer
Greed issues - Egypt scores
随机推荐
Redis core configuration and advanced data types
Alibaba cloud development board haas510 parses serial port JSON data and sends attributes
Leetcode questions brushing February /1020 Number of enclaves
In C language, the main function calls another function, which is understood by assembly code
浅谈中国程序员为什么要跳槽?
注重点击,追求更多用户进入网站,可以选择什么出价策略?
Notepad common settings
Player practice 26 adding slider and window maximization
Remote code injection
Player actual combat 16 xdecode class
Reverse the encryption parameters of a hot water software
SystemC:SC_ Thread and SC_ METHOD
工具笔记 —— 常用自定义工具类(正则,随机数等)
基于Profibus-DP协议的PLC智能从站设计
[advanced MySQL] query optimization principle and scheme (6)
Program analysis and Optimization - 6 loop optimization
Lua tvalue structure
初学者入门阿里云haas510开板式DTU(2.0版本)--510-AS
Dynamic search advertising intelligent search for matching keywords
【MySQL】数据库基本操作