# cordova-plugin-hongruan **Repository Path**: juntuo_zyq/cordova-plugin-hongruan ## Basic Information - **Project Name**: cordova-plugin-hongruan - **Description**: cordova 人脸识别插件 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-04-19 - **Last Updated**: 2024-08-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # cordova-plugin-hongruan ### Readme 虹软离线识别仅支持android系统,ios只会返回识别到的人脸图片 ## Install - 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+: ```shell cordova plugin add https://gitee.com/juntuo_zyq/cordova-plugin-hongruan.git ``` ### USE IN ANDROID > 注册服务 active ```js var params = { "appId": "your Arc appId", // 虹软APPID "sdkKey": "your Arc sdkKey"// 虹软SDKKEY } window.HongRuan.active( params, success => { console.log("success: "+success); }, error => { console.log("error: "+error); } ) ``` > 注册人脸特征码 future ```js var params = [{ id: "id", // returns in Api recognize 自定义id,会在识别到人脸后返回,以便于区分是谁的人脸 future: "base64", // face feature code 自定义base64人脸特征码,用于离线对比 type: "other info" // returns in Api recognize 自定义其他信息,会在识别到人脸后返回 }] window.HongRuan.future( params, success => { console.log("success: "+success); }, error => { console.log("error: "+error); } ) ``` > 开始识别 recognize ```js var params = { "topHeight": 0, // Distance from top 识别窗口与顶部的距离 "bottomHeight": 0, // Distance from bottom 识别窗口与底部的距离 "cameraId": 'back' // front or back 选择前置还是后置摄像头 } window.HongRuan.recognize( params, success => { /* success.name (returns as id+"#"+type, 'id' and 'type' is from the Api future) 注册时自定义的id+"#"+自定义的其他信息type success.img (returns as base64 of face) 识别到的人脸截图 */ console.log("success: "+success); }, error => { console.log("error: "+error); } ) ``` ### USE IN IOS > 开始识别 start ```js var params = { "topHeight": 0, // Distance from top 识别窗口与顶部的距离 "bottomHeight": 0, // Distance from bottom 识别窗口与底部的距离 "cameraId": 'back' // front or back 选择前置还是后置摄像头 } window.HongRuan.start( params, success => { // (returns as base64 of face) 识别到的人脸截图 var dataURL = "data:image/jpeg;base64," + success; console.log("base64: "+dataURL); }, error => { console.log("error: "+error); } ) ``` ### API > 关闭识别 finish ```js window.HongRuan.finish(); ```