-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
48 lines (37 loc) · 1.46 KB
/
app.js
File metadata and controls
48 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const tf = require('@tensorflow/tfjs-node')
const fs = require('fs')
const faceapi = require('@vladmandic/face-api')
const loadLabeledDescriptors = require('./load-labeled-descriptors')
const getToken = require('./get-user')
const run = async () => {
while(true)
{
const { exec } = require("child_process")
exec('libcamera-jpeg -e jpg --immediate -n -t 1 -o /home/bianca/hera.cam/public/verify/test.jpg')
await faceapi.nets.ssdMobilenetv1.loadFromDisk('./public/models')
await faceapi.nets.faceLandmark68Net.loadFromDisk('./public/models')
await faceapi.nets.faceRecognitionNet.loadFromDisk('./public/models')
const token = await getToken()
console.log(token)
const verify = tf.node.decodeImage(fs.readFileSync('./public/verify/test.jpg'))
if(await faceapi.detectSingleFace(verify) !== undefined)
{
const singleResult = await faceapi
.detectSingleFace(verify)
.withFaceLandmarks()
.withFaceDescriptor()
const labeledFaceDescriptors = await loadLabeledDescriptors(token)
const faceMatcher = new faceapi.FaceMatcher(labeledFaceDescriptors, 0.6);
if (singleResult) {
const bestMatch = faceMatcher.findBestMatch(singleResult.descriptor)
console.log(bestMatch.toString())
if(bestMatch.distance < 0.6)
{
const spawn = require("child_process").spawn;
const pythonProcess = spawn('python',["run.py"])
}
}
}
}
}
run()