From 6848ba6f9830df560ec536f6afc0f93bfa7f2da5 Mon Sep 17 00:00:00 2001 From: Bob Wei Date: Mon, 11 Jun 2018 00:00:22 +0800 Subject: [PATCH 1/2] Rm unused spaces --- lib/index.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/index.js b/lib/index.js index 0af5da2..353478e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,6 @@ /* - * @Author: lkspc - * @Date: 2017-10-02 00:19:50 + * @Author: lkspc + * @Date: 2017-10-02 00:19:50 * @Last Modified by: lkspc * @Last Modified time: 2017-10-11 17:06:31 */ @@ -29,9 +29,9 @@ class ArcFace { /** * initialize FD engine - * + * * @param {String} libFile - * @param {Object} opts + * @param {Object} opts * @param {String} opts.appId * @param {String} opts.sdkKey * @param {Number} opts.workSize @@ -78,9 +78,9 @@ class ArcFace { /** * initialize FR engine - * + * * @param {String} libFile - * @param {Object} opts + * @param {Object} opts * @param {String} opts.appId * @param {String} opts.sdkKey * @param {Number} opts.workSize @@ -133,11 +133,11 @@ class ArcFace { /** * extract face feature - * - * @param {TypeDef.ASVLOFFSCREEN} asvl - * @param {TypeDef.MRECT} rcFace - * @param {TypeDef.AFD_FSDK_OrientCode} orient - * @returns + * + * @param {TypeDef.ASVLOFFSCREEN} asvl + * @param {TypeDef.MRECT} rcFace + * @param {TypeDef.AFD_FSDK_OrientCode} orient + * @returns * @memberof Face */ extractFeature(asvl, rcFace, orient) { @@ -172,9 +172,9 @@ class ArcFace { /** * face compare - * - * @param {TypeDef.AFR_FSDK_FACEMODEL} faceModel1 - * @param {TypeDef.AFR_FSDK_FACEMODEL} faceModel2 + * + * @param {TypeDef.AFR_FSDK_FACEMODEL} faceModel1 + * @param {TypeDef.AFR_FSDK_FACEMODEL} faceModel2 * @returns {Number} similarity * @memberof Face */ @@ -195,8 +195,8 @@ class ArcFace { /** * face detect - * - * @param {TypeDef.ASVLOFFSCREEN} asvl + * + * @param {TypeDef.ASVLOFFSCREEN} asvl */ detect(asvl) { if (this.hFDEngine.isNull()) { @@ -239,9 +239,9 @@ class ArcFace { /** * parse image - * + * * @static - * @param {String} imgFile + * @param {String} imgFile * @returns {Promise.} * @memberof Face */ @@ -285,4 +285,4 @@ ArcFace.Lib = libc; ArcFace.TypeDef = TypeDef; ArcFace.Jimp = Jimp; -module.exports = ArcFace; \ No newline at end of file +module.exports = ArcFace; From d4fdceb92ccc6d52d8dada083bc9a7874a5c2be4 Mon Sep 17 00:00:00 2001 From: Bob Wei Date: Mon, 11 Jun 2018 00:02:05 +0800 Subject: [PATCH 2/2] Return array in stead of object --- lib/index.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/index.js b/lib/index.js index 353478e..8cd8ee4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -215,23 +215,21 @@ class ArcFace { const orientBuf = new Buffer(TypeDef.AFD_FSDK_OrientCode.size); // output faces - const faces = { - nFace: faceRes.nFace, - rcFace: [], - lfaceOrient: [] - }; + const faces = []; for (let i = 0; i < faceRes.nFace; ++i) { libc.memcpy(rect.ref().address(), faceRes.rcFace.address() + i * TypeDef.MRECT.size, TypeDef.MRECT.size) libc.memcpy(orientBuf.address(), faceRes.lfaceOrient.address() + i * TypeDef.AFD_FSDK_OrientCode.size, TypeDef.AFD_FSDK_OrientCode.size); - faces.rcFace.push({ - left: rect.left, - top: rect.top, - right: rect.right, - bottom: rect.bottom - }); - faces.lfaceOrient.push(ref.get(orientBuf, 0, TypeDef.AFD_FSDK_OrientCode)); + faces.push({ + rcFace: { + left: rect.left, + top: rect.top, + right: rect.right, + bottom: rect.bottom + }, + lfaceOrient: ref.get(orientBuf, 0, TypeDef.AFD_FSDK_OrientCode) + }) } return faces;