使用Google Drive在Android中集成OCR

使用Google Drive在Android中集成OCR,android,ocr,google-drive-api,Android,Ocr,Google Drive Api,我搜索了很多,但还没有成功。我不想使用Tesseract medhod 我已经创建了项目根据 运行时,图像被上传到goggle文档中。我收到一条消息,文件上传成功,文件名为 下载我所关注的数据 public void downloadfile(File file) { String imageAsTextUrl = file.getExportLinks().get("text/plain"); HttpClient client = new DefaultHtt

我搜索了很多,但还没有成功。我不想使用Tesseract medhod

我已经创建了项目根据

运行时,图像被上传到goggle文档中。我收到一条消息,文件上传成功,文件名为

下载我所关注的数据

public void downloadfile(File file)
  {
      String imageAsTextUrl = file.getExportLinks().get("text/plain");

      HttpClient client = new DefaultHttpClient();
      HttpGet get = new HttpGet(imageAsTextUrl);
      HttpResponse response;

      StringBuffer sb = new StringBuffer();
      BufferedReader in = null;
      try 
      {
          response = client.execute(get);
          in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
          String str;
          while ((str = in.readLine()) != null) 
          {
              sb.append(str);
          }
          Log.e(" sb data ", sb.toString());
          in.close();
      } 
      catch (ClientProtocolException e) 
      {
          e.printStackTrace();
      } 
      catch (IOException e) 
      {
          e.printStackTrace();
      }
  }
我得到了返回数据

欢迎使用谷歌文档html、body、div、h1、h2、h3、h4、h5、h6、p、img、dl、dt、dd、ol、ul、li、table、tr、td、form、object、embed、article、aside、canvas、command、details、fieldset、figcaption、fig、footer、group、header、hgroup、legend、mark、menu、meter、nav、output、progress、section、summary、time、audio、video{页边距:0;填充:0;边框:0;}文章,旁白,细节,图片,页脚,页眉,组,菜单,导航,部分{显示:块;}html{字体:81.25%arial,helvetica,无衬线;背景:#fff;颜色:#333;行高:1;方向:ltr;}a{颜色:#15c;文本装饰:无;}a:活动{颜色:#d14836;}a:hover{文本装饰:下划线;}h1,h2,h3,h4,h5,h6{颜色:#222;字体大小:1.54em;字体重量:正常;行高:24px;边距:0.46em;}p{行高:17px;边距:0.01em;}ol,ul{列表样式:无;行高:17px;边距:0.01em;}li{边距:0.5em;}表格{边框折叠:折叠;边框间距:0;}强{颜色:#222;}html,正文{位置:绝对;高度:100%;最小宽度:100%;}。包装{位置:相对;最小高度:100%;}。包装+样式+iframe{显示:无;}。内容{填充:0 44px;}。顶栏{文本对齐:右;顶部填充:.5em;底部填充:.5em;}。谷歌标题栏{高度:71px;背景:#f1f1f1;边框底部:1px实心#e5e5;溢出:隐藏;}.header.logo{margin:17px 0 0;float:left;}.header.sign.header.signup{margin:28px 0;float:right;font-weight:bold;}.header.signin按钮,.header.signup按钮{margin:22px 0;float:right;}.header.signin按钮a{font size:13px;font-weight:normal;}.header.signup按钮a{position:relative;top:-1px;margin:0.01em;}.main{margin:0 auto;width:650px;padding top:23px;padding bottom:100px;}.main h1:第一个子项{margin:0.92em;}.google footer bar{位置:绝对;底部:0;高度:35px;宽度:100%;边框顶部:1px实心#ebebebeb;溢出:隐藏;}。页脚{填充顶部:9px;字体大小:.85em;空白:nowrap;行高:0;}。页脚ul{颜色:#999;浮点:左;最大宽度:80%;}。页脚ul li{显示:内联;填充:0 1.5em 0;}。页脚a{颜色:#333.footer.lang chooser wrap{float:right;max width:20%}.footer.lang chooser wrap img{vertical align:middle;}.footer.attribute{float:right;}.footer.attribute span{vertical align:text top;}.redtext{color:#dd4b39;}.greytext color:#555;}.secondary{字体大小:11px;颜色:#666;}.source color:{color:#093;}.hidden{display:none;}.announcebar{position:absolute;bottom:35px;height:33px;z-index:2;width:100%;background:f9edbe;border top:1px solid#efe1ac;border bottom:1px solid#efe1ac;overflow:hidden;}.announcebar.message{字体大小:.85em;行高:33px;边距:0;}.announcebar.message.message{左边距:1.5em;}。宣布栏ac{背景:eee;边框顶部:1px实心#e5e5;边框底部:1px实心#e5e5;}。clearfix:after{可见性:隐藏;显示:块;字体大小:0;内容:'.;清除:两者;高度:0;}*html.clearfix{zoom:1;}*:第一个子项+html.clearfix{zoom:1;}预处理{字体系列:单空格;位置:绝对;左:0;边距:0;填充:1.5em;字体大小:13px;背景:#f1f1f1;边框顶部:1px实心#e5e5e5;方向:ltr;}按钮,输入,选择,文本区域{字体系列:继承;字体大小:继承;}按钮::-moz焦点内部,输入:-moz焦点内部{边框:0;}输入[type=email],输入[type=number],输入[type=password],输入[type=tel],输入[type=text],输入[type=url]{-webkit-“

但这不会返回图片中的文本,我上传了。如何获取文本,我上传了图片

当我试着

下载时,我在 “
DriveRequest-DriveRequest=(DriveRequest)请求;
” 它无法将HttpRequest强制转换为DriveRequest

然后我试了一下

DriveRequest driveRequest = DriveRequest.class.cast(request);
但我在这行中突然听到一句话“ClassCastExcaption”


欢迎提供任何相关答案。提前感谢。

我通过添加

get.setHeader("Authorization", "Bearer " + credential.getToken());
下载文件
方法

由于我的身份验证不正确,它返回了Google Docs欢迎页面的HTML。添加这一行后,我正确地获得了识别的文本