update
This commit is contained in:
parent
b908185658
commit
38780c56a8
|
|
@ -1,8 +1,7 @@
|
||||||
pyttsx3
|
#MacOS
|
||||||
openpyxl
|
python3 -m venv path/to/venv
|
||||||
pyzbar
|
source path/to/venv/bin/activate
|
||||||
opencv-python
|
pip install pyttsx3 openpyxl pyzbar opencv-python qrcode pyautogui requests pillow
|
||||||
qrcode
|
pip install wheel setuptools pip --upgrade
|
||||||
pyautogui
|
pip install git+https://github.com/ageitgey/face_recognition_models --verbose
|
||||||
requests
|
pip install face_recognition
|
||||||
pillow
|
|
||||||
|
|
@ -8,7 +8,7 @@ from datetime import datetime
|
||||||
import requests
|
import requests
|
||||||
import face_recognition
|
import face_recognition
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pickle
|
import pickle
|
||||||
# Khởi tạo danh sách rỗng để lưu trữ thông tin người dùng
|
# Khởi tạo danh sách rỗng để lưu trữ thông tin người dùng
|
||||||
user_data = []
|
user_data = []
|
||||||
history = []
|
history = []
|
||||||
|
|
@ -180,10 +180,10 @@ def process_qr_code(frame):
|
||||||
cv.resizeWindow(WINDOW_QR_CODE, screen_width, screen_height)
|
cv.resizeWindow(WINDOW_QR_CODE, screen_width, screen_height)
|
||||||
cv.imshow(WINDOW_QR_CODE, frame)
|
cv.imshow(WINDOW_QR_CODE, frame)
|
||||||
cv.moveWindow(WINDOW_QR_CODE, 10, 10)
|
cv.moveWindow(WINDOW_QR_CODE, 10, 10)
|
||||||
cv.waitKey(5000) # Chờ 5 giây
|
cv.waitKey(3000) # Chờ 5 giây
|
||||||
screenshot_window(file_name)
|
screenshot_window(file_name)
|
||||||
send_image(id_log, file_name)
|
|
||||||
cv.destroyWindow(WINDOW_QR_CODE)
|
cv.destroyWindow(WINDOW_QR_CODE)
|
||||||
|
send_image(id_log, file_name)
|
||||||
else:
|
else:
|
||||||
display_text(frame, f"QR invalid", (25, 25), 0.7, (6, 6, 255), 2)
|
display_text(frame, f"QR invalid", (25, 25), 0.7, (6, 6, 255), 2)
|
||||||
display_text(frame, f"Failed", (25, 50), 0.7, (6, 6, 255), 2)
|
display_text(frame, f"Failed", (25, 50), 0.7, (6, 6, 255), 2)
|
||||||
|
|
@ -216,14 +216,15 @@ def process_face_detect(text, frame):
|
||||||
# screenshot_window(file_name)
|
# screenshot_window(file_name)
|
||||||
res = check_out(text, frame, text)
|
res = check_out(text, frame, text)
|
||||||
id_log = res.get('data').get('id')
|
id_log = res.get('data').get('id')
|
||||||
|
screenshot_window(file_name)
|
||||||
cv.namedWindow(WINDOW_QR_CODE, cv.WINDOW_NORMAL)
|
cv.namedWindow(WINDOW_QR_CODE, cv.WINDOW_NORMAL)
|
||||||
cv.resizeWindow(WINDOW_QR_CODE, screen_width, screen_height)
|
cv.resizeWindow(WINDOW_QR_CODE, screen_width, screen_height)
|
||||||
cv.imshow(WINDOW_QR_CODE, frame)
|
cv.imshow(WINDOW_QR_CODE, frame)
|
||||||
cv.moveWindow(WINDOW_QR_CODE, 10, 10)
|
cv.moveWindow(WINDOW_QR_CODE, 10, 10)
|
||||||
cv.waitKey(5000) # Chờ 5 giây
|
# Chạy vòng lặp không chặn trong 2 giây
|
||||||
screenshot_window(file_name)
|
cv.waitKey(2000) # Chờ 10ms
|
||||||
send_image(id_log, file_name)
|
|
||||||
cv.destroyWindow(WINDOW_QR_CODE)
|
cv.destroyWindow(WINDOW_QR_CODE)
|
||||||
|
send_image(id_log, file_name)
|
||||||
else:
|
else:
|
||||||
display_text(frame, f"QR invalid", (25, 25), 0.7, (6, 6, 255), 2)
|
display_text(frame, f"QR invalid", (25, 25), 0.7, (6, 6, 255), 2)
|
||||||
display_text(frame, f"Failed", (25, 50), 0.7, (6, 6, 255), 2)
|
display_text(frame, f"Failed", (25, 50), 0.7, (6, 6, 255), 2)
|
||||||
|
|
@ -271,16 +272,16 @@ def main():
|
||||||
if not ret:
|
if not ret:
|
||||||
break
|
break
|
||||||
|
|
||||||
frameS = cv.resize(frame, (0,0), None, fx=1, fy=1)
|
frameS = cv.resize(frame, (0,0), None, fx=0.5, fy=0.5)
|
||||||
frameS = cv.cvtColor(frameS, cv.COLOR_BGR2RGB)
|
frameS = cv.cvtColor(frameS, cv.COLOR_BGR2RGB)
|
||||||
|
|
||||||
faceCurFrame = face_recognition.face_locations(frameS)
|
faceCurFrame = face_recognition.face_locations(frameS, model='hog')
|
||||||
encodeCurFrame = face_recognition.face_encodings(frameS)
|
encodeCurFrame = face_recognition.face_encodings(frameS)
|
||||||
frame = process_qr_code(frame)
|
frame = process_qr_code(frame)
|
||||||
for encodeFace, faceLoc in zip(encodeCurFrame, faceCurFrame):
|
for encodeFace, faceLoc in zip(encodeCurFrame, faceCurFrame):
|
||||||
matches = face_recognition.compare_faces(encodeListKnow, encodeFace)
|
matches = face_recognition.compare_faces(encodeListKnow, encodeFace)
|
||||||
faceDis = face_recognition.face_distance(encodeListKnow, encodeFace)
|
faceDis = face_recognition.face_distance(encodeListKnow, encodeFace)
|
||||||
print(faceDis)
|
# print(faceDis)
|
||||||
matchIndex = np.argmin(faceDis)
|
matchIndex = np.argmin(faceDis)
|
||||||
|
|
||||||
if faceDis[matchIndex] < 0.3:
|
if faceDis[matchIndex] < 0.3:
|
||||||
|
|
@ -290,9 +291,9 @@ def main():
|
||||||
name = "Unknow"
|
name = "Unknow"
|
||||||
display_text(frame, f"Face not found - use QRcode", (20, 55), 0.7, (6, 6, 255), 2)
|
display_text(frame, f"Face not found - use QRcode", (20, 55), 0.7, (6, 6, 255), 2)
|
||||||
y1, x2, y2, x1 = faceLoc
|
y1, x2, y2, x1 = faceLoc
|
||||||
y1, x2, y2, x1 = y1, x2, y2, x1
|
y1, x2, y2, x1 = y1*2, x2*2, y2*2, x1*2
|
||||||
cv.rectangle(frame, (x1,y1), (x2,y2), (0,255,0), 2)
|
cv.rectangle(frame, (x1,y1), (x2,y2), (0,255,0), 2)
|
||||||
cv.putText(frame, name + f"({(1 - round(faceDis[matchIndex], 2))*100}%)", (20, 25), cv.FONT_HERSHEY_COMPLEX, 1, (255,255,255), 2)
|
cv.putText(frame, name + f"({(1 - round(faceDis[matchIndex], 2))*100}%) - CHECKED", (20, 25), cv.FONT_HERSHEY_COMPLEX, 1, (255,255,255), 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -324,4 +325,5 @@ def main():
|
||||||
cap.release()
|
cap.release()
|
||||||
cv.destroyAllWindows()
|
cv.destroyAllWindows()
|
||||||
|
|
||||||
main()
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in New Issue