简体   繁体   English

错误:我无法将我的图像从 bgr 转换为 rgb:TypeError: Expected Ptr<cv::umat> 对于参数“src”</cv::umat>

[英]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.

相关问题 类型错误:预期的 Ptr<cv::umat> 对于参数'src'?</cv::umat> - TypeError: Expected Ptr<cv::UMat> for argument 'src'? 在将bgr转换为rgb时,获取TypeError:参数&#39;src&#39;的预期cv :: UMat - Getting TypeError: Expected cv::UMat for argument 'src' while casting bgr to rgb 收到错误 TypeError: Expected Ptr<cv::umat> 处理图像时的参数“src”</cv::umat> - Getting the error TypeError: Expected Ptr<cv::UMat> for argument 'src' while processing images 错误“TypeError:预期的 Ptr<cv::umat> 尝试显示数组中的图像时用于参数“垫子”</cv::umat> - Error “TypeError: Expected Ptr<cv::UMat> for argument 'mat'” when trying to display images from an Array Python - tkinter; 类型错误:预期的 Ptr<cv::umat> 对于参数“src”</cv::umat> - Python - tkinter; TypeError: Expected Ptr<cv::UMat> for argument 'src' 期望值<cv::umat>用于 rgb 图像的参数</cv::umat> - Expected Ptr<cv::UMat> for argument for rgb image 预期 Ptr<cv::UMat> 对于参数&#39;src&#39; - Expected Ptr<cv::UMat> for argument 'src' 类型错误:预期的 Ptr<cv::umat> 对于参数 'm'</cv::umat> - TypeError: Expected Ptr<cv::UMat> for argument 'm' 类型错误:预期的 Ptr<cv::umat> 对于参数“%s”</cv::umat> - TypeError: Expected Ptr<cv::UMat> for argument '%s' 类型错误:预期的 Ptr<cv::umat> 对于参数“img”</cv::umat> - TypeError: Expected Ptr<cv::UMat> for argument 'img'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM