1.創(chuàng)建文字識別項目
去百度智能云官網(wǎng),找到文字識別并創(chuàng)建項目,獲取AK和SK
t3.jpg
2.vs中nuget下載
image.png
3.編寫代碼
public string ExtractText(string image)
{ //image為圖片的路徑
var api_key = "你的AK";
var secret_key = "你的SK";
var client = new Baidu.Aip.Ocr.Ocr(api_key, secret_key);
client.Timeout = 60000;
var img = System.IO.File.ReadAllBytes(image);
var result = client.GeneralBasic(img).ToString();
Console.WriteLine(result);
return result;
}
4.測試結果
image.png