BEST Journal of Applied Electrical & Science Technology Ae University of PGRI Adi Buana Surabaya p-ISSN 2715-2871 e-ISSN 2714-5247 IMPLEMENTATION OF FACE DETECTION LOGIN SYSTEM USING PYTHON *Dwi Hastuti Electrical Engineering Universitas PGRI Adi Buana Surabaya Surabaya. Indonesia hastuti@unipasby. Rasyida Shabihah Zukro Aini Electrical Engineering Universitas PGRI Adi Buana Surabaya Surabaya. Indonesia rasyida@unipasby. AbstractAi Traditional authentication methods, primarily relying on passwords, face several critical challenges. Users often choose weak passwords, reuse them across multiple platforms, or struggle to remember complex combinations, leading to potential security vulnerabilities. As cybersecurity threats continue to evolve, traditional password-based authentication mechanisms have proven increasingly vulnerable to various attacks. Face detection-based login systems have emerged as a promising alternative, offering a balance between security and user convenience. This paper provides a detailed examination of implementing face detection-based login systems, focusing on using Python programming language. The research highlights both the advantages and potential vulnerabilities of such systems while proposing mitigation strategies for enhanced security. KeywordsAi Cybersecurity. Login System. Face Detection. Python Programming Language. INTRODUCTION In recent years, the evolution of authentication systems has witnessed a significant shift from traditional password-based methods toward more sophisticated biometric solutions. Among these, face detection-based login systems have emerged as a compelling alternative, offering a balance between security and user convenience. This transformation is driven by both the limitations of conventional password systems and the rapid advancement in computer vision and machine learning Traditional authentication methods, primarily relying on passwords, face several critical challenges. Users often choose weak passwords, reuse them across multiple platforms, or struggle to remember complex combinations, leading to potential security vulnerabilities. Additionally, passwords can be stolen, shared, or compromised through various attack vectors such as phishing or keylogging. These limitations have created a pressing need for more secure and user-friendly authentication mechanisms. Face detection-based login systems address these challenges by leveraging unique biological characteristics for These systems utilize computer vision algorithms to capture, process, and verify facial features, providing a natural and intuitive way for users to prove their identity. The implementation of such systems has become increasingly practical due to advances in hardware capabilities, improved algorithms, and the widespread availability of high-quality cameras in modern devices. Afif Nuril Musthofa Electrical Engineering Universitas PGRI Adi Buana Surabaya Surabaya. Indonesia afifmusthofa@unipasby. However, implementing a secure and reliable face detection login system presents its own set of challenges. These include ensuring accurate face detection under varying lighting conditions, preventing spoofing attacks, managing computational resources efficiently, and maintaining user privacy. A successful implementation must address these challenges while providing a seamless user experience and maintaining robust security standards. This paper presents a comprehensive guide for implementing a face detection login system, focusing on practical aspects of development, security considerations, and performance optimization. We explore the core components required for building such a system, including face detection algorithms, feature extraction methods, database management, and authentication protocols. The implementation approach described here aims to provide developers with a solid foundation for creating secure and efficient facial recognition authentication systems. Face detection-based login systems have emerged as a promising alternative, offering a balance between security and user convenience. This paper provides a detailed examination of implementing face detection-based login systems, focusing on Python Programming Language. Face detection and recognition technology has emerged as a crucial component in modern biometric authentication systems. This research presents a comprehensive implementation of a facial recognitionbased login system using Python programming language, incorporating advanced computer vision techniques and security measures. The system utilizes OpenCV and face recognition libraries to create a robust and secure authentication mechanism. Face detection login systems have gained significant attention in recent years due to their non-intrusive nature and high security potential. Traditional authentication methods like passwords and PINs are increasingly vulnerable to security breaches, making biometric solutions more attractive. Python, with its rich ecosystem of computer vision libraries, provides an ideal platform for implementing such systems. II. METHODS This research method describes in the form of Block Diagrams and System Flow. Image Acquisition. Face Detection Implementation. Feature Extraction Method. Database Management. Security Implementation. Performance Optimization. 79 iC BEST. Vol. No. 02, 2024 BEST Journal of Applied Electrical & Science Technology Ae University of PGRI Adi Buana Surabaya p-ISSN 2715-2871 e-ISSN 2714-5247 Block Diagrams and System Flow Image Acquisition Face Detection Implementation Image Acquisition Image Acquisition is the first and crucial step in face detection systems. It involves capturing and preparing images for face detection processing. The image acquisition process follows these steps: Camera Initialization: def initialize_camera. camera = cv2. VideoCapture. Database Management set. CAP_PROP_FRAME_W IDTH, . Feature Extraction Method set. CAP_PROP_FRAME_H EIGHT, . CAP_PROP_FPS, Security Implementation Frame Preprocessing: Performance Optimization def preprocess_frame. elf, fram. # Convert to RGB rgb_frame = cv2. cvtColor. COLOR_BGR2RGB) LOGIN SYSTEM USING FACE DETECTION Figure 1. Block Diagram # Resize for consistent resized_frame = resize. gb_frame, . , . ) # Normalize lighting normalized_frame = cv2. resized_frame. None, 0, 255. NORM_MINMAX User Input Image Acquisition return normalized_frame Face Detection Security Layer Feature Extraction Database Matching Authentication Result Figure 2. System Flow Face Detection Implementation Face Detection is a crucial part that locates and identifies faces in an image. Face Detection Algorithm: def detect_face. elf, fram. # Use HOG-based detector face_locations = face_recognition. face_locations( model="hog" if not face_locations: return None return face_locations. Return first face found 80 iC BEST. Vol. No. 02, 2024 BEST Journal of Applied Electrical & Science Technology Ae University of PGRI Adi Buana Surabaya p-ISSN 2715-2871 e-ISSN 2714-5247 Face Quality Assessment: def assess_face_quality. elf, frame, face_locatio. # Extract face region top, right, bottom, left = face_location face = frame. op:bottom, left:righ. # Check face size min_face_size = 100 if face. < min_face_size or face. < min_face_size: return False # Check brightness brightness = np. if brightness < 40 or brightness > 250: return False # Check blur laplacian = cv2. Laplacian. CV_64F). if laplacian < 100: return False return True Feature Extraction Methods Feature Extraction: def extract_features. elf, frame, face_locatio. # Generate face encodings face_encodings = face_recognition. face_encodings( . ace_locatio. if not face_encodings: return None return face_encodings. Feature Extraction: def process_feature_vector. elf, feature_vecto. # Normalize feature vector normalized_vector = feature_vector / norm. eature_vecto. # Convert to fixed-point representation for storage fixed_point_vector = . ormalized_vector * astype. return fixed_point_vector Database Management User Registration: def register_user. elf, username, face_encodin. with self. db_connection as conn: cursor = conn. execute(""" INSERT INTO users . sername, face_encodin. VALUES (?, ?) """, . sername, face_encoding. tobytes())) Authentication Verification: def verify_user. elf, face_encodin. with self. db_connection as conn: cursor = conn. execute("SELECT username, face_encoding FROM users") for username, stored_encoding in cursor: stored_vector = frombuffer. tored_encoding, dtype=np. ace_encoding stored_vecto. if distance < return True, username return False. None Security Implementation Anti-Spoofing Measures: def check_liveness. elf, frame, face_locatio. # Eye blink detection eye_landmarks = get_eye_landmarks. rame, face_locatio. blink_detected = detect_blink. ye_landmark. # Head pose estimation pose_angles = estimate_head_pose. rame, face_locatio. 81 iC BEST. Vol. No. 02, 2024 BEST Journal of Applied Electrical & Science Technology Ae University of PGRI Adi Buana Surabaya p-ISSN 2715-2871 e-ISSN 2714-5247 pose_varied = check_pose_variation. ose_angle. # Texture analysis for printed photo detection texture_score = analyze_face_texture. rame, face_locatio. return blink_detected and pose_varied and texture_score > 0. Data Protection: def encrypt_face_data. elf, face_encodin. # Generate salt salt = os. Resource Management: def manage_resources. # Monitor system resources cpu_usage = psutil. cpu_percent() memory_usage = virtual_memory(). # Adjust processing parameters based on resource usage if cpu_usage > 80: frame_skip = 1 elif cpu_usage < 50 and frame_skip > 1: frame_skip -= 1 i. RESULTS AND DISCUSSION # Key derivation kdf = PBKDF2HMAC( algorithm=hashes. SHA256(), length=32, salt=salt, iterations=100000 # Encrypt data urlsafe_b64encode. master_ke. ) f = Fernet. encrypted_data = encrypt. ace_encoding. tobytes()) return encrypted_data, salt Figure 3. Initial State. Registration. And Login Process Performance Optimization Processing Pipeline: def optimize_pipeline. # Implement frame skipping frame_skip = 2 # Use threading for parallel detection_thread = Thread. arget=self. detect_face_threa feature_thread = Thread. arget=self. extract_features_ # Initialize frame buffer frame_buffer = Queue. Figure 4. Login Process : Camera Preview 82 iC BEST. Vol. No. 02, 2024 BEST Journal of Applied Electrical & Science Technology Ae University of PGRI Adi Buana Surabaya p-ISSN 2715-2871 e-ISSN 2714-5247 ACKNOWLEDGMENT