Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
face
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
face
Commits
e781c566
Commit
e781c566
authored
Jun 11, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjusted detection and recognition example
parent
623052ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
8 deletions
+42
-8
detectAndRecognizeFaces.html
examples/views/detectAndRecognizeFaces.html
+42
-8
No files found.
examples/views/detectAndRecognizeFaces.html
View file @
e781c566
...
@@ -27,13 +27,29 @@
...
@@ -27,13 +27,29 @@
</div>
</div>
<button
<button
class=
"waves-effect waves-light btn"
class=
"waves-effect waves-light btn"
onclick=
"onDecrease
Threshold
()"
onclick=
"onDecrease
MinConfidence
()"
>
>
<i
class=
"material-icons left"
>
-
</i>
<i
class=
"material-icons left"
>
-
</i>
</button>
</button>
<button
<button
class=
"waves-effect waves-light btn"
class=
"waves-effect waves-light btn"
onclick=
"onIncreaseThreshold()"
onclick=
"onIncreaseMinConfidence()"
>
<i
class=
"material-icons left"
>
+
</i>
</button>
<div
class=
"row"
>
<label
for=
"maxDistance"
>
Max Descriptor Distance:
</label>
<input
disabled
value=
"0.8"
id=
"maxDistance"
type=
"text"
class=
"bold"
>
</div>
<button
class=
"waves-effect waves-light btn"
onclick=
"onDecreaseMaxDistance()"
>
<i
class=
"material-icons left"
>
-
</i>
</button>
<button
class=
"waves-effect waves-light btn"
onclick=
"onIncreaseMaxDistance()"
>
>
<i
class=
"material-icons left"
>
+
</i>
<i
class=
"material-icons left"
>
+
</i>
</button>
</button>
...
@@ -41,23 +57,35 @@
...
@@ -41,23 +57,35 @@
</div>
</div>
<script>
<script>
const
threshold
=
0.8
let
maxDistance
=
0.8
let
minConfidence
=
0.7
let
minConfidence
=
0.7
let
detectionNet
,
recognitionNet
let
detectionNet
,
recognitionNet
let
trainDescriptorsByClass
=
[]
let
trainDescriptorsByClass
=
[]
function
onIncrease
Threshold
()
{
function
onIncrease
MinConfidence
()
{
minConfidence
=
Math
.
min
(
faceapi
.
round
(
minConfidence
+
0.1
),
1.0
)
minConfidence
=
Math
.
min
(
faceapi
.
round
(
minConfidence
+
0.1
),
1.0
)
$
(
'#minConfidence'
).
val
(
minConfidence
)
$
(
'#minConfidence'
).
val
(
minConfidence
)
updateResults
()
updateResults
()
}
}
function
onDecrease
Threshold
()
{
function
onDecrease
MinConfidence
()
{
minConfidence
=
Math
.
max
(
faceapi
.
round
(
minConfidence
-
0.1
),
0.1
)
minConfidence
=
Math
.
max
(
faceapi
.
round
(
minConfidence
-
0.1
),
0.1
)
$
(
'#minConfidence'
).
val
(
minConfidence
)
$
(
'#minConfidence'
).
val
(
minConfidence
)
updateResults
()
updateResults
()
}
}
function
onIncreaseMaxDistance
()
{
maxDistance
=
Math
.
min
(
faceapi
.
round
(
maxDistance
+
0.1
),
1.0
)
$
(
'#maxDistance'
).
val
(
maxDistance
)
updateResults
()
}
function
onDecreaseMaxDistance
()
{
maxDistance
=
Math
.
max
(
faceapi
.
round
(
maxDistance
-
0.1
),
0.1
)
$
(
'#maxDistance'
).
val
(
maxDistance
)
updateResults
()
}
async
function
updateResults
()
{
async
function
updateResults
()
{
const
inputImgEl
=
$
(
'#inputImg'
).
get
(
0
)
const
inputImgEl
=
$
(
'#inputImg'
).
get
(
0
)
const
{
width
,
height
}
=
inputImgEl
const
{
width
,
height
}
=
inputImgEl
...
@@ -79,9 +107,15 @@
...
@@ -79,9 +107,15 @@
descriptors
.
forEach
((
descriptor
,
i
)
=>
{
descriptors
.
forEach
((
descriptor
,
i
)
=>
{
const
bestMatch
=
getBestMatch
(
trainDescriptorsByClass
,
descriptor
)
const
bestMatch
=
getBestMatch
(
trainDescriptorsByClass
,
descriptor
)
const
text
=
`
${
bestMatch
.
distance
<
threshold
?
bestMatch
.
className
:
'unkown'
}
(
${
bestMatch
.
distance
}
)`
const
text
=
`
${
bestMatch
.
distance
<
maxDistance
?
bestMatch
.
className
:
'unkown'
}
(
${
bestMatch
.
distance
}
)`
const
{
x
,
y
}
=
detectionsForSize
[
i
].
box
const
{
x
,
y
,
height
:
boxHeight
}
=
detectionsForSize
[
i
].
box
faceapi
.
drawText
(
canvas
.
getContext
(
'2d'
),
x
,
y
,
text
,
faceapi
.
getDefaultDrawOptions
())
faceapi
.
drawText
(
canvas
.
getContext
(
'2d'
),
x
,
y
+
boxHeight
,
text
,
Object
.
assign
(
faceapi
.
getDefaultDrawOptions
(),
{
color
:
'red'
,
fontSize
:
16
})
)
})
})
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment