原创|产品更新|编辑:李显亮|2020-06-18 09:54:00.507|阅读 373 次
概述:Aspose.OCR for .NET更新至最新版v20.6,添加了对使用流的API支持,添加了指定字符以进行识别的功能,改善了识别质量,欢迎下载体验。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
Aspose.OCR for .NET是一款字符识别组件,它使得开发人员可以添加OCR功能到他们的ASP.NET Web应用程序、web服务和windows应用程序中。它提供了一个简单的类集用于控制字符识别。
Aspose.OCR for .NET迎来2020年v20.6最新版更新,添加了对使用流的API支持,添加了指定字符以进行识别的功能,改善了识别质量。(点击下方按钮即可下载)
| space | ! | " | # | $ | % | & | ' | ( | ) |
| * | + | , | - | . | / | 0 | 1 | 2 | 3 |
| 4 | 5 | 6 | 7 | 8 | 9 | : | ; | < | = |
|---|---|---|---|---|---|---|---|---|---|
| > | ? | @ | [ | \ | ] | _ | ` | { | | |
| } | ~ | A | B | C | D | E | F | G | H |
| I | J | K | L | M | N | O | P | Q | R |
| S | T | U | V | W | X | Y | Z | a | b |
| c | d | e | f | g | h | i | j | k | l |
| m | n | o | p | q | r | s | t | u | v |
| w | x | y | z | Â | À | Á | Ã | Ä | Æ |
| Ç | È | É | Ê | Ë | Ì | Í | Î | Ï | Ñ |
| Ò | Ó | Ô | Õ | Ö | Ù | Ú | Û | Ü | ẞ |
| ß | à | á | â | ã | ä | æ | ç | è | é |
| ê | ë | ì | í | î | ï | ñ | ò | ó | ô |
| õ | ö | ù | ú | û | ü | ÿ | Œ | œ | Ÿ |
|
方法
|
描述
|
|---|---|
| string RecognizeImage(MemoryStream stream) | 通过自动检测文本区域来识别图像,并检测,纠正文本偏斜。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。stream-图像的MemoryStream。 |
| string RecognizeImage(string fullPath) | 通过自动检测文本区域来识别图像,并检测,纠正文本偏斜。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。fullPath-图像的路径。 |
| List RecognizeImage(MemoryStream stream, List rects) | 识别指定矩形中的文本。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。不会发生歪斜对齐。stream-图像的MemoryStream。rects-用于识别的以像素为单位的矩形列表。 |
| string RecognizeImage(MemoryStream stream, Rectangle rects) | 识别指定矩形中的文本。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。不会发生歪斜对齐。stream-图像的MemoryStream。rects-以像素为单位的矩形,用于识别。 |
| List RecognizeImage(string fullPath, List rects) | 识别指定矩形中的文本。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。不会发生歪斜对齐。fullPath-图像的路径。rects-用于识别的以像素为单位的矩形列表。 |
| string RecognizeImage(string fullPath, Rectangle rects) | 识别指定矩形中的文本。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。不会发生歪斜对齐。fullPath-图像的路径。rects-以像素为单位的矩形,用于识别。 |
| string RecognizeImage(MemoryStream stream, bool detectAreas, bool autoSkew = true) | 识别带有或不带有自动检测文本区域的图像,并根据参数校正文本的偏斜。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。stream-图像的MemoryStream。detectAreas-自动检测文本区域。如果为假,则图像被视为一个文本块。autoSkew-删除歪斜图像。默认值-true。 |
| string RecognizeImage(string fullPath, bool detectAreas, bool autoSkew = true) | 识别带有或不带有自动检测文本区域的图像,并根据参数校正文本的偏斜。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。fullPath-图像的路径。detectAreas-自动检测文本区域。如果为假,则图像被视为一个文本块。autoSkew-删除歪斜图像。默认值-true。 |
| string RecognizeLine(MemoryStream stream) | 识别仅包含一行文本的图像。不会发生歪斜对齐。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。stream-图像的MemoryStream。 |
| string RecognizeLine(string fullPath) | 识别仅包含一行文本的图像。不会发生歪斜对齐。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。fullPath-图像的路径。 |
| float CalculateSkew(MemoryStream image) | 计算图像中文本的倾斜角(以度为单位)。image-图像的MemoryStream。 |
| float CalculateSkew(string fullPath) | 计算图像中文本的倾斜角(以度为单位)。fullPath-图像的路径。 |
| List GetRectangles(MemoryStream stream) | 获取带有文本区域的检测矩形。不会发生歪斜对齐。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。stream-图像的MemoryStream。 |
| List GetRectangles(string fullPath) | 获取带有文本区域的检测矩形。不会发生歪斜对齐。支持GIF,PNG,JPEG,BMP,TIFF和WBMP。fullPath-图像的路径 |
| License() | 构造函数。创建一个许可证实例。 |
| AsposeOcr(string alphabet) | 构造函数。创建一个API实例,并在字母表中设置允许的字符集。 |
| AsposeOCR() | 构造函数。创建一个API实例。 |
| void SetLicense(string licenseName) | licenseName-xml许可证文件的路径。 |
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using Aspose.OCR;
namespace ProgramOCR
{
class Program
{
static void Main(string[] args)
{
// Get API
AsposeOcr api = new AsposeOcr();
// Create license
License lic = new License();
// Set license
lic.SetLicense("Aspose.Total.lic");
// Get image for recognize
string imgPath = "test_ocr.png";
/* Recognize image from file*/
// Recognize image
string result = api.RecognizeImage(imgPath);
// Print result
Console.WriteLine(result);
/* Recognize image from stream*/
using (MemoryStream ms = new MemoryStream())
using (FileStream file = new FileStream(imgPath, FileMode.Open, FileAccess.Read))
{
file.CopyTo(ms);
result = api.RecognizeImage(ms);
}
Console.WriteLine(result);
/*Recognize image from file without detected texts areas and remove skew
(all image is a text area) */
result = api.RecognizeImage(imgPath, false);
Console.WriteLine(result);
/*Recognize image from file with detected texts areas and without
remove skew text*/
result = api.RecognizeImage(imgPath, true, false);
Console.WriteLine(result);
/* Recognize image in the specified rectangles */
List<Rectangle> rects = new List<Rectangle>()
{
new Rectangle(138, 352, 2033, 537),
new Rectangle(147, 890, 2033, 1157),
new Rectangle(923, 2045, 465, 102),
new Rectangle(104, 2147, 2076, 819)
};
List<string> listResult = api.RecognizeImage(imgPath, rects);
foreach (string s in listResult)
{
Console.WriteLine(s);
}
/* Recognize image in the specified rectangle */
result = api.RecognizeImage(imgPath, rects[0]);
Console.WriteLine(result);
/* With allowed symbols*/
// Create api instance with allowed symbols.
api = new AsposeOcr("0123456789");
// Get image line for recognize
imgPath = "0002240177.Jpeg";
// Recognize line
result = api.RecognizeLine(imgPath);
Console.WriteLine(result);
/* Calculate skew image from stream */
imgPath = "skew_image.png";
float angle = 0;
using (MemoryStream ms = new MemoryStream())
using (FileStream file = new FileStream(imgPath, FileMode.Open, FileAccess.Read))
{
file.CopyTo(ms);
angle = api.CalculateSkew(ms);
}
Console.WriteLine(angle);
/* Calculate skew image from path to image */
angle = api.CalculateSkew(imgPath);
Console.WriteLine(angle);
}
}
}
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@ke049m.cn