Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
21-22J-056
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-22J-056
21-22J-056
Commits
ea7b7ba3
Commit
ea7b7ba3
authored
Jan 12, 2022
by
Davis E.J.A iIT18107456
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
frontal face
parent
99357b97
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
pregnentface.py
pregnentface.py
+35
-0
No files found.
pregnentface.py
0 → 100644
View file @
ea7b7ba3
# Importing the libraries
import
cv2
# Load the cascades
face_cascade
=
cv2
.
CascadeClassifier
(
'frontalface_cascade.xml'
)
eye_cascade
=
cv2
.
CascadeClassifier
(
'eyes_cascade.xml'
)
smile_cascade
=
cv2
.
CascadeClassifier
(
'Smile_cascade.xml'
)
# Defining a function that will do the detections
def
detect
(
gray
,
frame
):
faces
=
face_cascade
.
detectMultiScale
(
gray
,
1.3
,
5
)
for
(
x
,
y
,
w
,
h
)
in
faces
:
cv2
.
rectangle
(
frame
,
(
x
,
y
),
(
x
+
w
,
y
+
h
),
(
255
,
0
,
0
),
2
)
roi_gray
=
gray
[
y
:
y
+
h
,
x
:
x
+
w
]
roi_color
=
frame
[
y
:
y
+
h
,
x
:
x
+
w
]
eyes
=
eye_cascade
.
detectMultiScale
(
roi_gray
,
1.1
,
22
)
for
(
ex
,
ey
,
ew
,
eh
)
in
eyes
:
cv2
.
rectangle
(
roi_color
,
(
ex
,
ey
),
(
ex
+
ew
,
ey
+
eh
),
(
0
,
255
,
0
),
2
)
smiles
=
smile_cascade
.
detectMultiScale
(
roi_gray
,
1.7
,
19
)
for
(
sx
,
sy
,
sw
,
sh
)
in
smiles
:
cv2
.
rectangle
(
roi_color
,
(
sx
,
sy
),
(
sx
+
sw
,
sy
+
sh
),
(
0
,
0
,
255
),
5
)
return
frame
# Doing some Face Recognition with the webcam
video_capture
=
cv2
.
VideoCapture
(
0
)
while
True
:
_
,
frame
=
video_capture
.
read
()
gray
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2GRAY
)
canvas
=
detect
(
gray
,
frame
)
cv2
.
imshow
(
'Video'
,
canvas
)
if
cv2
.
waitKey
(
1
)
&
0xFF
==
ord
(
'q'
):
break
video_capture
.
release
()
cv2
.
destroyAllWindows
()
\ No newline at end of file
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