如何在ASP.Net MVC4 Web API项目中使用Microsoft OCR库(Microsoft.Windows.Ocr)? [英] How to use Microsoft OCR Library ( Microsoft.Windows.Ocr ) in an ASP.Net MVC4 Web API Project?

查看:503
本文介绍了如何在ASP.Net MVC4 Web API项目中使用Microsoft OCR库(Microsoft.Windows.Ocr)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人知道引用服务器端ASP.Net Web应用程序(例如MV4 Web API)上的Microsoft.Windows.Ocr(/WindowsPreview.Media.Ocr.dll)程序集的方法,并利用该程序集中的OCR功能来获取照片图像作为输入并从中提取文本内容? 如果是,请在您的答案中提供详细的说明.

Does anyone know of a way to reference Microsoft.Windows.Ocr (/ WindowsPreview.Media.Ocr.dll ) Assembly on a server-side ASP.Net Web application like MV4 Web API and make use of the OCR Functionality in that assembly to take a photo image as input and extract the text content out of it ? If yes, please provide detailed instructions in your answer.

我正在构建一个Web应用程序,该应用程序将图像上传到服务器(通过文件上传UI屏幕),然后使用 OCR 读取文本,并在下一页上显示该文本,到上传的图像.

I am building a web application that takes an image uploaded to the Server (via a file upload UI screen) and then reads the text using OCR and displays the text on the next page, right next to the image that was uploaded.

由于大多数商业OCR图书馆都花了一定的时间和精力(我上次检查的费用超过1300美元)我以为我可以尝试使用免费且似乎是

Since most commercial OCR Libraries cost an arm and length (over $1,300 last time I checked) I thought I can try and use the Microsoft OCR Library Microsoft.Windows.Ocr that is FREE and seems to be very simple and straightforward to use.

因此,我尝试将 Microsoft.Windows.Ocr Nuget软件包安装到我的ASP.Net MVC4 Web API项目中,并成功.

So I tried to install the Microsoft.Windows.Ocr Nuget Package to my ASP.Net MVC4 Web API Project and that succeeded.

此后,我浏览了我的《 MVC4 Web API项目参考》,令我惊讶的是,没有找到对 Microsoft.Windows.Ocr.dll 程序集的引用.

After that, I looked through my MVC4 Web API Project References, and to my surprise, did not find a reference to Microsoft.Windows.Ocr.dll Assembly.

因此,然后我尝试通过浏览到\packages文件夹中的该程序集,并添加对Microsoft.Windows.Ocr.dll程序集的x86版本的引用,然后选择 WindowsPreview.Media.Ocr.dll \lib\win81\x86文件夹

So then I tried to add a reference to the x86 version of the Microsoft.Windows.Ocr.dll Assembly by browsing to that Assembly in the \packages folder, and selected the WindowsPreview.Media.Ocr.dll from \lib\win81\x86 folder

注意::程序集名称为WindowsPreview.Media.Ocr.dll,而不是Microsoft.Windows.Ocr.dll,不确定原因!

Note: The Assembly name is WindowsPreview.Media.Ocr.dll and not Microsoft.Windows.Ocr.dll , not sure why!

当我这样做并单击确定时,我收到以下错误消息.

When I did that and clicked OK, I got the following Error Message.

---------------------------
Microsoft Visual Studio
---------------------------
A reference to   
'D:\TestProjects\packages\Microsoft.Windows.Ocr.1.0.0\lib\win81\x86\
 WindowsPreview.Media.Ocr.dll' could not be added. Please make sure 
 that the file is accessible, and that it is a valid assembly 
 or COM component.
---------------------------
OK   
---------------------------

然后我从 Nuget页面中发现支持的平台"仅是 Windows Phone 8,Windows Phone 8.1,Windows 8.1(仅Windows Store应用程序).

I then found out from the Nuget Page that the "Supported Platforms" are only Windows Phone 8, Windows Phone 8.1, Windows 8.1 (Windows Store apps only).

但是可以肯定的是,必须有一种方法可以在ASP.Net应用程序的服务器端使用此 OCR dll 吗?

But surely, there must be a way to use this OCR dll on the Server-side in an ASP.Net Application?

任何"hacks"和/或示例代码将不胜感激!

Any "hacks" and/or Sample code would be much appreciated!!

谢谢!

推荐答案

如果您使用的是Visual Studio 2015和Windows 10,则

If you are using Visual Studio 2015 and Windows 10, the

Microsoft.Windows.Ocr

Microsoft.Windows.Ocr

已被移至通用Windows平台.它可以作为

has been moved to Universal Windows Platform. It is available as

Windows.Media.Ocr

Windows.Media.Ocr

因此,您需要使用已启用Windows 10的工具来升级VS 2015.

So you need to upgrade your VS 2015 with tools for Windows 10 enabled.

我做了以下事情,并且在我的Web API中添加了Windows.Media.Ocr作为参考.

I did the following and Windows.Media.Ocr got added as a reference in my Web API.

  1. 在您的Web API项目的引用中,右键单击任何引用,然后单击在对象浏览器中查看".您的对象浏览器将如下所示
  2. 浏览:所有组件"框旁边有一个"..."按钮.工具提示显示为编辑自定义组件集".单击!
  3. 在编辑自定义组件集"框中,单击浏览"选项卡,然后导航到"C:/Program Files(x86)/Windows Kits/10/References/Windows.Foundation.UniversalApiContract/1.0.0.0" 并单击生成的winmd文件,然后单击添加".
  4. 好吧!
  5. 现在单击显示为添加到解决方案资源管理器中选定项目中的引用中"的图标(这是浏览:"旁边的"..."按钮中的第三个按钮).您可以看到Windows.Media.Ocr可以使用.
  1. In your Web API project's references right click any of the references and click View in Object Browser. Your Object browser will look something like this
  2. There is a '...' button right next to the "Browse: All components" Box. The tooltip reads "Edit Custom Component set".Click!
  3. In the "Edit Custom Component Set" Box click the Browse Tab and Navigate to "C:/Program Files(x86)/Windows Kits/10/References/Windows.Foundation.UniversalApiContract/1.0.0.0" and click the winmd file that results and click Add.
  4. Hit Ok!
  5. Now click icon that reads "Add to references in Selected Project in Solution Explorer"(It is the third button from the '...' button next to "Browse:"). You can see that Windows.Media.Ocr is available to use.

注意:以下内容仅适用于VS 2015和Windows10.也应针对以获取示例OCR.

Note: The following works only with VS 2015 and windows 10. That too VS 2015 should be updated for Universal Windows Platform(UWP). Check this for a sample OCR.

希望这会有所帮助. 更新 它已导入我的参考中,但是无法加载.希望它能为人们提供一些起点. 谢谢!.

Hope this helps. Update It got imported into my reference but is failing to load though. Hope it provides some start for people. Thanks!.

这篇关于如何在ASP.Net MVC4 Web API项目中使用Microsoft OCR库(Microsoft.Windows.Ocr)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆