{"id":25246264,"url":"https://github.com/mohamedyounis10/face-detection-app","last_synced_at":"2026-05-03T21:34:12.584Z","repository":{"id":269806659,"uuid":"908515042","full_name":"mohamedyounis10/Face-Detection-App","owner":"mohamedyounis10","description":"This Flutter app incorporates a basic face detection system using image processing techniques such as color models, morphological operations, and geometric analysis. These techniques are implemented in the Python backend code. The app detects faces in images and highlights them with bounding boxes for easy visualization.","archived":false,"fork":false,"pushed_at":"2025-05-13T08:41:32.000Z","size":830,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-18T06:55:52.114Z","etag":null,"topics":["backend","dart","face-detection","flutter","python","skimage"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mohamedyounis10.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-26T09:03:14.000Z","updated_at":"2025-05-13T08:41:36.000Z","dependencies_parsed_at":"2025-07-18T05:30:20.263Z","dependency_job_id":"a3e18a7d-f2b5-46b4-9250-b59d84efb054","html_url":"https://github.com/mohamedyounis10/Face-Detection-App","commit_stats":null,"previous_names":["mohamedyounis10/face-detection-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mohamedyounis10/Face-Detection-App","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedyounis10%2FFace-Detection-App","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedyounis10%2FFace-Detection-App/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedyounis10%2FFace-Detection-App/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedyounis10%2FFace-Detection-App/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohamedyounis10","download_url":"https://codeload.github.com/mohamedyounis10/Face-Detection-App/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedyounis10%2FFace-Detection-App/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32586187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","dart","face-detection","flutter","python","skimage"],"created_at":"2025-02-12T02:13:35.460Z","updated_at":"2026-05-03T21:34:12.569Z","avatar_url":"https://github.com/mohamedyounis10.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Face Detection Flutter App with Python Backend\n\n## Overview\nThis project implements a face detection system using custom image processing techniques. The goal is to detect faces in images by processing pixel-level data and applying various image manipulation methods. Key techniques include:\n\n- Skin detection in HSV color space.\n- Morphological operations (erosion and dilation).\n- Edge detection using the Canny algorithm.\n- Logical operations (XOR) for refining detected regions.\n- Filtering based on dynamic thresholds for aspect ratio and size of the detected regions.\n\nThe system processes images to detect faces and highlights them with bounding boxes. Intermediate results such as masks, edges, and histograms of aspect ratios are also visualized for analysis.\n\n---\n\n## Features\n- **Pixel-level Face Detection**: Detect faces based on custom processing techniques.\n- **Morphological Transformations**: Uses custom kernels for erosion and dilation to refine the skin mask.\n- **Edge Detection**: Applies the Canny algorithm to enhance image boundaries.\n- **XOR Operation**: Refines detected face regions through XOR logical operations.\n- **Geometric Filtering**: Filters regions based on dynamic aspect ratio and size thresholds.\n- **Visualization**: Displays intermediate steps such as masks, edges, and histograms of aspect ratios.\n\n---\n\n## Images\n\n### 1. Mobile App Screen\n\n![Mobile App](https://github.com/user-attachments/assets/9060f7d6-44cd-4343-8e1f-17e4b3768b1f)\n\n---\n\n### 2. Example Outputs  \nAfter running the face detection script, various intermediate results will be produced. Below are the outputs of the process:\n\n- **Original Image with Detected Faces**:  \n  The original image with faces highlighted by bounding boxes.\n\n  ![Original Image with Detected Faces](https://github.com/user-attachments/assets/1e5f2ab8-a063-4690-8f8a-e8e15e91a6f4)\n\n---\n\n## Requirements\n\nTo run this project, you'll need Python 3.7 or higher and the following dependencies:\n\n- `numpy`\n- `opencv-python`\n- `scikit-image`\n- `matplotlib`\n- `flask`\n- `werkzeug`\n\nTo install these dependencies, run the following command:\n\n```bash\npip install numpy opencv-python scikit-image matplotlib flask werkzeug\n```\n\n---\n\n## How to Run\n\n1. **Run the Python Flask API**:\n   The mobile app requires the Python backend (Flask server) to be running. Please follow these steps to start the backend:\n\n   - **Install the necessary Python libraries**:\n     ```bash\n     pip install flask opencv-python numpy scikit-image werkzeug\n     ```\n\n   - **Run the Python Flask server**:\n     Navigate to the directory where your `app.py` file is located and run the following command:\n     ```bash\n     python app.py\n     ```\n     The Flask server will start on `http://localhost:5000`.\n\n   - **Test the Flask API**:\n     Ensure the Flask server is running properly by sending a sample image using a tool like Postman or CURL, or by using the mobile app.\n\n2. **Clone the repository**:\n   Clone this project’s repository to your local machine:\n   ```bash\n   git clone \u003crepository_url\u003e\n   cd \u003crepository_directory\u003e\n   ```\n\n3. **Set the image path**:\n   Replace the image path in the code with the path to the image you want to process. Update the variable `imagepath` in the script:\n   ```python\n   imagepath = \"./images/sample_image.webp\"\n   ```\n   Ensure that the `images` folder contains your input images.\n\n4. **Run the Python script**:  \n   Run the Python script that processes the image:\n   ```bash\n   python face_detection.py\n   ```\n\n5. **View the results**:  \n   After running the script, the following outputs will be displayed:\n   - The original image with bounding boxes around detected faces.\n   - A skin detection mask.\n   - Eroded and dilated masks.\n   - Canny edge detection result.\n   - Refined face detection after XOR operation.\n   - Histograms of aspect ratios of the detected regions.\n\n---\n\n## Modifications\n\n### Dropping Static Dependence\n\nIn the previous version of the code, faces were filtered based on a **static threshold** for the aspect ratio. This was replaced with **dynamic thresholds**, which are calculated based on the **band statistics** of the detected regions' aspect ratios. The updated logic ensures more adaptive and flexible filtering of detected faces.\n\nHere’s the updated Python code for dynamic filtering:\n\n```python\nmean_aspect_ratio = np.mean(hist_average_ratio)\nstd_aspect_ratio = np.std(hist_average_ratio)\nmin_band = mean_aspect_ratio - std_aspect_ratio\nmax_band = mean_aspect_ratio + std_aspect_ratio\n\nfor i in range(1, num_labels):\n    x, y, w, h, area = stats[i, cv2.CC_STAT_LEFT], stats[i, cv2.CC_STAT_TOP], stats[i, cv2.CC_STAT_WIDTH], stats[i, cv2.CC_STAT_HEIGHT], stats[i, cv2.CC_STAT_AREA]\n    aspect_ratio = w / float(h)\n\n    if (min_band \u003c aspect_ratio \u003c max_band and w \u003e 25 and h \u003e 25 and area \u003e 1000):\n        filtered_faces.append((x, y, w, h))\n```\n\nThis change allows for **better dynamic filtering** of detected regions based on their geometric properties, improving the accuracy of the face detection.\n\n### Running Python Backend First\n\nBefore running the mobile app, you **must start the Python Flask backend** to ensure the API is available for the Flutter app to interact with. \n\n#### Steps to Run the Python Flask API:\n\n1. **Install the necessary Python libraries**:\n   Make sure you have Python 3.7 or higher, and install the dependencies:\n   ```bash\n   pip install flask opencv-python numpy scikit-image werkzeug\n   ```\n\n2. **Run the Python Flask server**:\n   Navigate to the directory where your `app.py` file is located and run the following command:\n   ```bash\n   python app.py\n   ```\n   The server will start on `http://localhost:5000` by default.\n\n3. **Test the Flask API**:\n   Ensure that the server is running properly by sending a sample image using a tool like Postman or CURL, or by using the mobile app.\n\n---\n\n### Flutter Mobile App\n\nOnce the **Python Flask backend is running**, you can now run the Flutter app. The Flutter app will send requests to the Python backend for face detection and display the results.\n\n---\n\n### Workflow\n\n1. **Run the Flask backend (Python)**:\n   - This step is essential because the Flutter app communicates with the Flask server via HTTP requests to get the image processed.\n   \n2. **Run the Flutter app**:\n   - After the Flask server is running, open the Flutter app to interact with it.\n   - The app will upload an image to the Flask API for face detection and display the processed image with bounding boxes around detected faces.\n\n---\n\n### Important Note:\n- **Ensure the Flask server is running** on your system at `http://localhost:5000` before launching the Flutter app. The Flutter app depends on this server to handle image uploads and processing.\n\n---\n\n## Outputs\n\nThe program will produce the following outputs:\n\n1. **Original Image**: Displays the input image.\n2. **Skin Mask**: A binary mask that highlights the skin regions in the image.\n3. **Eroded and Dilated Masks**: Refined masks after applying morphological transformations.\n4. **Edges**: Detected edges in the image using the Canny algorithm.\n5. **XOR Result**: A refined mask after applying the XOR logical operation to eliminate false positives.\n6. **Histograms**: Visualizations of aspect ratios of the detected regions to aid in filtering.\n7. **Final Image**: The original image with bounding boxes around detected faces.\n\n---\n\n## Limitations\n\n- The method may not perform well in the following cases:\n  - Complex backgrounds with no clear distinction between the face and background.\n  - Low-quality images or images with poor lighting conditions.\n  - Overlapping or occluded faces.\n  - Images with non-human faces (e.g., animal faces).\n\n---\n\n## Future Enhancements\n1. **Real-Time Detection**: Integrate with webcam or real-time video feed for live face detection.\n2. **GUI for Visualization**: Create a graphical user interface (GUI) to simplify interaction and visualization of detection results.\n3. **Optimizations for Speed**: Enhance performance for real-time processing and large-scale datasets.\n\n---\n\n## License\nThis project is licensed under the MIT License. See the `LICENSE` file for details.\n\n---\n\n## Acknowledgments\nSpecial thanks to the open-source contributors and the developers of Python libraries (e.g., OpenCV, NumPy, Scikit-image, Matplotlib) who made this project possible. Your contributions are greatly appreciated!\n\n---\n\n## Additional Resources\nFor more detailed information on the implementation and results of this project, please refer to the [Project Report](https://drive.google.com/file/d/17QnKxqzXBB2fWX2wN9wzlal0dphwhEFD/view?usp=drive_link).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedyounis10%2Fface-detection-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohamedyounis10%2Fface-detection-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedyounis10%2Fface-detection-app/lists"}