按键精灵---调用百度AI进行文字识别脚本 - Go语言中文社区

按键精灵---调用百度AI进行文字识别脚本


Import "ShanHai.lua"
Import "Cjson.lua"

//Dim pic = File.Read("/storage/emulated/0/Pictures/1.jpg")
//Dim pic = File.Read("/sdcard/Pictures/1.jpg")
//Dim picBase64 = ShanHai.Base64En(pic)

Dim picBase64 = ShanHai.ReadFileBase("/sdcard/Pictures/1.jpg")
dim picUrlEncode =  ShanHai.CharToUrl(picBase64)
Dim api_url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
//用山海post,得不到结果,不知道为什么,可能是默认的包头不一样
//dim RetJson2 = ShanHai.PostHttp(api_url, "image="&picUrlEncode)
dim RetJson = Url.Post(api_url, "image="&picUrlEncode)
Dim retTable = Cjson.Decode(RetJson)

TracePrint RetJson
TracePrint "识别文字行数:" & retTable["words_result_num"]

Dim words_results= retTable["words_result"]
For i=0 to UBound(words_results)
	Dim oneUnit = words_results(i)
	Dim words = oneUnit["words"]
	TracePrint words
Next

不同地址-不同识别能力,一览表(后台地址:https://console.bce.baidu.com/ai/?fromai=1#/ai/ocr/app/detail~appId=665090

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/liujiayu2/article/details/84651348
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-04-07 23:18:32
  • 阅读 ( 3151 )
  • 分类:职场

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢