[英]error: im not able to convert my images from bgr to rgb: TypeError: Expected Ptr<cv::UMat> for argument 'src'
#error: im not able to convert my images from bgr to rgb #error: 我无法将我的图像从 bgr 转换为 rgb
images = []
path = 'E:\subjects\AI\Face-Mask-Detection-master\without-mask-detections'
listimages=os.listdir(path)
encode_list = []
for img in listimages:
images.append(img)
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
encode = face_recognition.face_encodings(img)
encode_list.append(encode)
print(images)
#encodeListKnown= find_encoding(images)
#print(len(encodeListKnown))
The file name you are using (img) does not include the full path and cannot be opened.您使用的文件名 (img) 不包含完整路径,无法打开。 Also, your code does not open the image file.此外,您的代码不会打开图像文件。 You should build the full path and open it using:您应该构建完整路径并使用以下命令打开它:
for file in listimages:
img = cv2.imread(os.path.join(path, file))
images.append(img)
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
encode = face_recognition.face_encodings(img)
encode_list.append(encode)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.