首先,这里选用的sdk是java(支持本地上传版本)和python

阿里云的sdk最好是通过maven来导入,而且在使用maven的时候注意将镜像设置为阿里云,否则会很慢。

AccessKey

记得在阿里云上申请(目前免费)accessKey 及密码。

并将其放在application. properties 处

在线测试

发现可以在线测试呀!!!而且可以使用临时生成的accesskey自动进行,wow!

onlineTest

代码

并不会!(嘤嘤嘤)(勉强会一点点的python(借助样例))

java实现

参考了一份(java嘿嘿)

主要需要编写的有:

pic

python实现

首先需要使用 pip install aliyun-python-sdk-core 命令,安装阿里云SDK核心库 。

然后执行下载文字识别包:pip install aliyun-python-sdk-ocr

新建.py文件见下列代码cv,然后将自己的ak填入即可。之后在url的地方图片的链接(仅支持阿里云的oss,代码中给出了一个示例,可以使用)

下面的set_Side就是正反面

运行即可

#!/usr/bin/env python
#coding=utf-8
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkocr.request.v20191230.RecognizeIdentityCardRequest import RecognizeIdentityCardRequest

client = AcsClient('<accessKeyId>', '<accessSecret>', 'cn-shanghai')

request = RecognizeIdentityCardRequest()
request.set_accept_format('json')

request.set_ImageURL("http://explorer-image.oss-cn-shanghai.aliyuncs.com/1786373016143448/index.jpg?OSSAccessKeyId=LTAI4Fk9FstqSEYnqKJ5Dpeo&Expires=1589709652&Signature=wdCT6OMdBw2mvOdvVecgkDWtqcI%3D")
request.set_Side("face")

response = client.do_action_with_exception(request)
# python2:  print(response) 
print(str(response, encoding='utf-8'))

pyresult

上图是python的测试结果。

测试

测试图片(图源网络)

images

index

result

测试结果

基本符号要求。(总算成功了)

最后

基于阿里云开放平台我们可以便捷使用的工具还有很多很多, 包括人脸人体、文字识别、商品理解、内容安全、图像识别、图像生产、分割抠图、视觉搜索、目标检测、图像分析处理、视频理解、视频生产、视频分割13个类目 ,日后便去完成!