Introduction:
As Covid-19 arises, one problem we all face is entering places but still being close to people. A face mask detection camera could allow people, such as students and teachers in school, to make sure to put on their masks when entering the places keeping the environment we live in safe and healthy.
Driven Question:
How can we use computer vision to mitigate spread of Coronavirus?
Background Research:
Before making this project, I had to research what coding software would work best, how best to go about coding it, and how to get the computer vision to work properly in python programming language.
Computer vision: This field involves the use of computers to analyze, understand, and process visual data from the real world. OpenCV is a popular open-source library that provides tools and functions for performing various computer vision tasks, such as image and video processing, feature detection, and object tracking. You can learn more about the basics of computer vision and how to use OpenCV by reading online tutorials and documentation.
Python programming: Python is a popular programming language that is widely used in various fields, including scientific computing, data analysis, and web development. It is known for its simplicity, readability, and flexibility, making it a great language for beginners. You can learn more about Python programming by reading online tutorials and taking online courses.
PBL Face Mask Detection Project aims to use computer vision and machine learning techniques, along with the OpenCV and Python programming languages, to develop a system that can accurately detect whether individuals are wearing face masks in public spaces. This is a pressing issue, as the use of face masks has been recommended as an effective measure for reducing the spread of COVID-19. However, ensuring compliance with face mask mandates can be challenging, particularly in large crowds or in public spaces where it may not be practical for individuals to be monitored continuously by human personnel.
To address this problem, the PBL Face Mask Detection Project will explore the use of image classification and object detection algorithms to identify and classify the presence of face masks within an image or video. The project will also consider challenges such as variations in lighting conditions, occlusions, and the wide range of face mask designs and colors that may be present. Additionally, the system must be able to accurately detect masks on individuals with a wide range of skin tones and facial features, in order to avoid bias.
In addition to the technical aspects of the project, the PBL Face Mask Detection Project will also involve the development of a user-friendly and engaging interface using Python and OpenCV, as well as the application of STEM concepts such as problem-solving, logic, spatial reasoning, and physics. By completing this project, students will have the opportunity to learn about computer vision, Python programming, game development, and STEM concepts, and apply these skills to address a pressing public health issue. Regenerate response
Purpose & Goal:
Our Purpose & Goal is to write a code that helps the camera scan an individuals face and determine if they are wearing a mask and help reduce possible covid-19 cases. I believe that writing and editing a code using the "open cv" and multiple other codes in the library can provide an efficient code that detects an individuals face and one that detects their nose, if it is covered or not, can help reduce possible covid-19 cases.
Materials for the project:
Webcam
Laptop
Python&Pycharm
Face Mask
Procedure:
Prepare Materials & Start research on open cv
Install python – Download the latest version for your computer. www.python.org/downloads
Install Pycharm – Download the latest version for your computer www.jetbrains.com/pycharm/download
Install OpenCV and Numpy Packages by using pip install library. Run this pip command in your terminal: –pip install OpenCV-python numpy
Requirements for Face Recognition Project
Create a new folder on your computer
Download the haarcascade_frontalface_default_default.xml file into your folder
Copy your image for detection faces into the folder
Create a python file for detecting faces. (Open the Pycharm program, Create a new python project and save it to your folder)
Start code and import the files from the library
Make sure program works and if not, debug and redo until code works
Understanding of computer vision and image processing concepts: Students could learn about concepts such as edge detection, color space, and feature extraction, and how they can be applied to detect and classify objects in images.
Hands-on experience with programming and problem-solving: Students could gain practical experience with programming concepts such as loops, conditionals, and functions, as well as develop their problem-solving skills as they design and debug their face mask detection system.
Exposure to machine learning and artificial intelligence: Students could learn about the basics of machine learning and how it can be used to classify images based on their content. They could also learn about the different types of machine learning algorithms and how they differ in terms of their complexity and performance.
Understanding of the role of computer science in solving real-world problems: Students could learn about the practical applications of computer science in fields such as public health, security, and retail, and how their face mask detection system could be used to address these challenges.
Configure Your Python interpreter :Click File / Settings / Project / Python Interpreter for Windows .
Real Life Connections:
Public health: Face masks are an important tool for controlling the spread of infectious diseases, such as COVID-19. A face mask detection system could be used to remind people to wear masks in public places, or to enforce mask-wearing rules in settings such as schools or hospitals.
Security: Face masks can make it more difficult to identify individuals, which can be a concern in security-sensitive environments such as airports or government buildings. A face mask detection system could be used to alert security personnel when someone is wearing a mask, or to trigger additional security measures such as ID checks.
Retail: Face masks have become a common sight in retail settings, as stores implement measures to protect employees and customers from COVID-19. A face mask detection system could be used to alert employees when someone enters a store without a mask, or to trigger additional cleaning or sanitization measures.
Traffic and transportation: Face masks are often required on public transportation, such as buses, trains, and subways. A face mask detection system could be used to alert drivers or conductors when someone is not wearing a mask, or to trigger reminders or enforcement measures.
1- What are the requirements for building a facemask detection project.
In order for our mask detector model to work, it needs images of faces. For this, we will detect the frames with faces using the methods as shown in the first section and then pass them to our model after preprocessing them. So let us first import all the libraries we need.
2- How OpenCV works in Python?
OpenCV is an open-source Python library, which used to understand the content of the digital images. The CV is the abbreviation form of computer vision. It extracts the description from the real-time image or digital image, which may be an object, a text description, and so on. We can perform many tasks using the OpenCV library such as face detection, face recognition, blob detection, edge detection, image filter, template matching, etc. To work with the OpenCV, we need to install it in our Python environment.
3- How does the Process for the Project help facemask detection?
The main process during the project was importing the library items to the coding platform, I used Pycharm, and later writing the code. For the code we used an array of variables to instruct the computer to understand the human face, focusing on the nostrils and the mouth. Later we created a track box which would change color if the nostrils were detected telling the users they are not wearing a mask and staying the blue color when the user is wearing the mask. Finally we added a cleaner surrounding and a notification box so that the app nice to the user. Conclusively the use of previous AI projects and the python library tremendously helped in creating a projecting like Face Mask Detection.
4- How does the software/code identify faces?
We will use the haar cascade classifier in this project. Haar-cascade classifier is an Object Detection Algorithm used to identify faces in an image or a real-time video. The algorithm uses edge or line detection features proposed by Viola and Jones in their research paper “Rapid Object Detection using a Boosted Cascade of Simple Features” published in 2001. The algorithm is given a lot of positive images consisting of faces, and a lot of negative images not consisting of any face to train on them. The model created from this training is available at the OpenCV
5- How Computer Vision will change worl?
Artificial intelligence (AI)'s field of computer vision enables computers and systems to extract useful information from digital images, videos, and other visual inputs and to take actions or offer recommendations in response to that information. If AI gives computers the ability to think, computer vision gives them the ability to see, observe, and comprehend. Human vision has an advantage over computer vision in that it has been around longer. With a lifetime of context, human sight has the advantage of learning how to distinguish between objects, determine their distance from the viewer, determine whether they are moving, and determine whether an image is correct.
My Code:
#import libraries
import cv2
import os
#Credit realpython.com
#start webcam
cap=cv2.VideoCapture(0)
# Capture frame-by-frame
# Convert into grayscale
# Create Cascade Classifiers
while True:
ret,frame=cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faceCascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30, 30)
)
# Draw a rectangle around the faces
for (x, y, w, h) in faces:
cv2.putText(frame,"face", (x, y - 10),
cv2.FONT_HERSHEY_DUPLEX,0.5, (194, 231, 26), 1)
cv2.rectangle(frame, (x, y), (x+w, y+h), (194, 231, 26), 2)
# Display the resulting frame
cv2.imshow("frame",frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break;
cap.release()
cv2.destroyAllWindows()