import_auto

menpo.io.base.import_auto(pattern, max_meshes=None, max_images=None)[source]

Smart mixed asset import generator.

Makes it’s best effort to import and attach relevant related information such as landmarks. It searches the directory for files that begin with the same filename and end in a supported extension. Furthermore, this method attempts to handle mixed assets (e.g. textured meshes in the same folder as images) without ‘double importing’ anything.

Note that this is a generator function. This allows for pre-processing of data to take place as data is imported (e.g. cropping images to landmarks as they are imported for memory efficiency).

Parameters:

pattern : String

The glob path pattern to search for textures and meshes.

max_meshes: positive integer, optional :

If not None, only import the first max_mesh meshes found. Else, import all.

Default: None

max_images: positive integer, optional :

If not None, only import the first max_images found. Else, import all.

Default: None

Examples

Import all meshes that have file extension .obj:

>>> meshes = list(import_auto('*.obj'))

(note the cast to a list as auto_import is a generator and we want to exhaust it’s values)

Look for all files that begin with the string test:

>>> test_images = list(import_auto('test.*'))

Assuming that in the current directory that are two files, bunny.obj and bunny.pts, which represent a mesh and it’s landmarks, calling

>>> bunny = list(import_auto('bunny.obj'))

Will create a mesh object that includes the landmarks automatically.