Pembuatan Program
Pembuatan Program
Pembuatan Program
# PENGGUNAAN
import face_recognition
import argparse
import pickle
import cv2
import os
# Parsing Argumen
ap = argparse.ArgumentParser()
1
ap.add_argument("-e", "--encodings", required=True,
args = vars(ap.parse_args())
imagePaths = list(paths.list_images(args["dataset"]))
knownEncodings = []
knownNames = []
len(imagePaths)))
2
name = imagePath.split(os.path.sep)[-2]
image = cv2.imread(imagePath)
boxes = face_recognition.face_locations(rgb,
model=args["detection_method"])
# Pemrosesan Wajah
knownEncodings.append(encoding)
knownNames.append(name)
3
print("[INFO] Memproses serialize encoding...")
f = open(args["encodings"], "wb")
f.write(pickle.dumps(data))
f.close()
# PENGGUNAAN
import face_recognition
import argparse
import imutils
import pickle
import time
import cv2
4
# Parsing Argumen
ap = argparse.ArgumentParser()
args = vars(ap.parse_args())
detector = cv2.CascadeClassifier(args["cascade"])
# Nyalakan Kamera
vs = VideoStream(src=0).start()
time.sleep(2.0)
5
# Penghitung FPS (Frame per Second)
fps = FPS().start()
while True:
frame = vs.read()
flags=cv2.CASCADE_SCALE_IMAGE)
6
boxes = [(y, x + w, y + h, x) for (x, y, w, h) in rects]
names = []
matches = face_recognition.compare_faces(data["encodings"],
encoding)
name = "Unknown"
if True in matches:
counts = {}
for i in matchedIdxs:
name = data["names"][i]
counts[name] = counts.get(name, 0) + 1
7
names.append(name)
cv2.imshow("Frame", frame)
if key == ord("q"):
break
8
# update FPS
fps.update()
fps.stop()
# cleanup
cv2.destroyAllWindows()
vs.stop()