0% found this document useful (0 votes)
7 views1 page

Real-time Face Detection with OpenCV

This document describes code for detecting faces in a video stream from a webcam. The code uses OpenCV to load a pre-trained face detection classifier, start a video capture from the webcam, detect faces in each frame and draw rectangles around them.

Uploaded by

Dimas Dandy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Real-time Face Detection with OpenCV

This document describes code for detecting faces in a video stream from a webcam. The code uses OpenCV to load a pre-trained face detection classifier, start a video capture from the webcam, detect faces in each frame and draw rectangles around them.

Uploaded by

Dimas Dandy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

faceCascade =

[Link]("haarcascade/haarcascade_frontalface_default.xml")
noseCascade = [Link]("haarcascade/[Link]")

video_capture = [Link](0)
mask_on = False

while True:
ret, frame = video_capture.read()
gray = [Link](frame, cv2.COLOR_BGR2GRAY)
wajah = [Link](gray, 1.1, 5)

for (x, y, w, h) in wajah:


roi_gray = gray[y:y+h, x:x+w]
roi_color = frame[y:y+h, x:x+w]
[Link](frame, (x, y), (x+w, y+h), (0, 255, 0), 3)
[Link](frame, 'wajah', (x, y), cv2.FONT_HERSHEY_SIMPLEX, 2, (0,255,0),
5)

[Link](frame,'Jumlah Wajah : ' + str(len(wajah)),(30, 30),


cv2.FONT_HERSHEY_SIMPLEX, 1,(255,0,0),2)
[Link]('Video', frame)

if [Link](1) & 0xFF == ord('q'):


break

video_capture.release()
[Link]()

You might also like