thecodacus / Face-Recognition

Face Recognition tutorial code
Apache License 2.0
81 stars 73 forks source link

detector.py - Assertion failed #7

Closed Mayoogh closed 4 years ago

Mayoogh commented 5 years ago

opencv version 4.0.0 Python version 3.5.2

File "detector.py", line 18, in gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.0.0) /io/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

mandjevant commented 5 years ago

Possibly failed to load the webcam properly. Check in your cv2.imread line if the webcam exist and does not return a None. Also check the count variable if it has a valid number.

Also, the detector.py in detectMultiScale inputs a flags parameter. This parameter is only used by old format cascade, removing the parameter might help you resolve your error.

Mayoogh commented 4 years ago
faces = detector.detectMultiScale(gray, scaleFactor=1.2, minNeighbors=5, minSize=(100, 100))

flags – Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.

https://docs.opencv.org/2.4/modules/objdetect/doc/cascade_classification.html