简体   繁体   English

<built-in function imread>返回 NULL 没有设置错误</built-in>

[英]<built-in function imread> returned NULL without setting an error

    def image_descriptors(file):
      img = cv2.imread(file,0)
      img = cv2.resize(img, (256, 256))
      _ , descriptors = cv2.SIFT().detectAndCompute(img, None)
   return descriptors
   def folder_descriptors(folder):
     cv_img=[]
     for img in glob.glob("*.jpg"):
         n=cv2.imread(img)
         cv_img.append(n)
   print("Calculating descriptos. Number of images is", len(cv_img))
   return np.concatenate([image_descriptors(file) for file in cv_img])

I am getting the following in output screen: Calculating descriptos.我在 output 屏幕中得到以下信息:计算描述。 Number of images is 274 SystemError: returned NULL without setting an error图像数量为 274 SystemError: returned NULL 未设置错误

Path.glob return list of Path object ( WindowsPath in windows or PosixPath in linux). Path.glob返回Path object 的列表( PosixPath中的WindowsPath或 linux 中的 PosixPath)。 and cv2.imread expect string .cv2.imread期望字符串

you can get string of path from Path object using str class ( str(path_object) ) or build in magic method from Path object ( path_object.__str__() )您可以使用str class ( str(path_object) )从Path object 获取路径字符串或从Path object ( path_object.__str__() )构建魔术方法

def image_descriptors(file):
  img = cv2.imread(file,0)
  img = cv2.resize(img, (256, 256))
  _ , descriptors = cv2.SIFT().detectAndCompute(img, None)
  return descriptors
def folder_descriptors(folder):
  cv_img=[]
  for img in glob.glob("*.jpg"):
     # convert `Path` object to string
     n=cv2.imread(str(img))
     cv_img.append(n)
  print("Calculating descriptos. Number of images is", len(cv_img))
  return np.concatenate([image_descriptors(file) for file in cv_img])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 cv2.imread 错误:img = cv2.imread(0) 系统错误:<built-in function imread> 返回 NULL 没有设置错误</built-in> - cv2.imread error:img = cv2.imread(0) SystemError: <built-in function imread> returned NULL without setting an error 对象检测图像文件夹读取返回<built-in function imread>返回 NULL 而不设置错误 - Object Detection Images folder read return <built-in function imread> returned NULL without setting an error 系统错误:<built-in function imread> 返回 NULL 没有设置错误(tkinter)</built-in> - SystemError: <built-in function imread> returned NULL without setting an error (tkinter) 使用 cv2.imread:“<built-in function imread> 没有设置错误就返回NULL”,好像无法打开图片或获取数据</built-in> - Using cv2.imread: “<built-in function imread> returned NULL without setting an error”, as if it can't open the picture or get the data 将 OpenCV imread 和 imwrite 与 Python Path 对象一起使用会给出 SystemError:<built-in function imread> 返回 NULL 没有设置错误</built-in> - Using OpenCV imread and imwrite with Python Path objects gives SystemError: <built-in function imread> returned NULL without setting an error <built-in function imshow>返回 NULL 而不设置错误 - <built-in function imshow> returned NULL without setting an error 系统错误:<built-in function puttext> 返回 NULL 没有设置错误</built-in> - SystemError: <built-in function putText> returned NULL without setting an error tensorflow: <built-in function AppendInt32ArrayToTensorProto> 返回NULL而不设置错误 - tensorflow: <built-in function AppendInt32ArrayToTensorProto> returned NULL without setting an error cv2.imwrite() 系统错误:<built-in function imwrite> 返回 NULL 没有设置错误</built-in> - cv2.imwrite() SystemError: <built-in function imwrite> returned NULL without setting an error 如何修复“系统错误:<built-in function 'name'> 在 Python C 扩展中返回 NULL 而不设置错误” - How to fix "SystemError: <built-in function 'name'> returned NULL without setting an error" in Python C Extension
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM