Commit 0b4470af by vincent

faceapi.round -> faceapi.utils.round

parent 5df8e27a
...@@ -26,13 +26,13 @@ function getFaceDetectorOptions() { ...@@ -26,13 +26,13 @@ function getFaceDetectorOptions() {
} }
function onIncreaseMinConfidence() { function onIncreaseMinConfidence() {
minConfidence = Math.min(faceapi.round(minConfidence + 0.1), 1.0) minConfidence = Math.min(faceapi.utils.round(minConfidence + 0.1), 1.0)
$('#minConfidence').val(minConfidence) $('#minConfidence').val(minConfidence)
updateResults() updateResults()
} }
function onDecreaseMinConfidence() { function onDecreaseMinConfidence() {
minConfidence = Math.max(faceapi.round(minConfidence - 0.1), 0.1) minConfidence = Math.max(faceapi.utils.round(minConfidence - 0.1), 0.1)
$('#minConfidence').val(minConfidence) $('#minConfidence').val(minConfidence)
updateResults() updateResults()
} }
...@@ -51,24 +51,24 @@ function changeInputSize(size) { ...@@ -51,24 +51,24 @@ function changeInputSize(size) {
} }
function onIncreaseScoreThreshold() { function onIncreaseScoreThreshold() {
scoreThreshold = Math.min(faceapi.round(scoreThreshold + 0.1), 1.0) scoreThreshold = Math.min(faceapi.utils.round(scoreThreshold + 0.1), 1.0)
$('#scoreThreshold').val(scoreThreshold) $('#scoreThreshold').val(scoreThreshold)
updateResults() updateResults()
} }
function onDecreaseScoreThreshold() { function onDecreaseScoreThreshold() {
scoreThreshold = Math.max(faceapi.round(scoreThreshold - 0.1), 0.1) scoreThreshold = Math.max(faceapi.utils.round(scoreThreshold - 0.1), 0.1)
$('#scoreThreshold').val(scoreThreshold) $('#scoreThreshold').val(scoreThreshold)
updateResults() updateResults()
} }
function onIncreaseMinFaceSize() { function onIncreaseMinFaceSize() {
minFaceSize = Math.min(faceapi.round(minFaceSize + 20), 300) minFaceSize = Math.min(faceapi.utils.round(minFaceSize + 20), 300)
$('#minFaceSize').val(minFaceSize) $('#minFaceSize').val(minFaceSize)
} }
function onDecreaseMinFaceSize() { function onDecreaseMinFaceSize() {
minFaceSize = Math.max(faceapi.round(minFaceSize - 20), 50) minFaceSize = Math.max(faceapi.utils.round(minFaceSize - 20), 50)
$('#minFaceSize').val(minFaceSize) $('#minFaceSize').val(minFaceSize)
} }
......
...@@ -161,8 +161,8 @@ ...@@ -161,8 +161,8 @@
const { age, gender, genderProbability } = result const { age, gender, genderProbability } = result
new faceapi.draw.DrawTextField( new faceapi.draw.DrawTextField(
[ [
`${faceapi.round(age, 0)} years`, `${faceapi.utils.round(age, 0)} years`,
`${gender} (${faceapi.round(genderProbability)})` `${gender} (${faceapi.utils.round(genderProbability)})`
], ],
result.detection.box.bottomLeft result.detection.box.bottomLeft
).draw(canvas) ).draw(canvas)
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
function displayTimeStats(timeInMs) { function displayTimeStats(timeInMs) {
$('#time').val(`${timeInMs} ms`) $('#time').val(`${timeInMs} ms`)
$('#fps').val(`${faceapi.round(1000 / timeInMs)}`) $('#fps').val(`${faceapi.utils.round(1000 / timeInMs)}`)
} }
function displayImage(src) { function displayImage(src) {
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
let descriptors = { desc1: null, desc2: null } let descriptors = { desc1: null, desc2: null }
function updateResult() { function updateResult() {
const distance = faceapi.round( const distance = faceapi.utils.round(
faceapi.euclideanDistance(descriptors.desc1, descriptors.desc2) faceapi.euclideanDistance(descriptors.desc1, descriptors.desc2)
) )
let text = distance let text = distance
......
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30) forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30)
const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length
$('#time').val(`${Math.round(avgTimeInMs)} ms`) $('#time').val(`${Math.round(avgTimeInMs)} ms`)
$('#fps').val(`${faceapi.round(1000 / avgTimeInMs)}`) $('#fps').val(`${faceapi.utils.round(1000 / avgTimeInMs)}`)
} }
async function onPlay(videoEl) { async function onPlay(videoEl) {
......
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30) forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30)
const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length
$('#time').val(`${Math.round(avgTimeInMs)} ms`) $('#time').val(`${Math.round(avgTimeInMs)} ms`)
$('#fps').val(`${faceapi.round(1000 / avgTimeInMs)}`) $('#fps').val(`${faceapi.utils.round(1000 / avgTimeInMs)}`)
} }
function interpolateAgePredictions(age) { function interpolateAgePredictions(age) {
...@@ -192,8 +192,8 @@ ...@@ -192,8 +192,8 @@
const interpolatedAge = interpolateAgePredictions(age) const interpolatedAge = interpolateAgePredictions(age)
new faceapi.draw.DrawTextField( new faceapi.draw.DrawTextField(
[ [
`${faceapi.round(interpolatedAge, 0)} years`, `${faceapi.utils.round(interpolatedAge, 0)} years`,
`${gender} (${faceapi.round(genderProbability)})` `${gender} (${faceapi.utils.round(genderProbability)})`
], ],
result.detection.box.bottomLeft result.detection.box.bottomLeft
).draw(canvas) ).draw(canvas)
......
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30) forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30)
const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length
$('#time').val(`${Math.round(avgTimeInMs)} ms`) $('#time').val(`${Math.round(avgTimeInMs)} ms`)
$('#fps').val(`${faceapi.round(1000 / avgTimeInMs)}`) $('#fps').val(`${faceapi.utils.round(1000 / avgTimeInMs)}`)
} }
async function onPlay() { async function onPlay() {
......
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30) forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30)
const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length
$('#time').val(`${Math.round(avgTimeInMs)} ms`) $('#time').val(`${Math.round(avgTimeInMs)} ms`)
$('#fps').val(`${faceapi.round(1000 / avgTimeInMs)}`) $('#fps').val(`${faceapi.utils.round(1000 / avgTimeInMs)}`)
} }
async function onPlay() { async function onPlay() {
......
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30) forwardTimes = [timeInMs].concat(forwardTimes).slice(0, 30)
const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length const avgTimeInMs = forwardTimes.reduce((total, t) => total + t) / forwardTimes.length
$('#time').val(`${Math.round(avgTimeInMs)} ms`) $('#time').val(`${Math.round(avgTimeInMs)} ms`)
$('#fps').val(`${faceapi.round(1000 / avgTimeInMs)}`) $('#fps').val(`${faceapi.utils.round(1000 / avgTimeInMs)}`)
} }
async function onPlay() { async function onPlay() {
......
...@@ -19,8 +19,8 @@ async function run() { ...@@ -19,8 +19,8 @@ async function run() {
const { age, gender, genderProbability } = result const { age, gender, genderProbability } = result
new faceapi.draw.DrawTextField( new faceapi.draw.DrawTextField(
[ [
`${faceapi.round(age, 0)} years`, `${faceapi.utils.round(age, 0)} years`,
`${gender} (${faceapi.round(genderProbability)})` `${gender} (${faceapi.utils.round(genderProbability)})`
], ],
result.detection.box.bottomLeft result.detection.box.bottomLeft
).draw(out) ).draw(out)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment