AIML Full Course Day 19 | Artificial Intelligence & Machine Learning Course
Автор: CodeKarmaNepal
Загружено: 2025-08-27
Просмотров: 24
Описание:
📌 Welcome to Day 19 of our Best Artificial Intelligence & Machine Learning Course by CodeKarma Nepal!
In today’s session, we dive into one of the most exciting applications of Computer Vision – Face Detection using OpenCV with Haar Cascade Classifiers.
🔍 What You Will Learn in This Video:
✅ Introduction to Face Detection
✅ Understanding Haar Cascade Classifier in OpenCV
✅ How to use pre-trained XML files for face detection
✅ Capturing video from Webcam using OpenCV
✅ Converting frames to Grayscale for detection
✅ Using detectMultiScale() function to detect faces
✅ Drawing bounding boxes around detected faces
✅ Breaking the loop with a keyboard event (‘q’ key)
---
🖥 Code Used in This Video:
import cv2 as cv
Load pre-trained Haar Cascade Classifier for face detection
face_cascade = cv.CascadeClassifier(cv.data.haarcascades + 'haarcascade_frontalface_default.xml')
Start webcam
cap = cv.VideoCapture(0)
while True:
tr, frame = cap.read()
Convert frame to grayscale
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
Detect faces
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5)
Draw rectangle around detected faces
for (x, y, w, h) in faces:
cv.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
cv.imshow("Face Detection", frame)
Exit on pressing 'q'
if cv.waitKey(1) & 0xFF == ord("q"):
break
Release resources
cap.release()
cv.destroyAllWindows()
---
📝 Key Points:
Haar Cascades are machine learning object detection algorithms used to identify objects in images/video.
Pre-trained models like haarcascade_frontalface_default.xml make face detection easier.
Real-time face detection is achieved by continuously reading frames from the webcam.
---
🎯 Assignment for You:
👉 Modify the code to:
1. Detect multiple faces and display the total count of faces.
2. Try different Haar Cascade files like haarcascade_eye.xml or haarcascade_smile.xml.
---
📢 Stay Connected:
📺 Don’t forget to Like, Share, and Subscribe to CodeKarma Nepal for more exciting lessons in Artificial Intelligence and Machine Learning!
🔔 Hit the bell icon so you never miss an update.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: