以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]字符串叠加 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=145569) |
-- 作者:天一生水 -- 发布时间:2020/1/31 11:25:00 -- [求助]字符串叠加 蓝老师好! 我想在每次叠加字符串时,添加一个标记行,放在字符串的首行。但是下面的代码把标记行添加到字符串的末尾了,这个代码应该怎样写? 谢谢! ...... str & = vbcrlf & "★★★" & kh & vbcrlf
|
-- 作者:有点蓝 -- 发布时间:2020/1/31 11:29:00 -- str = "★★★" & kh & vbcrlf & str |
-- 作者:天一生水 -- 发布时间:2020/1/31 12:38:00 -- 放入批量文字识别的代码中,标记行集中到最终结果的最前面了(共识别4张图片),应该是在每一页的最前面。 老师帮忙看看是什么原因? \'\'\' Dim dlg As New OpenFileDialog dlg.MultiSelect = True dlg.Filter= "图形文件|*.bmp;*.jpg;*.gif,;*.png" If dlg.ShowDialog = DialogResult.OK Then Dim txt As WinForm.TextBox = e.Form.Controls("TextBox1") Dim pic1 As WinForm.PictureBox = e.Form.Controls("PictureBox1") Dim str As String For Each fl As String In dlg.FileNames pic1.ImageFile = fl Dim kh As String = FileSys.GetName(fl).split(".")(0) \'取文件名 try 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 str = "★★★" & kh & vbcrlf & str \'每张图片添加图片名称 catch ex As exception txt.text = str & vbcrlf & "识别接口调用失败,错误描述: " & vbcrlf & ex.message End try Next txt.text = str End If |
-- 作者:有点蓝 -- 发布时间:2020/1/31 13:09:00 -- 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
|