Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
21_22-J-02
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J-02
21_22-J-02
Commits
3ad2752d
Commit
3ad2752d
authored
Apr 10, 2022
by
NaweenTharuka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unwanted files removed
parent
1c5aea57
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
46 deletions
+0
-46
Emotion_Video/main.py
Emotion_Video/main.py
+0
-46
Emotion_Video/model.h5
Emotion_Video/model.h5
+0
-0
No files found.
Emotion_Video/main.py
deleted
100644 → 0
View file @
1c5aea57
from
keras.models
import
load_model
from
time
import
sleep
from
keras.preprocessing.image
import
img_to_array
from
keras.preprocessing
import
image
import
cv2
import
numpy
as
np
face_classifier
=
cv2
.
CascadeClassifier
(
r'F:\SLIIT\Research Project\New folder\Emotion Classification\haarcascade_frontalface_default.xml'
)
classifier
=
load_model
(
r'F:\SLIIT\Research Project\New folder\Emotion Classification\model.h5'
)
emotion_labels
=
[
'Angry'
,
'Disgust'
,
'Fear'
,
'Happy'
,
'Neutral'
,
'Sad'
,
'Surprise'
]
cap
=
cv2
.
VideoCapture
(
0
)
while
True
:
_
,
frame
=
cap
.
read
()
labels
=
[]
gray
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2GRAY
)
faces
=
face_classifier
.
detectMultiScale
(
gray
)
for
(
x
,
y
,
w
,
h
)
in
faces
:
cv2
.
rectangle
(
frame
,(
x
,
y
),(
x
+
w
,
y
+
h
),(
0
,
255
,
255
),
2
)
roi_gray
=
gray
[
y
:
y
+
h
,
x
:
x
+
w
]
roi_gray
=
cv2
.
resize
(
roi_gray
,(
48
,
48
),
interpolation
=
cv2
.
INTER_AREA
)
if
np
.
sum
([
roi_gray
])
!=
0
:
roi
=
roi_gray
.
astype
(
'float'
)
/
255.0
roi
=
img_to_array
(
roi
)
roi
=
np
.
expand_dims
(
roi
,
axis
=
0
)
prediction
=
classifier
.
predict
(
roi
)[
0
]
label
=
emotion_labels
[
prediction
.
argmax
()]
label_position
=
(
x
,
y
-
10
)
cv2
.
putText
(
frame
,
label
,
label_position
,
cv2
.
FONT_HERSHEY_SIMPLEX
,
1
,(
0
,
255
,
0
),
2
)
else
:
cv2
.
putText
(
frame
,
'No Faces'
,(
30
,
80
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
1
,(
0
,
255
,
0
),
2
)
cv2
.
imshow
(
'Emotion Detector'
,
frame
)
if
cv2
.
waitKey
(
1
)
&
0xFF
==
ord
(
'q'
):
break
cap
.
release
()
cv2
.
destroyAllWindows
()
\ No newline at end of file
Emotion_Video/model.h5
deleted
100644 → 0
View file @
1c5aea57
File deleted
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