FcascPath='/content/drive/MyDrive/COTM july/Copy of haarcascade_frontalface_default.xml'
#Create the haar cascade
faceCascade = cv2.CascadeClassifier(FcascPath)
def imgdetect(gray,image):
faces=faceCascade.detectMultiScale(gray,1.3,5)
for (x,y,w,h) in faces:
cv2.rectangle(image,(x,y),(x+w,y+h),(0,255,0),2)
roi_gray=gray[y:y+h,x:x+w]
return image
i10="/content/drive/MyDrive/COTM july/Faces /10.jpg"
gr = cv2.cvtColor(i10, cv2.COLOR_BGR2GRAY)
canvas=imgdetect(gr,i10)
cv2.imshow("resultvideo", canavs)
And it is showing this:
TypeError Traceback (most recent call last) in () 13 14 i10="/content/drive/MyDrive/COTM july/Faces /10.jpg" ---> 15 gr = cv2.cvtColor(i10, cv2.COLOR_BGR2GRAY) 16 17 canvas=imgdetect(gr,i10)
TypeError: Expected Ptr<cv::UMat> for argument '%s