{"id":25271315,"url":"https://github.com/relostar-devil/face-recognition","last_synced_at":"2025-04-06T06:43:46.932Z","repository":{"id":277020301,"uuid":"931070937","full_name":"Relostar-Devil/Face-Recognition","owner":"Relostar-Devil","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-11T17:14:18.000Z","size":162,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T18:27:30.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/Relostar-Devil.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}},"created_at":"2025-02-11T17:09:49.000Z","updated_at":"2025-02-11T17:14:21.000Z","dependencies_parsed_at":"2025-02-11T18:38:38.003Z","dependency_job_id":null,"html_url":"https://github.com/Relostar-Devil/Face-Recognition","commit_stats":null,"previous_names":["relostar-devil/face-recognition"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relostar-Devil%2FFace-Recognition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relostar-Devil%2FFace-Recognition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relostar-Devil%2FFace-Recognition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relostar-Devil%2FFace-Recognition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Relostar-Devil","download_url":"https://codeload.github.com/Relostar-Devil/Face-Recognition/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445651,"owners_count":20939953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-02-12T12:23:04.049Z","updated_at":"2025-04-06T06:43:46.911Z","avatar_url":"https://github.com/Relostar-Devil.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Face Recognition Project\n\n## Overview\n\nThis project implements a basic face recognition system using OpenCV and Haar cascades. It detects faces in images using the `haarcascade_frontalface_default.xml` classifier and draws rectangles around the detected faces.\n\n## Features\n\n*   **Face Detection:** Detects faces in images using the Haar cascade classifier.\n*   **Image Processing:** Reads images from a directory, converts them to grayscale, and applies the face detection algorithm.\n*   **Visual Output:** Displays the images with rectangles around the detected faces.\n\n## Requirements\n\n*   Python 3.x\n*   OpenCV (`cv2`)\n*   Glob\n  \nDownload the `haarcascade_frontalface_default.xml` file from the [OpenCV repository](https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml) and place it in the same directory as the script.\n\n*  Ensure you have a directory with `.jpg` images for testing.\n\n## Usage\n\n1.  Place the `Face-Recognition.ipynb` file, the `haarcascade_frontalface_default.xml` file, and the images you want to test in the same directory.\n2.  Open the `Face-Recognition.ipynb` file using Jupyter Notebook or JupyterLab.\n3.  Run the cells in the notebook. The script will:\n\n    *   Read all `.jpg` images from the directory.\n    *   Detect faces in each image.\n    *   Display the images with rectangles around the detected faces for 2 seconds each.\n  \n## Code Explanation\n\nimport cv2, glob\nGet all .jpg images from the current directory\ngimage = glob.glob(\"*.jpg\")\nLoad the Haar cascade classifier for face detection\ndetect = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')\nCheck if the cascade file loaded successfully\nif detect.empty():\nprint(f\"Error: Unable to load cascade file: haarcascade_frontalface_default.xml\")\nexit()\nIterate through each image\nfor timage in gimage:\n# Read the image\nimage = cv2.imread(timage)\n# Convert the image to grayscale\ngrayimg = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n# Detect faces in the grayscale image\nface = detect.detectMultiScale(grayimg, 1.25, 3)\ntext\n# Draw rectangles around the detected faces\nfor (x, y, w, h) in face:\n    cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)\n\n# Display the image with detected faces\ncv2.imshow(\"Detect images\", image)\n# Wait for 2 seconds\ncv2.waitKey(2000)\n\n# Close all open windows\ncv2.destroyAllWindows()\ntext\n\n*   **Import Libraries:** Imports the necessary libraries (`cv2` for OpenCV and `glob` for file handling).\n*   **Load Haar Cascade:** Loads the `haarcascade_frontalface_default.xml` file, which is a pre-trained Haar cascade classifier for face detection.\n*   **Image Loading and Processing:**\n    *   Reads all `.jpg` images from the current directory.\n    *   Converts each image to grayscale because the Haar cascade classifier works on grayscale images.\n    *   Uses the `detectMultiScale` function to detect faces in the grayscale image. This function returns a list of rectangles representing the detected faces.\n*   **Drawing Rectangles:** Iterates through the detected faces and draws a rectangle around each face on the original color image.\n*   **Displaying Images:** Displays the image with the detected faces for 2 seconds and then closes the window.\n\n## Troubleshooting\n\n*   **Error: Unable to load cascade file:** Ensure that the `haarcascade_frontalface_default.xml` file is in the same directory as the script and that the path is correct.\n*   **No faces detected:** Adjust the `scaleFactor` and `minNeighbors` parameters in the `detectMultiScale` function.  `scaleFactor` (1.25 in the example) affects how much the image size is reduced at each image scale, and `minNeighbors` (3 in the example) affects how many neighboring rectangles each candidate rectangle should have to retain it.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelostar-devil%2Fface-recognition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frelostar-devil%2Fface-recognition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelostar-devil%2Fface-recognition/lists"}