How danagh1/real-time-facial-emotion-recognition-using-ai works
Project type and purpose
• This project is an Android mobile application focused on real-time facial emotion recognition using AI. It is tailored to improve the detection of emotions for Middle Eastern faces, especially women wearing hijabs.
• The README explains that the app uses a deep learning model (CNN) that was trained and retrained on multiple datasets. Although some Python files are present (for model retraining), the delivered product is an Android app built in Java that integrates with OpenCV.
File structure
• Top-level files include Android configuration files (AndroidManifest.xml, build.gradle, gradlew scripts, gradle configuration) along with documentation (PDFs and presentation slides) and Python scripts for model retraining.
• The “java” folder (java/com/example/myfirstapp) includes all the key Activity classes:
• SplashActivity.java (the initial screen)
• MainActivity.java (likely the home screen that branches into options)
• FirstButtonActivity.java (screen handling photo-based emotion analysis with capture and gallery selection)
• SecondButtonActivity.java (screen for real-time emotion detection)
• ResultActivity.java (screen to display detection results, tips, and provide links to videos)
• FacialExpressionRecognition.java (the core class likely handling interfacing with the pretrained CNN model and OpenCV processing).
• Other files such as local.properties, gradle, proguard rules, and settings.gradle indicate standard Android project configuration.
README for additional insights
• The README gives an overview of the application flow, the reasoning behind focusing on a specific demographic, and instructions for setting up and running the application.
• It highlights the two main interaction flows: one for a camera-based photo capture (with options for gallery selection and processing) and the other for real‑time emotion detection (with camera flip and configurable timer for notifications).
Key components
a. Main Components:
• UI/Presentation Layer: Different Android Activities (SplashActivity, MainActivity, FirstButtonActivity, SecondButtonActivity, ResultActivity), layouts (XML in “res/layout”) and assets (images, videos, and audio files).
• Core Processing/Business Logic: The FacialExpressionRecognition.java class handling emotion detection logic. This component would bridge the camera input (or gallery image) with the deep learning model, likely invoked through OpenCV and the pre-trained CNN engine.
• External Libraries / Tools: OpenCV SDK (as indicated by the dependencies in the README and the presence of OpenCV-related resources such as haarcascade xml), Android SDK components, and possibly integration with notification and media playback systems.
• Model Training Artifacts: Although not part of the runtime Android application, Python scripts (Model_Retrained_on_the_Hybrid_Dataset.py and Model_Retrained_on_the_IEFDB_Dataset.py) and zipped dataset (alldataset.zip) form a separate off-line component that informed the model used in the app.
b. Relationships and interactions:
• The SplashActivity acts as the entry point, leading to MainActivity.
• From the MainActivity, the user can choose between two primary flows:
• Photo/Image Processing Flow: Leads to FirstButtonActivity where the user can capture or select an image. The image is then passed to FacialExpressionRecognition for processing. Results flow to ResultActivity.
• Real-time Detection Flow: Launches SecondButtonActivity where the camera continuously feeds input to facial recognition and a notification system prompts the user with emotion feedback and video suggestions.
• The core processing component (FacialExpressionRecognition) interacts with external libraries (OpenCV) to perform computation and analysis.
c. Architectural patterns and design principles:
• The design follows an MVC-like pattern: Activities and XML layouts form the “View”, Java classes (including FacialExpressionRecognition) serve as the “Controller/Model” conducting the analysis.
• Emphasis is on modularity, reflected in separate activities for different user flows and separating UI from processing logic.
• Utilizes clear separation of concerns: UI components, processing logic, and external integrations are housed in distinct parts of the project.
d. Relevant technologies, frameworks, or libraries:
• Android (Java) framework components and lifecycle management.
• OpenCV for Android – for both face detection (with provided haarcascade XML in res/raw) and image processing.
• Deep Learning/CNN model integration indicated by training scripts and pre-trained model artifacts.
Final reminders
• Every essential element as described in the file tree and README. Do not oversimplify—include as many distinct components as possible.
• Clarity in how data moves through the system so that another engineer can understand the responsibilities of each module.