Skip to content

Instantly share code, notes, and snippets.

@yerkbn
Last active April 24, 2019 21:06
Show Gist options
  • Save yerkbn/9d6521745a59a30955c0bc8839f077ef to your computer and use it in GitHub Desktop.
Save yerkbn/9d6521745a59a30955c0bc8839f077ef to your computer and use it in GitHub Desktop.
def video_parser(video_name = "videos/{}".format("vid1.mp4")):
video_capture = cv2.VideoCapture(video_name)
OFFSET = 50
OFFSET_TOP = 100
QUALITY = 0.25
CLASSES = {
"lannister": ['tyrion', 'cersei', 'jaime', 'joffery', 'myrcella', 'tommen', 'tywin'],
#-----------------------
"stark": ['arya', 'brandon', 'eddard', 'robb', 'sansa']
}
known_face_encodings = []
# [2] ADD THAT NAME HERE ALSO
known_face_names = [
"tyrion",
'cersei',
'jaime',
'joffery',
'myrcella',
'tommen',
'tywin',
"arya",
'arya',
'brandon',
'eddard',
'robb',
'sansa'
]
# [3] ADD IMAGE WITH NAME.JPG FORMAT TO FACES/ FOLDER
# mapping
for name in known_face_names:
temp_image = face_recognition.load_image_file("faces/{}.jpg".format(name))
temp_encoding = face_recognition.face_encodings(temp_image)[0]
known_face_encodings.append(temp_encoding)
# Initialize some variables
face_locations = []
face_encodings = []
face_names = []
process_this_frame = True
COUNT = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment