Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
MD_KHANDAKER_6001CEM/face.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
25 lines (19 sloc)
659 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
from deepface import DeepFace | |
url = "http://100.84.177.205:4747/video" | |
cap = cv2.VideoCapture(url) | |
while True: | |
ret, frame = cap.read() | |
cv2.imshow('Press Space to capture', frame) | |
if cv2.waitKey(1) & 0xFF == ord(' '): # Press space to capture | |
cv2.imwrite('./data/live_image.jpg', frame) # Save the captured image | |
break | |
cap.release() | |
cv2.destroyAllWindows() | |
obj = DeepFace.analyze(img_path="./data/live_image.jpg", actions=['age']) | |
print(obj) | |
age_restriction = 18 | |
if obj[0]["age"] >= age_restriction: | |
print("Access granted.") | |
else: | |
print("Access denied. Age restriction not met.") |