简体   繁体   English

imutils.imlist openCV Python

[英]imutils.imlist openCV Python

I am currently using OPENCV 3.1 version 我目前正在使用OPENCV 3.1版本

I am facing error in using imutils.imlist(dir) error AttributeError: module 'imutils' has no attribute 'imlist' 我在使用imutils.imlist(dir)时遇到错误AttributeError:模块'imutils'没有属性'imlist'

please suggest some other attribute which can be used instead of imlist or tell what imlist does exaclty 请提出一些可以代替imlist使用的其他属性,或告诉imlist做些什么

If you follow the blog post completely, you will realize that the blogger wasn't using the pip package imutils. 如果您完全关注博客文章,您将意识到博客没有使用pip软件包imutils。 He was using his own custom file which he imported and the name of the custom file is imutils, which is present on github . 他使用了自己导入的自定义文件,该自定义文件的名称为imutils,该文件位于github上

As of 19 March, 2017, the function you are looking for is: 截至2017年3月19日,您正在寻找的功能是:

def imlist(path):
    """
    The function imlist returns all the names of the files in 
    the directory path supplied as argument to the function.
    """
    return [os.path.join(path, f) for f in os.listdir(path)]

That being said, IIUC, this function assumes that all files inside the given directory are images. 就是说,IIUC,此功能假定给定目录内的所有文件均为图像。 Instead of that, the imutils package which you are using, has a function of it's own, called list_images which provides similar functionality (it's recursive). 取而代之的是,您正在使用的imutils软件包具有自己的功能,称为list_images ,它提供了类似的功能(它是递归的)。 You can use it like this: 您可以像这样使用它:

from imutils import paths

list(paths.list_images('/path/to/dir/containing/images'))

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM