Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Facial expression detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Automatants
Facial expression detection
Commits
176ba232
Commit
176ba232
authored
4 years ago
by
Timothé Boulet
Browse files
Options
Downloads
Patches
Plain Diff
add selectFace
parent
74de12d8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
imageProcess.py
+20
-1
20 additions, 1 deletion
imageProcess.py
with
20 additions
and
1 deletion
imageProcess.py
+
20
−
1
View file @
176ba232
...
...
@@ -32,3 +32,22 @@ def imageProcess(image):
#Write emotion on the image
emotion
=
fa
.
detectEmotion
(
face_color
)
cv2
.
putText
(
image
,
emotion
,
(
x
,
y
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
1
,
(
255
,
0
,
0
),
2
)
def
selectFace
(
image
):
#Return a face identified on an colored image
#Import cv2 face detector
face_cascade
=
cv2
.
CascadeClassifier
(
cv2
.
data
.
haarcascades
+
'
haarcascade_frontalface_default.xml
'
)
#Face detection is made on gray images
gray
=
cv2
.
cvtColor
(
image
,
cv2
.
COLOR_BGR2GRAY
)
faces
=
face_cascade
.
detectMultiScale
(
gray
,
1.3
,
5
)
#This return a list of tuple locating faces on image
#The face returned is the first face detected on the image (if exists)
if
faces
!=
[]:
x
,
y
,
w
,
h
=
faces
[
0
]
face
=
image
[
y
:
y
+
h
,
x
:
x
+
w
]
return
face
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment