以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求助c#转换到FT (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=116116) |
-- 作者:lxq3736 -- 发布时间:2018/3/20 10:31:00 -- 求助c#转换到FT 源码如下: ?using System;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
namespace
com.baidu.ai
{
public
class
General
{
// 通用文字识别
public
static
string
general()
{
string token = "#####调用鉴权接口获取的token#####";
string strbaser64 = FileUtils.getFileBase64("/work/ai/images/ocr/general.jpeg"); // 图片的base64编码
string host = "https://aip.baidubce.com/rest/2.0/ocr/v1/general?access_token=" + token;
Encoding encoding = Encoding.Default;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(host);
request.Method = "post";
request.ContentType = "application/x-www-form-urlencoded";
request.KeepAlive = true;
String str = "image=" + HttpUtility.UrlEncode(strbaser64);
byte[] buffer = encoding.GetBytes(str);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);
string result = reader.ReadToEnd();
Console.WriteLine("通用文字识别:");
Console.WriteLine(result);
return result;
}
}
} 拜托各位,谢谢!
|
-- 作者:有点甜 -- 发布时间:2018/3/20 10:35:00 -- 参考
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=106768&skin=0
参考
|
-- 作者:lxq3736 -- 发布时间:2018/3/20 22:33:00 -- 一点一点学习,已解决。谢谢! 一点一点学习,已解决。谢谢! |