Skip to content

Instantly share code, notes, and snippets.

@SULAIMAN-5-AHMED
Last active November 3, 2022 13:48
Show Gist options
  • Save SULAIMAN-5-AHMED/962e73cbbed57b0381f7c5a169b11e27 to your computer and use it in GitHub Desktop.
Save SULAIMAN-5-AHMED/962e73cbbed57b0381f7c5a169b11e27 to your computer and use it in GitHub Desktop.
import cv2 as cv
cap = cv.VideoCapture(0)
while True:
successs, img = cap.read()
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
haar_cascade = cv.CascadeClassifier("haar_face.xml")
face_detect = haar_cascade.detectMultiScale(gray,1.1,12)
for (x,y,w,h) in face_detect:
cv.rectangle(img,(x,y),(x+w,y+h),(0,256,0),2)
cv.imshow('Image', img)
cv.waitKey(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment