You are on page 1of 1

import cv2

face_cap=cv2.CascadeClassifier("C:/Users/DELL/AppData/Local/Programs/Python/
Python310/Lib/site-packages/cv2/data/haarcascade_frontalface_default.xml")
# video_cap=cv2.VideoCapture(0)
for i in range(6,17):
i=i+1
img=cv2.imread("C:/Users/DELL/Desktop/VS Code Proj/Images/18.jpg")
# rgb_img=cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
# img_encode= face_recognition.face_encodings(rgb_img)[0]
print("Img1 loaded")
while True:
# ret , video_data= img.read()
col= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
faces=face_cap.detectMultiScale(
col,
scaleFactor=1.1,
minNeighbors=5,
minSize=(30,30),
flags=cv2.CASCADE_SCALE_IMAGE
)
i=1
for(x,y,w,h) in faces:
faceimg=img[y:y+h,x:x+w]
fname="Images/18.jpg"
cv2.imwrite(fname,faceimg)

# cv2.imshow("video_live", faceimg)
if cv2.waitKey(10) == ord("a"):
break

You might also like