Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-027
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
1
Merge Requests
1
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
2022-027
2022-027
Commits
0ec547bd
Commit
0ec547bd
authored
Nov 14, 2022
by
Gunasena D K B
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
210f7c21
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
FaceIdentification/Basic.py
FaceIdentification/Basic.py
+25
-0
No files found.
FaceIdentification/Basic.py
0 → 100644
View file @
0ec547bd
import
cv2
import
numpy
as
np
import
face_recognition
imgElon
=
face_recognition
.
load_image_file
(
'ImagesBasic/Me Test.JPG'
)
imgElon
=
cv2
.
cvtColor
(
imgElon
,
cv2
.
COLOR_BGR2RGB
)
imgTest
=
face_recognition
.
load_image_file
(
'ImagesBasic/Hesith.jpg'
)
imgTest
=
cv2
.
cvtColor
(
imgTest
,
cv2
.
COLOR_BGR2RGB
)
faceLoc
=
face_recognition
.
face_locations
(
imgElon
)[
0
]
encodeElon
=
face_recognition
.
face_encodings
(
imgElon
)[
0
]
cv2
.
rectangle
(
imgElon
,
(
faceLoc
[
3
],
faceLoc
[
0
]),
(
faceLoc
[
1
],
faceLoc
[
2
]),
(
255
,
0
,
255
),
2
)
faceLocTest
=
face_recognition
.
face_locations
(
imgTest
)[
0
]
encodeTest
=
face_recognition
.
face_encodings
(
imgTest
)[
0
]
cv2
.
rectangle
(
imgTest
,
(
faceLocTest
[
3
],
faceLocTest
[
0
]),
(
faceLocTest
[
1
],
faceLocTest
[
2
]),
(
255
,
0
,
255
),
2
)
results
=
face_recognition
.
compare_faces
([
encodeElon
],
encodeTest
)
faceDis
=
face_recognition
.
face_distance
([
encodeElon
],
encodeTest
)
print
(
results
,
faceDis
)
cv2
.
putText
(
imgTest
,
f
'{results} {round(faceDis[0], 2)}'
,
(
50
,
50
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
1
,
(
0
,
0
,
255
),
2
)
cv2
.
imshow
(
'Original'
,
imgElon
)
cv2
.
imshow
(
'Test'
,
imgTest
)
cv2
.
waitKey
(
0
)
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