【问题标题】:Getting an error while reading image using cv2.imread() [closed]使用 cv2.imread() 读取图像时出错 [关闭]
【发布时间】:2021-01-01 06:41:08
【问题描述】:

train_data 文件如下所示:

使用imread函数读取图片报错如图

SystemError: 返回 NULL 而没有设置错误

【问题讨论】:

  • 欢迎来到 SO。请重新阅读 How to ask,因为您第一次阅读时似乎错过了一些关键点,即“请勿发布代码、数据、错误的图像消息等。 - 将文本复制或输入到问题中”(强调原文)。看看为什么an image of your code is not helpful
  • 是的,我想我应该详细了解它们。我一定会记住的,谢谢提醒

标签: python opencv


【解决方案1】:

您不能将整个 Pandas 数据帧发送到 cv2.imread。您想访问实际文件本身。您还希望附加图像,而不是仅包含图像的列表以便于访问:

data = []
for i in range(len(train_data)):
    img_array = cv2.imread(train_data.loc[i, 'file'], 1)
    data.append(img_array)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-04
    • 2017-03-20
    • 1970-01-01
    • 2014-06-30
    • 2020-02-24
    • 2018-11-29
    • 1970-01-01
    • 2017-06-21
    相关资源
    最近更新 更多