因爲公司最近的軟件項目設備選型是windows 8平板電腦,開發Windows app store上的Metro應用,該應用要實現客戶名片識別的功能,即便用平板電腦上的攝像頭給客戶的名片拍照,應用能即時可識別該客戶名片上的信息,並自動輸入應用中,網上看了一大堆的資料,國內的開發商提供的接口服務費都過高了,動輒就要幾十萬。國外有個免費的,這個就是ABBYY Cloud OCR SDK,但ABBYY Cloud OCR SDK的名片識別接口沒有js的接口。它只提供了C#語言和iPhone的例子。這樣須要在服務器上用C#作一個轉換的方法。由平板向服務器發送客戶名片的照片,服務器再向ABBYY Cloud OCR SDK的名片識別接口發出識別請求,服務器接收到識別結果再向平板返回結果了。windows
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"); } }
附:
一、 ocrsdk名片識別的接口:[POST] http(s)://cloud.ocrsdk.com/processBusinessCardapp
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.iphone
[POST] http(s)://cloud.ocrsdk.com/processBusinessCard
The image file is transmitted in the request body.ui
二、 C#語言的例子
http://ocrsdk.com/documentation/quick-start/cs/spa
三、 iPhone的例子
http://ocrsdk.com/documentation/quick-start/iphone-ocr-sdk/rest