-
Notifications
You must be signed in to change notification settings - Fork 0
/
callPy.js
55 lines (51 loc) · 1.36 KB
/
callPy.js
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
49
50
51
52
53
54
55
const exec = require('child_process').exec;
function getVec(imgPath) {
return new Promise((resolve, reject) => {
const cmdStr = `py ./py/easydl.py --test ./${imgPath}`;
console.log(`推导:${cmdStr}`);
exec(cmdStr, function (err, stdout, stderr) {
if (err) {
console.log(err);
reject(stderr);
} else {
const data = JSON.parse(stdout);
resolve(data);
}
});
})
}
function faceDetect(imgPath) {
return new Promise((resolve, reject) => {
const cmdStr = `py ./py/slashFace.py --test ./${imgPath} --method detect`;
console.log(`推导:${cmdStr}`);
exec(cmdStr, function (err, stdout, stderr) {
if (err) {
console.log(err);
reject(stderr);
} else {
const data = JSON.parse(stdout);
resolve(data);
}
});
})
}
function faceDistance(imgPaths) {
return new Promise((resolve, reject) => {
const cmdStr = `py ./py/slashFace.py --test ./${imgPaths.join(',')} --method distance`;
console.log(`推导:${cmdStr}`);
exec(cmdStr, function (err, stdout, stderr) {
if (err) {
console.log(err);
reject(stderr);
} else {
const data = JSON.parse(stdout);
resolve(data);
}
});
})
}
module.exports = {
getVec,
faceDetect,
faceDistance
}