2

I get this error after adding the part for saving the images, any idea how to get this error fixed ? This answer it doesn't help and it is in c++

for co in range(1, 5):
fsize = cv2.resize(roi_gray, (100, 100))

...........................................................................

errorTraceback (most recent call last)
<ipython-input-1-86e0bb6aa30e> in <module>()
     62 
     63 if __name__ == "__main__":
---> 64     create()

<ipython-input-1-86e0bb6aa30e> in create()
     21                 ret, frame = camera.read()
     22 
---> 23                 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
     24 
     25         faces = faceCascade.detectMultiScale(

error: C:\build\2_4_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\color.cpp:3739: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor
2

1 Answer 1

1

As |'L'| has said, it may be the same issue where your camera capture a gray scale image so the conversion does not work. Another possibility is youy indicate a wrong camera. The front camera for a mac is camercapture(1) while 0 for window, try change this.

Sign up to request clarification or add additional context in comments.

2 Comments

"The front camera for a mac is camercapture(1) while 0 for window" --- This is not true. If you only have a single camera, it should be VideoCapture(0) regardless of the OS. I have a Macbook and my front camera is still 0. Also, the paths displayed hint at the OP using Windows anyways.
No it doesnot work for me, and the error came after i changed while (True): into for co in range(1, 5): and also this part fsize = cv2.resize(roi_gray, (100, 100)) cv2.imwrite('%s/%s.JPEG' % (path,count), fsize)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.