调用阿里云的通用文字识别-高精版识别接口,识别图片中的文字详解

调用阿里云的通用文字识别-高精版识别接口,识别图片中的文字详解,第1张

调用阿里云的通用文字识别-高精版识别接口,识别图片中的文字详解

阿里云的通用文字识别-高精版识别接口地址:

通用文字识别 - 文字识别(OCR) - 阿里云

直接上代码

核心代码

package com.aliyun.sample;

import com.aliyun.tea.*;
import com.aliyun.ocr_api20210707.*;
import com.aliyun.ocr_api20210707.models.*;
import com.aliyun.teaopenapi.*;
import com.aliyun.teaopenapi.models.*;
import com.aliyun.darabonba.stream.*;

public class Sample {

    
    public static com.aliyun.ocr_api20210707.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com";
        return new com.aliyun.ocr_api20210707.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List args = java.util.Arrays.asList(args_);
        com.aliyun.ocr_api20210707.Client client = Sample.createClient("client id", "client secrect");
        java.io.InputStream bodySyream = com.aliyun.darabonba.stream.Client.readFromFilePath("D:\work\doc\1.jpg");
        RecognizeAdvancedRequest recognizeAdvancedRequest = new RecognizeAdvancedRequest()
                .setBody(bodySyream);
        // 复制代码运行请自行打印 API 的返回值
        RecognizeAdvancedResponse response= client.recognizeAdvanced(recognizeAdvancedRequest);
        System.out.println(response.getBody().getData());
    }
}

pom.xml配置文件



  4.0.0
  com.aliyun
  sample
  1.0.0
  jar
  sample
  Alibaba Cloud SDK Code Sample for Java
    
  https://github.com/aliyun/alibabacloud-code-sample
  
    
      
      http://www.apache.org/licenses/LICENSE-2.0.txt
    
  
  
    
      aliyundeveloper
      Aliyun SDK
      aliyunsdk@aliyun.com
    
  
  
    
      sonatype-nexus-snapshots
      https://s01.oss.sonatype.org/content/repositories/snapshots
    
    
      sonatype-nexus-staging
      https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
    
  
  
    
    
    
  
  
    
      com.aliyun
      ocr_api20210707
      1.1.1
    
    
      com.aliyun
      darabonba-stream
      0.0.1
    
    
      com.aliyun
      tea-openapi
      0.2.0
    
    
      com.aliyun
      tea-console
      0.0.1
    
    
      com.aliyun
      tea-util
      0.2.13
    
    
      com.aliyun
      tea
      1.1.14
    
  
  
    
      
        org.apache.maven.plugins
        maven-compiler-plugin
        3.6.1
        
          7
          7
        
      
      
        org.apache.maven.plugins
        maven-gpg-plugin
        1.6
        
          
            sign-artifacts
            verify
            
              sign
            
          
        
      
      
        org.sonatype.plugins
        nexus-staging-maven-plugin
        1.6.3
        true
        
          sonatype-nexus-staging
          https://s01.oss.sonatype.org/
          true
        
      
      
        org.apache.maven.plugins
        maven-javadoc-plugin
        3.1.1
        
          UTF-8
          none
        
      
      
        org.apache.maven.plugins
        maven-surefire-plugin
        2.22.1
      
      
        org.apache.maven.plugins
        maven-assembly-plugin
        2.4.1
        
          
            jar-with-dependencies
          
          
            
              true
              com.aliyun.sample.Sample
            
          
        
        
          
            make-assembly
            package
            
              single
            
          
        
      
    
  

运行后输出内容为:

 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5721705.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-18
下一篇 2022-12-18

发表评论

登录后才能评论

评论列表(0条)

保存