Windows phone 8 Windows Phone 8 WP8上的OCR
我是编程界的新手,正在尝试开发一款使用OCR的应用程序。 我希望应用程序将一张单数收据转换成文本(没有什么太复杂) 然而,我的问题是,我发现WP8上缺少OCR的信息,以及如何实现它。 我认为这是WP的一个内置功能,可以很容易地获取关于如何实现它的信息 有人知道我可以去哪里看,或者我可以使用的一段简单的代码示例吗?Windows phone 8 Windows Phone 8 WP8上的OCR,windows-phone-8,ocr,Windows Phone 8,Ocr,我是编程界的新手,正在尝试开发一款使用OCR的应用程序。 我希望应用程序将一张单数收据转换成文本(没有什么太复杂) 然而,我的问题是,我发现WP8上缺少OCR的信息,以及如何实现它。 我认为这是WP的一个内置功能,可以很容易地获取关于如何实现它的信息 有人知道我可以去哪里看,或者我可以使用的一段简单的代码示例吗? 不需要基于订阅的服务。Microsoft最近发布了用于Windows运行时的OCR库。杰瑞·尼克松发布了一段视频,引导你浏览,还有一篇msdn文章 您可以尝试使用Bing镜头使用的相
不需要基于订阅的服务。Microsoft最近发布了用于Windows运行时的OCR库。杰瑞·尼克松发布了一段视频,引导你浏览,还有一篇msdn文章
您可以尝试使用Bing镜头使用的相同OCR服务。若你们还并没有试过:打开相机,把镜头换成bing镜头,然后试一下 服务端点是。它还提供有关检测到的文本及其边界框的位置的信息 可能一些fiddler分析会帮助您以类似的方式发送图像 下面我有一个小片段,希望图像是字节数组
public static readonly string ocrServiceUrl = "http://ocrrest.bingvision.net/V1"; // was: "platform.bing.com/ocr/V1";
public static readonly string ocrLanguage = "en";
public static async Task<JsonObject> MakeOcrJSON(byte[] image)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format("{0}/Recognize/{1}", ocrServiceUrl, ocrLanguage));
request.Method = "POST";
using (Stream requestStream = await request.GetRequestStreamAsync())
{
requestStream.Write(image, 0, image.Length);
}
try
{
using (HttpWebResponse response = (HttpWebResponse) (await request.GetResponseAsync()))
{
using (var responseStream = new StreamReader(response.GetResponseStream()))
{
var json = JsonObject.Parse(responseStream.ReadToEnd());
return json;
}
}
}
catch (WebException we)
{
using (Stream responseStream = we.Response.GetResponseStream())
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(OcrResponse));
OcrResponse ocrResponse = (OcrResponse)serializer.ReadObject(responseStream);
string ErrorMessage = "Unknown Error";
if (ocrResponse.OcrFault.HasValue)
{
ErrorMessage = string.Format(
"HTTP status code: {0} Message: {1}",
ocrResponse.OcrFault.Value.HttpStatusCode,
ocrResponse.OcrFault.Value.Message);
}
throw new Exception(ErrorMessage);
}
}
}
公共静态只读字符串ocrServiceUrl=”http://ocrrest.bingvision.net/V1"; // was:“platform.bing.com/ocr/V1”;
公共静态只读字符串ocrLanguage=“en”;
公共静态异步任务MakeorJSON(字节[]图像)
{
HttpWebRequest request=(HttpWebRequest)WebRequest.Create(string.Format(“{0}/Recognize/{1}”,ocrServiceUrl,ocrLanguage));
request.Method=“POST”;
使用(Stream requestStream=await request.GetRequestStreamAsync())
{
Write(image,0,image.Length);
}
尝试
{
使用(HttpWebResponse=(HttpWebResponse)(wait request.GetResponseAsync())
{
使用(var responseStream=newstreamreader(response.GetResponseStream()))
{
var json=JsonObject.Parse(responseStream.ReadToEnd());
返回json;
}
}
}
catch(WebException-we)
{
使用(Stream responseStream=we.Response.GetResponseStream())
{
DataContractJsonSerializer serializer=新的DataContractJsonSerializer(typeof(OcrResponse));
OcrResponse=(OcrResponse)serializer.ReadObject(responseStream);
string ErrorMessage=“未知错误”;
if(ocrResponse.OcrFault.HasValue)
{
ErrorMessage=string.Format(
“HTTP状态代码:{0}消息:{1}”,
ocrResponse.OcrFault.Value.HttpStatusCode,
ocrResponse.OcrFault.Value.Message);
}
抛出新异常(ErrorMessage);
}
}
}
Windows phone 8不支持任何OCR API。您可以尝试一些外部库。看看-@SadAlAbdullah,请将此作为答案,添加支持您答案的Microsoft声明,这样我们就可以结束了。