Skip to main content

Python library to map textures on a Wavefront .obj files.

Project description

PyPI version


3DNIRMapper maps multiple textures with given camera parameters on a 3d-model using a z-buffer approach. It was originaly developed to map nearinfrared pictures on a 3d tooth model and was developed in proceedings of my master thesis.

For example with the given camera parameters it can map these two images to a 3d-modell...

preview preview projecting them to the image area and resolving the overlapping parts as shown here:


... and finally creates the combined textured 3d-modell:


The program is able to import wavefront objects and exports them to textured Collada files.

The package is on pypi or can be cloned on github.

pip install nirmapper

CLI Usage

The program comes with a cli, developed with Click. It contains two commands.


The first command maps textures to a 3d-model:


  --zfactor FLOAT        The z factor defines how big the z-buffer should be
                         for the visibility analysis. If results are bad put
                         this up to 2 or 3. Be careful with values below zero
                         because zfactor is multiplied with resolution of
                         camera and must match aspect ratio of resolution.
  --thread / --unthread
  --help                 Show this message and exit.


  • NAME is the name of the model.
  • MODEL_SRC is the path to the model.
  • TEXTURE_SRC ist the path of the textures to map.
  • DST is the destination path.

The camera parameters must be provided for every picture to map in a XML-file in the TEXTURE_SRC that looks like this:

<?xml version="1.0"?>
    <!-- <rotation type="EULER">
    <rotation type="QUAT">

It can contain either euler or quaternion rotation although quaternions are highly recommended. For every texture to map there must be an .xml file with the same file name providing those parameters. An example can be found in nirmapper/resources/xmlExample/.


The second cli call creates a cube, tooth or elefant example:

Usage: nirmapper example [OPTIONS] DST

  --type [cube|tooth|elephant]
  --help                        Show this message and exit.


  • DST is the destination path.

Code Usage

To use the implemented modules for own developments or improvement just include them to your project:

import nirmapper

For example if you want to use on of the examples:

from nirmapper.examples import generate_cube_example

dst = '/tmp/Cube'



All tests can be found in the tests directory. To run the tests:

# Install pywavefront in develop mode
python develop

# Install required packages for running tests
pip install -r test-requirements.txt

# Run all tests

# Optionally specific tests modules can be runned sepeartely
pytest tests/


3DNIRMapper is Apache-licensed

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nirmapper-1.1.10.tar.gz (20.5 MB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page