update
This commit is contained in:
parent
b908185658
commit
38780c56a8
|
|
@ -1,8 +1,7 @@
|
|||
pyttsx3
|
||||
openpyxl
|
||||
pyzbar
|
||||
opencv-python
|
||||
qrcode
|
||||
pyautogui
|
||||
requests
|
||||
pillow
|
||||
#MacOS
|
||||
python3 -m venv path/to/venv
|
||||
source path/to/venv/bin/activate
|
||||
pip install pyttsx3 openpyxl pyzbar opencv-python qrcode pyautogui requests pillow
|
||||
pip install wheel setuptools pip --upgrade
|
||||
pip install git+https://github.com/ageitgey/face_recognition_models --verbose
|
||||
pip install face_recognition
|
||||
|
|
@ -180,10 +180,10 @@ def process_qr_code(frame):
|
|||
cv.resizeWindow(WINDOW_QR_CODE, screen_width, screen_height)
|
||||
cv.imshow(WINDOW_QR_CODE, frame)
|
||||
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)
|
||||
send_image(id_log, file_name)
|
||||
cv.destroyWindow(WINDOW_QR_CODE)
|
||||
send_image(id_log, file_name)
|
||||
else:
|
||||
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)
|
||||
|
|
@ -216,14 +216,15 @@ def process_face_detect(text, frame):
|
|||
# screenshot_window(file_name)
|
||||
res = check_out(text, frame, text)
|
||||
id_log = res.get('data').get('id')
|
||||
screenshot_window(file_name)
|
||||
cv.namedWindow(WINDOW_QR_CODE, cv.WINDOW_NORMAL)
|
||||
cv.resizeWindow(WINDOW_QR_CODE, screen_width, screen_height)
|
||||
cv.imshow(WINDOW_QR_CODE, frame)
|
||||
cv.moveWindow(WINDOW_QR_CODE, 10, 10)
|
||||
cv.waitKey(5000) # Chờ 5 giây
|
||||
screenshot_window(file_name)
|
||||
send_image(id_log, file_name)
|
||||
# Chạy vòng lặp không chặn trong 2 giây
|
||||
cv.waitKey(2000) # Chờ 10ms
|
||||
cv.destroyWindow(WINDOW_QR_CODE)
|
||||
send_image(id_log, file_name)
|
||||
else:
|
||||
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)
|
||||
|
|
@ -271,16 +272,16 @@ def main():
|
|||
if not ret:
|
||||
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)
|
||||
|
||||
faceCurFrame = face_recognition.face_locations(frameS)
|
||||
faceCurFrame = face_recognition.face_locations(frameS, model='hog')
|
||||
encodeCurFrame = face_recognition.face_encodings(frameS)
|
||||
frame = process_qr_code(frame)
|
||||
for encodeFace, faceLoc in zip(encodeCurFrame, faceCurFrame):
|
||||
matches = face_recognition.compare_faces(encodeListKnow, encodeFace)
|
||||
faceDis = face_recognition.face_distance(encodeListKnow, encodeFace)
|
||||
print(faceDis)
|
||||
# print(faceDis)
|
||||
matchIndex = np.argmin(faceDis)
|
||||
|
||||
if faceDis[matchIndex] < 0.3:
|
||||
|
|
@ -290,9 +291,9 @@ def main():
|
|||
name = "Unknow"
|
||||
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 = 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.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()
|
||||
cv.destroyAllWindows()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue