You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
|
|
namespace qingdaoport
|
|
|
|
|
{
|
|
|
|
|
public class OcrDemo
|
|
|
|
|
{
|
|
|
|
|
Baidu.Aip.Ocr.Ocr client = new Baidu.Aip.Ocr.Ocr(MsSysParamSetDAL.GetData("PARAMNAME='CLOUDBAIDUOCRApi'").PARAMVALUE, MsSysParamSetDAL.GetData("PARAMNAME='CLOUDBAIDUOCRSec'").PARAMVALUE);
|
|
|
|
|
public JToken GeneralBasic(string filename)
|
|
|
|
|
{
|
|
|
|
|
var image = File.ReadAllBytes(filename);
|
|
|
|
|
System.Threading.Thread.Sleep(400);
|
|
|
|
|
// 通用文字识别
|
|
|
|
|
return client.GeneralBasic(image);//通用文字识别 500次/天
|
|
|
|
|
//return client.AccurateBasic(image);//通用文字识别含位置信息版 500次/天
|
|
|
|
|
}
|
|
|
|
|
public JToken GeneralBasicDemo(string path)
|
|
|
|
|
{
|
|
|
|
|
var image = File.ReadAllBytes(path);
|
|
|
|
|
// 可选参数
|
|
|
|
|
var options = new Dictionary<string, object>{
|
|
|
|
|
{"detect_direction", "false"},
|
|
|
|
|
{"probability", "true"},
|
|
|
|
|
{"language_type", "ENG"},
|
|
|
|
|
{"detect_language","true" }
|
|
|
|
|
};
|
|
|
|
|
System.Threading.Thread.Sleep(400);
|
|
|
|
|
// 带参数调用通用文字识别, 图片参数为远程url图片
|
|
|
|
|
return client.GeneralBasic(image, options);//通用文字识别 500次/天
|
|
|
|
|
//return client.AccurateBasic(image, options);//通用文字识别含位置信息版 500次/天
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|