After Updating code a bit.
import numpy
import cv2
#int Cam
cap=cv2.VideoCapture(0)
#facedetection
face_cascade=cv2.CascadeClassifier(“haarcascade_frontalface_alt.xml”)
skip=0
while True:
ret,frame=cap.read()
if ret==False:
continue
faces=face_cascade.detectMultiScale(frame,1.3,5)
print(faces)
for face in faces:
x,y,w,h=face
cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,255),2)
cv2.imshow("Frame",frame)
#Store every 10th face
if(skip%10==0):
break
key_pressed=cv2.waitKey(1) & 0xFF
if key_pressed==ord("q"):
break
cap.release() # release the device
cv2.destroyAllWindows()
Getting the below warning and not getting expected output.
PS C:\Users\abhis\images> python face_data_collect.py
()
[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (436) anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback PS C:\Users\abhis\images> python face_data_collect.py () [ WARN:1] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (436)
anonymous-namespace’::SourceReaderCB::~SourceReaderCB terminating async callback
PS C:\Users\abhis\images> python face_data_collect.py
[[233 208 188 188]]
[ WARN:1] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (436) anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback PS C:\Users\abhis\images> python face_data_collect.py () [ WARN:1] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (436)
anonymous-namespace’::SourceReaderCB::~SourceReaderCB terminating async callback
PS C:\Users\abhis\images>