用于映射wavefront.obj文件上纹理的python库。
nirmapper的Python项目详细描述
三维近红外成像仪
3DNIRMapper使用z缓冲区方法在三维模型上映射具有给定相机参数的多个纹理它最初是在三维牙齿模型上绘制近红外图像的,是在我的硕士论文中开发的
例如,使用给定的相机参数,它可以将这两个图像映射到三维模型…
…将它们投影到图像区域并解决重叠部分,如下所示:
…最后创建组合纹理三维模型:
该程序能够导入波前对象并将其导出到有纹理的collada文件。
pip install nirmapper
cli用法
该程序带有cli,通过click开发。它包含两个命令
地图
第一个命令将纹理映射到三维模型:
Usage: nirmapper map [OPTIONS] NAME MODEL_SRC TEXTURE_SRC DST
Options:
--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是模型的名称
- model_src是模型的路径。
- 纹理是要映射的纹理的路径。
- DST是目标路径
必须提供相机参数,以便将每个图片映射到纹理src中的xml文件中,该纹理src如下:
<?xml version="1.0"?>
<data>
<focal-length>35</focal-length>
<resolution>
<width>1280</width>
<height>1024</height>
</resolution>
<sensor>
<width>32</width>
<height>25.6</height>
</sensor>
<location>
<x>-1.2196</x>
<y>1.2096</y>
<z>9.8</z>
</location>
<!-- <rotation type="EULER">
<x>-8</x>
<y>20.2</y>
<z>85.2</z>
</rotation>-->
<rotation type="QUAT">
<w>0.715</w>
<x>-0.169</x>
<y>0.082</y>
<z>0.674</z>
</rotation>
</data>
它可以包含euler或四元数旋转,但强烈建议使用四元数对于每个要映射的纹理,必须有一个.xml文件,该文件具有提供这些参数的相同文件名可以在nirmapper/resources/xmlExample/中找到一个示例
示例
第二个cli调用创建一个cube、tooth或elefant示例:
Usage: nirmapper example [OPTIONS] DST
Options:
--type [cube|tooth|elephant]
--help Show this message and exit.
其中:
- DST是目标路径
代码使用
要将实现的模块用于自己的开发或改进,只需将它们包含到项目中:
importnirmapper
例如,如果要在以下示例中使用:
fromnirmapper.examplesimportgenerate_cube_exampledst='/tmp/Cube'generate_cube_example(dst)
测试
所有测试都可以在tests
目录中找到运行测试:
# Install pywavefront in develop mode python setup.py develop # Install required packages for running tests pip install -r test-requirements.txt # Run all tests pytest # Optionally specific tests modules can be runned sepeartely pytest tests/test_parser.py
许可证
3dnirmapper是Apache-licensed