|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- # 配置流程
-
- ## 接入配置
-
- ### 注意事项
-
- - SDK 最低支持 Android 4.0 以上版本 API LEVEL 16。
- - SDK 将以 AAR 文件的形式提供,[cepm-sdk-release.aar](#demo) 和 [sdkproject-release_enc.aar](#demo),详情请参见 [添加依赖](#yilai)。
- - 提供多个入口方法,请根据业务选择
-
- ### 准备工作
-
- 1. 向AI平台申请使用凭证
- 2. 需要提供使用环境的Appid、目标客户
- 3. LicenseID标签已废弃,无需关注
- 4. 使用凭证包含如下部分:
- - SysName:系统名称
- - UserCode:用户名
- - Password:密钥
- - Url:AI平台服务链接
-
- <span id='yilai'></span>
-
- ### 添加依赖
-
- 将提供的 AAR 文件加入到 App 工程的 libs 文件夹内,并且在 build.gradle 中添加下面的配置。
-
- ```
- android{
-
- repositories {
- flatDir {
- dirs 'libs'
- }
- }
- }
-
-
- dependencies {
-
-
- implementation 'com.alibaba:fastjson:1.2.73'
- implementation 'com.squareup.okhttp3:okhttp:4.0.0'
- implementation files('libs/cepm-sdk-release.aar')
- implementation files('libs/sdkproject-release_enc.aar')
- }
-
- ```
-
- <span id='shili'></span>
-
- # 接入示例
- 初始化:该步骤必须进行,否则无法调用
- ```
- # 项目需要增加Application类
- public class MyApp extends Application {
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- CepmApp.init(this);
- }
- }
-
- ```
-
- 快速调用:
- ```
- # 在MainActivity中单击某个按钮的代码逻辑
-
- Credential cert=new Credential();
- final FaceidSDK.IDCardInputData inputdata=FaceidSDK.getInstance().new IDCardInputData("xxx","xxx");
- cert.setPassword("xxxx");
- cert.setUserCode("xxxx");
- cert.setUrl("xxxx");
- cert.setSysName("xxxx");
-
- FaceidSDK.getInstance().init(MainActivity.this,"你的LicenseID", cert,new FaceidSDK.FaceidLoginListener() {
- @Override
- public void onLoginSuccess() {
- FaceidSDK.getInstance().startActivity(inputdata, new FaceidSDK.FaceidResultListener() {
- @Override
- public void onFailed(String errorCode, String errorMsg) {
-
- }
-
- @Override
- public void onFinish(FaceidSDK.OutputData result) {
-
-
- }
- });
- }
-
- @Override
- public void onLoginFailed(String errorCode, String errorMsg) {
-
- }
- });
- ```
- <span id='demo'></span>
-
- [完整demo和sdk下载](./demo/demo-sdk.zip) (跳转后点击查看**原始文件**)
-
- # 接口详细说明
-
- 1. [Faceid接口](#faceid)
- 2. [Ocr接口](#ocr)
-
- <span id='faceid'></span>
-
- ## SDK Faceid 接口
-
- SDK 代码调用的入口为 `FaceidSDK` 这个类。
-
- ```
- public class FaceidSDK {
-
-
- public static FaceidSDK getInstance(){
-
- }
-
-
-
-
- public void setFaceSDKConfig(FaceSDKConfig faceSDKConfig) {
-
- }
-
-
-
- public void init(Context context,String LicenseID,Credential credential, FaceidLoginListener loginListerner){
-
- }
-
-
-
- public void startActivity(IDCardInputData data,FaceidResultListener resultListener) {
-
- }
-
-
-
- public void startActivity(PhotoInputData data,FaceidResultListener resultListener) {
-
- }
-
-
-
- public void startActivity(faceDataResultListener resultListener) {
-
- }
-
-
-
- public interface FaceidLoginListener {
- void onLoginSuccess();
- void onLoginFailed(String errorCode, String errorMsg);
- }
-
-
-
- public interface FaceidResultListener{
- void onFailed(String errorCode, String errorMsg);
- void onFinish(OutputData result);
- }
-
-
- public interface FaceDataResultListener {
- void onFailed(String errorCode, String errorMsg);
- void onFinish(OutputFaceData result);
- }
- ```
-
- `startActivity()` 的参数PhotoInputData和IDCardInputData用来传递数据:
-
- ```
- String name;
- String idNum;
- ----
- DataItem photo;
- ```
-
- > 以上参数被分别封装在 `FaceidSDK.PhotoInputData`,`FaceidSDK.IDCardInputData` 对象中。
-
- ### 接入示例
- 关于接口调用的示例可参考 [接入示例](#shili)
-
- <span id='canshu'></span>
-
- ### 接口参数说明
-
- | IDCardInputData参数 | 说明 | 类型 | 长度(字节) | 是否必填 |
- | --- | --- | --- | --- | --- |
- | name | 核验人的姓名| String | - | 是 |
- | idNum | 核验人的身份证号 | String | 32 | 是 |
-
-
- | PhotoInputData参数 | 说明 | 类型 | 长度(字节) | 是否必填 |
- | --- | --- | --- | --- | --- |
- | photo | 核验人的照片,DataItem属性见下表| DataItem | - | 是 |
-
-
- | DataItem属性 | 说明 | 类型 | 是否必填 |
- | --- | --- | --- | --- |
- | origin | 文件类型<br/> base64形式:self<br/> 链接形式:uri <br/> | DataItem.DataOrigin | 是 |
- | data | 照片内容(base64或uri链接)| String | 是 |
-
-
- ### 动作参数说明
-
- | FaceSDKConfig参数 | 说明 | 类型 |
- | --- | --- | --- |
- | actions | [动作](#dongzuo)范围<br/> 可选"eye","mouth","headRight","headLeft","headUp","headDown","yaw"<br/>默认包含所有| List\<String\> |
- | actionOrderRandom | 动作顺序是否随机,默认true | boolean |
- | actionNum | 随机从actions中选取几个动作,默认3 | int |
-
- <span id='dongzuo'></span>
-
- ### 动作
-
- | 参数名 | 说明 |
- | --- | --- |
- | eye | 眨眼 |
- | mouth | 张嘴 |
- | headRight | 头右转 |
- | headLeft | 头左转 |
-
- <span id='ocr'></span>
-
- ## SDK Ocr 接口
-
- SDK 代码调用的入口为 `OcrSDK` 这个类。
-
- ```
- public class OcrSDK {
-
-
- public static OcrSDK getInstance(){
-
- }
-
-
-
- public void init(Context context,Credential credential, final OcrLoginListener loginListerner){
-
- }
-
-
-
-
- public void startTakePhotoActivity(TakePhotoResultListener resultListener,OcrType ocrType) {
-
- }
-
-
-
- public void startIdCardFrontActivity(IdCardFrontResultListener resultListener) {
-
-
- }
-
-
-
- public void startIdCardBackActivity(IdCardBackResultListener resultListener) {
-
-
- }
-
-
- public void startBankCardActivity(BankCardResultListener resultListener) {
-
-
- }
-
-
-
- public interface OcrLoginListener {
- void onLoginSuccess();
-
- void onLoginFailed(String errorCode, String errorMsg);
- }
-
-
-
- public interface TakePhotoResultListener {
-
-
- void onFailed(String errorCode, String errorMsg);
-
- void onFinish(String result);
- }
-
-
- public interface IdCardFrontResultListener {
-
-
- void onFailed(String errorCode, String errorMsg);
-
- void onFinish(IdCardFrontData result);
- }
-
-
- public interface IdCardBackResultListener {
-
-
- void onFailed(String errorCode, String errorMsg);
-
- void onFinish(IdCardBackData result);
- }
-
-
- public interface BankCardResultListener {
-
-
- void onFailed(String errorCode, String errorMsg);
-
- void onFinish(BankCardData result);
- }
- ```
|