资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
eoLinker-API Shop OCR-车车牌牌识别识别 C#调调用示例代用示例代码码OCR-车车牌牌识别识别车牌识别服务能自动地从图片中定位车牌图片区域,识别出其中包含的车牌信息。该产该产品品拥拥有以下有以下APIs: :1.车牌识别注意,注意,该该示例代示例代码仅码仅适用于适用于 www.apishop.net 网站下网站下API 使用使用该产该产品前,您需要通品前,您需要通过过 https:/www.apishop.net/#/api/detail/?productID=207 申申请请API服服务务1.车车牌牌识别识别 using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Text; using System.Web.Script.Serialization;namespace apishop_sdk class Program/* 转发请求到目的主机* param method string 请求方法* param url string 请求地址* param params Dictionary 请求参数* param headers Dictionary 请求头* return string*/static string apishop_send_request(string method, string url, Dictionary param, Dictionary headers)string result = string.Empty;trystring paramData = “;if (param != null foreach (var item in param)if (sbuilder.Length 0)sbuilder.Append(“sbuilder.Append(item.Key + “=“ + item.Value);paramData = sbuilder.ToString();method = method.ToUpper();if (method = “GET“)url = string.Format(“0?1“, url, paramData);HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.Create(url);if (method = “GET“)wbRequest.Method = “GET“;else if (method = “POST“)wbRequest.Method = “POST“;wbRequest.ContentType = “application/x-www-form- urlencoded“;wbRequest.ContentLength = Encoding.UTF8.GetByteCount(paramData);using (Stream requestStream = wbRequest.GetRequestStream()using (StreamWriter swrite = new StreamWriter(requestStream)swrite.Write(paramData);HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse();using (Stream responseStream = wbResponse.GetResponseStream()using (StreamReader sread = new StreamReader(responseStream)result = sread.ReadToEnd();catchreturn “;return result;class Responsepublic string statusCode;static void Main(string args)string method = “POST“;string url = “https:/api.apishop.net/common/ocr/ocrVehiclePlate“;Dictionary param = new Dictionary(); param.Add(“apiKey“, “your_api_key“); /需要从www.apishop.net获取 param.Add(“imgBASE64“, “); /图片的base64编码内容(图片大小应小于2M) param.Add(“multi_crop“, “); /当设成1时,会做多crop预测,只有当多crop返回的结果一致,并且置信度0.9时,才 返回结果。默认为0 Dictionary headers = null;string result = apishop_send_request(method, url, param, headers);if (result = “)/返回内容异常,发送请求失败Console.WriteLine(“发送请求失败“);return;Response res = new JavaScriptSerializer().Deserialize(result);if (res.statusCode = “000000“)/状态码为000000, 说明请求成功Console.WriteLine(string.Format(“请求成功: 0“, result);else/状态码非000000, 说明请求失败Console.WriteLine(string.Format(“请求失败: 0“, result);Console.ReadLine();
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号