
    P\h                     R    S SK r S SKrS SKrS SKJrJr  S SKrS SK	r	S SK
r
S SKrS rg)    N)load_encodingsmark_attendancec                     [         R                  " S5        [         R                  " S5      n U Gb  Sn[        US5       nUR	                  U R                  5       5        SSS5        0 n[        R                  " S5       nUR                  5       nUR                  S5      R                  5       nU HK  u  px[        R                  " [        R                  " U5      5      n	Xs;  a  / X7'   X7   R                  U	5        MM     SSS5        [         R"                  " U5      n
[         R$                  " U
5      nU(       d  [         R&                  " S5        gUS	   nUR)                  5        HI  u  p}[         R*                  " XS
S9nSU;   d  M"  [-        U5        [         R.                  " SU S35        Us  $    [         R&                  " S5        g! , (       d  f       GNs= f! , (       d  f       N= f)zZProcesses a photo from the user's device camera for face recognition and marks attendance.zaPlease use your device's camera to mark attendance. Look directly at the camera for best results.zTake a photo to mark attendanceNztemp_attendance.jpgwbzapp/facial_attendance_db.dbzeSELECT USERS.name, USER_IMAGES.encoding FROM USERS JOIN USER_IMAGES ON USERS.id = USER_IMAGES.user_idz#No face detected. Please try again.r   g?)	toleranceTzAttendance marked for !z8Face not recognized. Please register first or try again.)stinfocamera_inputopenwrite	getbuffersqlite3connectcursorexecutefetchallnparrayjsonloadsappendface_recognitionload_image_fileface_encodingserroritemscompare_facesr   success)uploaded_imgimg_pathfregistered_usersconnr   resultsnameencoding_jsonencodingimgr   face_encoding	encodingsmatchess                  <D:\DownLoads\facial_attendance_system-main\app\attendance.pyprocess_video_feedr.   
   s   GGop??#DEL((D!QGGL**,- " __:;t[[]Fnn  &M  N  W  W  YG'.#88DJJ}$=>/-/$* &--h7	 (/ < ..x8)88=HH:;&q)/557OD&44YY]^Gw%

3D6;<  8 	KL7 "! <;s    G?BG
G
G+)timer   numpyr   	app.utilsr   r   	streamlitr	   r   r   osr.        r-   <module>r6      s"       5    	"r5   