Ask Your Question

Revision history [back]

for below code I'm getting this error: OpenCV(3.4.1) C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\color.cpp:11147: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor

import cv2 import numpy as np

facedetect=cv2.CascadeClassifier('haarcascade_frontalface_default.xml'); cam=cv2.VideoCapture(1);

while(True): retval,img=cam.read();

gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
faces=facedetect.detectMultiScale(gray,1.3,5);
for(x,y,w,h)in faces:
    cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),2)
    cv2.imshow("Face",img);
    if(cv2.waitKey(1)==ord('q')):
        break;
cam.release()
cv2.destroyAllWindows()