本帖最后由 kaze 于 2019-4-2 13:32 编辑
大家可以参照此帖看看百度ocr的要求等详细解释,
http://www.bathome.net/viewthread.php?tid=48390&highlight=ocr
但是本代码并非来源于以上贴子,有心人肯定能够猜到本代码是干啥的了,但是是属于不能明说的一类了。(这里的网址隐藏了真实意图)
源代码并非批处理,也是用的百度普通ocr,现在提出要求,使用百度ocr高精度识别,把在线图片base64编码、去掉编码头后再进行urlencode。
这一步我是怎么也搞不定了,希望有兴趣的高手能够实现,谢谢。- /*&cls
- @echo off
- title 取图片信息
- echo 取图片信息
- cd /d "%~dp0"
- cscript -nologo -e:jscript "%~f0"
- pause&exit /b
- */
-
- var fso=new ActiveXObject('Scripting.FileSystemObject');
- var http=new ActiveXObject('MSXML2.XMLHTTP');
- var m=0;
- var img_url_list='';
- var img_url_list=gettext('http://open.iciba.com/dsapi/').match(/fenxiang_img\":\"(http.+)\"\}/m)[1].replace(/\\/g,'');
- var num=img_url_list.match(/\d{4}(-\d\d){2}/m)[0];
-
- var client_id="你的百度文字识别的id";
- var client_secret="你的百度文字识别的Secret Key";
- var access_token=get_access_token(client_id,client_secret);
- var list=send_Pic2word_request(img_url_list,access_token);
-
- WSH.echo(num+'\r\n'+img_url_list+'\r\n'+list);
- //var f=fso.CreateTextFile('X:/ssr.txt', 2, true);
- //f.Write(num+'\r\n'+list);
- //f.Close();
- WSH.Quit();
-
- function gettext(url){
- var text='';
- http.open('Get', url, false)
- http.send();
- if (http.status == 200 ) {text=http.responseText;
- return text;}
- else {m++;WSH.echo(m);
- gettext(url);
- }
- }
-
- function get_access_token(client_id,client_secret){
- host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id='+client_id+'&client_secret='+client_secret
- http.open('Post', host, false)
- http.send();
- if (http.status == 200) {content = http.responseText;
- var json=eval('('+content+')');
- return json['access_token'];
- }
- }
-
- function send_Pic2word_request(img_url_list,access_token){
- host="https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token="+access_token+"&url="+img_url_list;
- http.open('Post', host, false)
- http.send();
- content = http.responseText;
- WSH.echo(content);
- if (content){
- var json1=eval('('+content+')');
- var n=json1.words_result_num;
- var wr=json1.words_result
- var test1=wr[0].words;
- var test2=wr[1].words;
- var list=test1+'\r\n'+test2+'\r\n';
- return list;
- }
- }
复制代码
|