try
str = str & vbcrlf & "★★★" & kh
Dim client As new Baidu.Aip.Ocr.Ocr(Vars("APIKey"), Vars("SecretKey")) '初始化接口类,传入创建的应用的API Key,Secret Key
client.Timeout = 60000 '设置超时时间
Dim data() As Byte = System.IO.File.ReadAllBytes(fl) '把图片文件字节流加载进来,
Dim options As new Dictionary(of String, object) '使用字典传递参数
options.Add("detect_direction","true") '是否检测图像朝向,默认不检测
options.Add("probability","true")
Dim result = client.GeneralBasic(data, options) '调用接口开始识别,返回值为JObject对象
If result("error_code") IsNot Nothing AndAlso result("error_code") <> 0 Then
txt.text = "识别失败: " & vbcrlf & result("error_msg").Tostring
Else
Dim ja As JArray = result("words_result")
For i As Integer = 0 To ja.Count - 1
str = str & vbcrlf & ja(i)("words").Tostring
Next
End If
catch ex As exception
txt.text = str & vbcrlf & "识别接口调用失败,错误描述: " & vbcrlf & ex.message
End try