@solve img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' error
It is not clear whether the input image is single-channel or multi-channel, and the grayscale of the image.
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
One, know whether the input is a single-channel image or a multi-channel image
Second, if it is a single channel, directly cv2.imread(tmp_path, 0)
read in single channel mode, do not read in multi channel mode such as 1, otherwise cv2.cvtColor it will report an error.
Third, choose a high-quality one. For face recognition, choose a photo with a fuller and clearer face.