Integrating face recognition
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
045bf530a1
commit
de0fa69417
35
face.js
Normal file
35
face.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
const fr = require('face-recognition')
|
||||||
|
|
||||||
|
if (process.argc <= 2) {
|
||||||
|
console.log("Usage: node face image");
|
||||||
|
process.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const filename = process.argv[2];
|
||||||
|
|
||||||
|
console.log("Loading " + filename);
|
||||||
|
const image = fr.loadImage(filename)
|
||||||
|
const detector = fr.FaceDetector()
|
||||||
|
|
||||||
|
console.log("Detecting faces...");
|
||||||
|
const faceRectangles = detector.locateFaces(image)
|
||||||
|
|
||||||
|
/* 200x200 picture faces */
|
||||||
|
const faceImages = detector.detectFaces(image, 200)
|
||||||
|
console.log("Writing " + faceImages.length + " faces.");
|
||||||
|
|
||||||
|
const fs = require("fs"),
|
||||||
|
path = require("path");
|
||||||
|
const filepath = path.dirname(filename) + "/faces";
|
||||||
|
try {
|
||||||
|
fs.statSync(filepath);
|
||||||
|
} catch (error) {
|
||||||
|
fs.mkdirSync(filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
faceImages.forEach(function(face, index) {
|
||||||
|
let target = filepath + "/" + path.basename(filename).replace(/.(png|jpg|jpeg)$/, "-face-" + (index + 1));
|
||||||
|
faceRectangles[index].filename = filename;
|
||||||
|
fs.writeFileSync(target + ".nfo", JSON.stringify(faceRectangles[index], null, 2));
|
||||||
|
fr.saveImage(target + ".png", face);
|
||||||
|
});
|
@ -21,6 +21,7 @@
|
|||||||
"exif-reader": "github:paras20xx/exif-reader",
|
"exif-reader": "github:paras20xx/exif-reader",
|
||||||
"express": "^4.16.2",
|
"express": "^4.16.2",
|
||||||
"express-session": "^1.15.6",
|
"express-session": "^1.15.6",
|
||||||
|
"face-recognition": "^0.9.4",
|
||||||
"handlebars": "^4.0.12",
|
"handlebars": "^4.0.12",
|
||||||
"ldapauth-fork": "^4.0.2",
|
"ldapauth-fork": "^4.0.2",
|
||||||
"mariasql": "^0.2.6",
|
"mariasql": "^0.2.6",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user