腾讯云OCR图片文字识别
一、 OCR
OCR (Optical Character Recognition,光学字符识别)是指电子设备(例如扫描仪或数码相机)检查纸上打印的字符,通过检测暗、亮的模式确定其形状,然后用字符识别方法将形状翻译成计算机文字的过程;
-- 来自百度
二、腾讯云OCR
基于腾讯自研的深度学习技术和海量的数据,提供卡证、票据类印刷体和手写体、自定义模板等多种场景和类型的文字识别服务。
三、接口对接
说明:基于 spring boot 的接口对接
1、添加开发的SDK
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>qcloud-image-sdk</artifactId>
<version>2.3.6</version>
</dependency>
2、编写工具类
注意:此接口对接版本有点低,现在的sdk是2.0了,不过这个工具类是可以正常食用的。2.0的sdk可以官方给出的文档 传送门
import com.qcloud.image.ImageClient;
import com.qcloud.image.exception.AbstractImageException;
import com.qcloud.image.request.*;
import java.io.File;
/**
* 腾讯云Ocr文字识别
*
* @author lixingwu
*/
public class OcrUtil {
/*配置参数为空,请自行填写*/
private static final String APP_ID = "";
private static final String SECRET_ID = "";
private static final String SECRET_KEY = "";
private static final String BUCKET_NAME = "";
private static final ImageClient IMAGECLIENT = new ImageClient(APP_ID, SECRET_ID, SECRET_KEY, ImageClient.NEW_DOMAIN_recognition_image_myqcloud_com);
/**
* 方法描述:识别身份证URL方式.
* 创建时间:2018-12-19 11:54:36
*
* @param url 图片地址
* @param cardType 0正面,1反面
* @return the string
* @author "lixingwu"
*/
public static String ocrIdCardUrl(String url, Integer cardType) {
String ret = null;
String[] idcardUrlList = new String[]{url};
IdcardDetectRequest idReq = new IdcardDetectRequest(BUCKET_NAME, idcardUrlList, cardType);
try {
ret = IMAGECLIENT.idcardDetect(idReq);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:识别身份证path方式.
* 创建时间:2018-12-19 11:54:36
*
* @param path 图片路径
* @param cardType 0正面,1反面
* @return the string
* @author "lixingwu"
*/
public static String ocrIdCardPath(String path, Integer cardType) {
String ret = null;
File[] idcardUrlList = new File[]{new File(path)};
IdcardDetectRequest idReq = new IdcardDetectRequest(BUCKET_NAME, idcardUrlList, cardType);
try {
ret = IMAGECLIENT.idcardDetect(idReq);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:驾驶证识别URL方式.
* 创建时间:2018-12-19 12:52:27
*
* @param url 图片地址
* @return the string
* @author "lixingwu"
*/
public static String ocrDrivingLicenceUrl(String url) {
String ret = null;
OcrDrivingLicenceRequest request = new OcrDrivingLicenceRequest(BUCKET_NAME, OcrDrivingLicenceRequest.TYPE_DRIVER_LICENSE, url);
try {
ret = IMAGECLIENT.ocrDrivingLicence(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:驾驶证识别path方式.
* 创建时间:2018-12-19 12:52:27
*
* @param path 图片路径
* @return the string
* @author "lixingwu"
*/
public static String ocrDrivingLicencePath(String path) {
String ret = null;
File file = new File(path);
OcrDrivingLicenceRequest request = new OcrDrivingLicenceRequest(BUCKET_NAME, OcrDrivingLicenceRequest.TYPE_DRIVER_LICENSE, file);
try {
ret = IMAGECLIENT.ocrDrivingLicence(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:行驶证识别URL方式.
* 创建时间:2018-12-19 12:52:27
*
* @param url 图片地址
* @return the string
* @author "lixingwu"
*/
public static String ocrVehicleLicenceUrl(String url) {
String ret = null;
OcrDrivingLicenceRequest request = new OcrDrivingLicenceRequest(BUCKET_NAME, OcrDrivingLicenceRequest.TYPE_VEHICLE_LICENSE, url);
try {
ret = IMAGECLIENT.ocrDrivingLicence(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:行驶证识别path方式.
* 创建时间:2018-12-19 12:52:27
*
* @param path 图片路径
* @return the string
* @author "lixingwu"
*/
public static String ocrVehicleLicencePath(String path) {
String ret = null;
File file = new File(path);
OcrDrivingLicenceRequest request = new OcrDrivingLicenceRequest(BUCKET_NAME, OcrDrivingLicenceRequest.TYPE_VEHICLE_LICENSE, file);
try {
ret = IMAGECLIENT.ocrDrivingLicence(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:车牌识别URL方式.
* 创建时间:2018-12-19 12:52:27
*
* @param url 图片地址
* @return the string
* @author "lixingwu"
*/
public static String ocrPlateUrl(String url) {
String ret = null;
OcrPlateRequest request = new OcrPlateRequest(BUCKET_NAME, url);
try {
ret = IMAGECLIENT.ocrPlate(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:车牌识别path方式.
* 创建时间:2018-12-19 12:52:27
*
* @param path 图片路径
* @return the string
* @author "lixingwu"
*/
public static String ocrPlatePath(String path) {
String ret = null;
File file = new File(path);
OcrPlateRequest request = new OcrPlateRequest(BUCKET_NAME, file);
try {
ret = IMAGECLIENT.ocrPlate(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:营业执照识别URL方式.
* 创建时间:2018-12-19 12:52:27
*
* @param url 图片地址
* @return the string
* @author "lixingwu"
*/
public static String ocrBizLicenseUrl(String url) {
String ret = null;
OcrBizLicenseRequest request = new OcrBizLicenseRequest(BUCKET_NAME, url);
try {
ret = IMAGECLIENT.ocrBizLicense(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:营业执照识别path方式.
* 创建时间:2018-12-19 12:52:27
*
* @param path 图片路径
* @return the string
* @author "lixingwu"
*/
public static String ocrBizLicensePath(String path) {
String ret = null;
File file = new File(path);
OcrBizLicenseRequest request = new OcrBizLicenseRequest(BUCKET_NAME, file);
try {
ret = IMAGECLIENT.ocrBizLicense(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:银行卡识别URL方式.
* 创建时间:2018-12-19 12:52:27
*
* @param url 图片地址
* @return the string
* @author "lixingwu"
*/
public static String ocrBankCardUrl(String url) {
String ret = null;
OcrBankCardRequest request = new OcrBankCardRequest(BUCKET_NAME, url);
try {
ret = IMAGECLIENT.ocrBankCard(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:银行卡识别path方式.
* 创建时间:2018-12-19 12:52:27
*
* @param path 图片路径
* @return the string
* @author "lixingwu"
*/
public static String ocrBankCardPath(String path) {
String ret = null;
File file = new File(path);
OcrBankCardRequest request = new OcrBankCardRequest(BUCKET_NAME, file);
try {
ret = IMAGECLIENT.ocrBankCard(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:通用印刷体识别URL方式.
* 创建时间:2018-12-19 12:52:27
*
* @param url 图片地址
* @return the string
* @author "lixingwu"
*/
public static String ocrGeneralUrl(String url) {
String ret = null;
GeneralOcrRequest request = new GeneralOcrRequest(BUCKET_NAME, url);
try {
ret = IMAGECLIENT.generalOcr(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
/**
* 方法描述:通用印刷体识别URL方式.
* 创建时间:2018-12-19 12:52:27
*
* @param path 图片路径
* @return the string
* @author "lixingwu"
*/
public static String ocrGeneralPath(String path) {
String ret = null;
File file = new File(path);
GeneralOcrRequest request = new GeneralOcrRequest(BUCKET_NAME, file);
try {
ret = IMAGECLIENT.generalOcr(request);
} catch (AbstractImageException e) {
e.printStackTrace();
}
return ret;
}
}
3、天气太热了
上面的工具类只是简单的说了一下,如果项目需要用到,得自己去测试,等我那天心情好了再说详细了点。
腾讯云OCR图片文字识别的更多相关文章
- 一篇文章搞定百度OCR图片文字识别API
一篇文章搞定百度OCR图片文字识别API https://www.jianshu.com/p/7905d3b12104
- 关于python 使用腾讯云OCR 通用印刷体识别
腾讯的python SDK没有通用印刷体识别,所以参考了别人识别网上图片的方式:https://www.cnblogs.com/semishigure/p/7690789.html 但是咱们使用的基本 ...
- PHP百度AI的OCR图片文字识别
第一步可定要获取百度的三个东西 要到百度AI网站(http://ai.baidu.com/)去注册 然后获得 -const APP_ID = '请填写你的appid'; -const API_KEY ...
- 有道自然语言翻译和文字识别OCR(图片文字识别)接口调用
官网 http://ai.youdao.com 文档地址 http://ai.youdao.com/docs/doc-ocr-api.s#p01 在Python中调用api. #/usr/bin/en ...
- 云+社区分享——腾讯云OCR文字识别
欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由云+社区运营团队发布在腾讯云+社区 前言 2018年3月27日腾讯云云+社区联合腾讯云智能图像团队共同在客户群举办了腾讯云OCR文字识 ...
- 阿里云OCR图片转换成文字识别调用
using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Drawing; using S ...
- 小试Office OneNote 2010的图片文字识别功能(OCR)
原文:小试Office OneNote 2010的图片文字识别功能(OCR) 自Office 2003以来,OneNote就成为了我电脑中必不可少的软件,它集各种创新功能于一身,可方便的记录下各种类型 ...
- 【图片识别】java 图片文字识别 ocr (转)
http://www.cnblogs.com/inkflower/p/6642264.html 最近在开发的时候需要识别图片中的一些文字,网上找了相关资料之后,发现google有一个离线的工具,以下为 ...
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 18—Photo OCR 应用实例:图片文字识别
Lecture 18—Photo OCR 应用实例:图片文字识别 18.1 问题描述和流程图 Problem Description and Pipeline 图像文字识别需要如下步骤: 1.文字侦测 ...
随机推荐
- List泛型
.Net自从2.0以后开始支持泛型. 泛型的作用:可以创建独立于被包含类型的类和方法.泛型类使用泛型类型,并可以根据需要使用特定的类型替换泛型类型.这就保证了类型安全性:如果某个类型不支持泛型类,编译 ...
- 【小白视频学Java for循环】3分钟学会Java的for循环,让看懂for循环嵌套再不是难事
目录 一.单个for循环介绍 二.for循环嵌套 听讲时能听懂的for循环为什么一做题就晕菜?一个for循环还勉强能看懂,但为什么一看到双重for循环脑子里就感觉脑子全是浆糊? 如果有上述问题那么就继 ...
- node的httpserver简单创建
1.设计原则为文件夹名字可以依据资源来命名,静态资源统一命名 ps:路径中绝对和相对路径,依据server.js本身的位置而言 const http = require("http" ...
- Remoting、WCF、WebAPI、WCFREST、WebService之间的区别与联系
在.net平台下,有大量的技术让你创建一个服务,像Web Service,WCF,Web API,Remoting,我们来对比一下他们的区别与联系 Remoting Web Service WCF W ...
- java new一个对象的过程中发生了什么?
java在new一个对象的时候,会先查看对象所属的类有没有被加载到内存,如果没有的话,就会先通过类的全限定名来加载.加载并初始化类完成后,再进行对象的创建工作. 我们先假设是第一次使用该类,这样的话n ...
- springboot 报错 org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type 'com.example.service.HrService' available: 有没有大佬出个主意,我找了一天,刚入门springboot
话不多说先上图,这是启动类的配置,这里配置了@ComponentScan("我的mapper的接口") 接下来是我的项目结构截图 然后是service 的截图,我在这里加了注解@S ...
- Linux下的python3,virtualenv,Mysql、nginx、redis等常用服务安装配置
Linux下的python3,virtualenv,Mysql.nginx.redis等常用服务安装配置 学了前面的Linux基础,想必童鞋们是不是更感兴趣了?接下来就学习常用服务部署吧! 安装环 ...
- linux下ftp(vsftpd)添加用户及设置权限详细步骤
1.环境:ftp为vsftp.被限制用户名为test.被限制路径为/home/test2.建用户:在root用户下:useradd test //增加用户test,并制定test用户的主目录为/hom ...
- Spring Aop和Spring Ioc(二)
Spring IOC: DI注入集合类型: 实体类: package cn.spring.entity; import java.util.*; public class Dientity { pri ...
- 克里金插值 调用matlab工具箱
克里金插值 克里金插值是依据协方差函数对随机过程或随机场进行空间建模和插值的回归算法. 克里金插值法的公式为: 式中为待插入的各点的重金属污染值,为已知点的重金属污染值,为每个点的权重值. 用BLUP ...