ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi, here are some suggestions to improve:

In my case images are unordered. To sort images in numerical order, a new function can be defined:

def CompSortFileNamesNr(f):
    g = os.path.splitext(os.path.split(f)[1])[0]
    numbertext = ''.join(c for c in g if c.isdigit())
    return int(numbertext)

And in GetFilesFromDir, change line

            for f in files:

to

            for f in sorted(files, key=CompSortFileNamesNr):

In order to process a sequence of grey-level images, the code may be modified as follow:

Change "rgb8" encoding to "mono8", and "[pix for pixdata in im.getdata() for pix in pixdata]" to "[pix for pixdata in [im.getdata()] for pix in pixdata]"

Bye