how to solve this error error: C:\build\2_4_winpack-bindings-win32-vc14-static\opencv\modules\imgproc\src\color.cpp:3783: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor

asked 2019-03-17 05:54:16 -0500

deeitm gravatar image

updated 2019-03-17 20:50:00 -0500

supra56 gravatar image

import cv2 import numpy as np

    faceDetect=cv2.CascadeClassifier('haarcascade_frontalface_default.xml');
    cam=cv2.VideoCapture(0);

    while(True):
        ret,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,255,0),2)
            cv2.imshow("Face",img);
        if(cv2.waitKey(1)==ord('q')):
            break;
    cam.release()
    cv2.destroyALLWindows()
edit retag flag offensive close merge delete

Comments

You have to removed semi-colon. I attempted this, but failed. I cannot solved your problem. But on my side, it will worked, but I had to used OpenCV 4.0.1. What's version OpenCV are you using? Copy and Paste doesn't helped on python. But i still getting an error faces=faceDetect.detectMultiScale(gray,1.3,5), But sorry.

supra56 gravatar imagesupra56 ( 2019-03-18 08:23:26 -0500 )edit