You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.
I receive this error when trying to run this function to convert images to grayscale, this is not my code, this was provided by Udacity.
convert BGR image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
error Traceback (most recent call last)
in
1 # convert BGR image to grayscale
----> 2 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
error: OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
That is the whole cell in the detecting human's pictures section
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
I receive this error when trying to run this function to convert images to grayscale, this is not my code, this was provided by Udacity.
convert BGR image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
error Traceback (most recent call last)
in
1 # convert BGR image to grayscale
----> 2 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
error: OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
That is the whole cell in the detecting human's pictures section
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
extract pre-trained face detector
face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_alt.xml')
load color (BGR) image
img = cv2.imread(human_files[3])
convert BGR image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
find faces in image
faces = face_cascade.detectMultiScale(gray)
print number of faces detected in the image
print('Number of faces detected:', len(faces))
get bounding box for each detected face
for (x,y,w,h) in faces:
# add bounding box to color image
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
convert BGR image to RGB for plotting
cv_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
display the image, along with bounding box
plt.imshow(cv_rgb)
plt.show()
The text was updated successfully, but these errors were encountered: