Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 29 additions & 31 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
*/
Expand All @@ -195,8 +195,8 @@ class ArcFace {

/**
* face detect
*
* @param {TypeDef.ASVLOFFSCREEN} asvl
*
* @param {TypeDef.ASVLOFFSCREEN} asvl
*/
detect(asvl) {
if (this.hFDEngine.isNull()) {
Expand All @@ -215,33 +215,31 @@ 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;
}

/**
* parse image
*
*
* @static
* @param {String} imgFile
* @param {String} imgFile
* @returns {Promise.<ASVLOFFSCREEN>}
* @memberof Face
*/
Expand Down Expand Up @@ -285,4 +283,4 @@ ArcFace.Lib = libc;
ArcFace.TypeDef = TypeDef;
ArcFace.Jimp = Jimp;

module.exports = ArcFace;
module.exports = ArcFace;