您的位置:首页 > 其它

ABBYY Cloud OCR SDK的名片识别接口

2013-09-30 11:01 507 查看
由于公司最近的软件项目设备选型是windows 8平板电脑,开发Windows app store上的Metro应用,该应用要实现客户名片识别的功能,即使用平板电脑上的摄像头给客户的名片拍照,应用能即时可识别该客户名片上的信息,并自动输入应用中,网上看了一大堆的资料,国内的开发商提供的接口服务费都太高了,动辄就要几十万。国外有个免费的,这个就是ABBYY Cloud OCR SDK,但ABBYY Cloud OCR SDK的名片识别接口没有js的接口。它只提供了C#语言和iPhone的例子。这样需要在服务器上用C#做一个转换的方法。由平板向服务器发送客户名片的照片,服务器再向ABBYY Cloud OCR SDK的名片识别接口发出识别请求,服务器接收到识别结果再向平板返回结果了。

C#的请求识别代码:

public void ProcessFile(string sourceFilePath, string outputFileBase, ProcessingSettings settings)
{
Console.WriteLine("Uploading to www.fenhon.com ...");
Task task = restClient.ProcessImage(sourceFilePath, settings);

TaskId taskId = task.Id;

while (true)
{
task = restClient.GetTaskStatus(taskId);
if (!Task.IsTaskActive(task.Status))
break;

Console.WriteLine(String.Format("Task status: {0}", task.Status));
System.Threading.Thread.Sleep(1000);
}

if (task.Status == TaskStatus.Completed)
{
Console.WriteLine("Processing completed.");
for (int i = 0; i < settings.OutputFormats.Count; i++)
{
var outputFormat = settings.OutputFormats[i];
string ext = settings.GetOutputFileExt(outputFormat);
restClient.DownloadUrl(task.DownloadUrls[i], outputFileBase + ext);
}
Console.WriteLine("Download completed.");
}
else if (task.Status == TaskStatus.NotEnoughCredits)
{
Console.WriteLine("Not enough credits to process the file. Please add more pages to your application balance.");
}
else
{
Console.WriteLine("Error while processing the task");
}
}


附:
1、 ocrsdk名片识别的接口:[POST] http(s)://cloud.ocrsdk.com/processBusinessCard

processBusinessCard Method
The method allows you to recognize a business card on an image. The method loads the image, creates a processing task for the image with the specified parameters, and passes the task for processing.

[POST] http(s)://cloud.ocrsdk.com/processBusinessCard
The image file is transmitted in the request body.

2、 C#语言的例子 http://ocrsdk.com/documentation/quick-start/cs/
3、 iPhone的例子 http://ocrsdk.com/documentation/quick-start/iphone-ocr-sdk/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: