Watch 1 Star 0 Fork 0

河海大学CG实验室 / voxelizationPython

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
readme.md 2.97 KB
Copy Edit Web IDE Raw Blame History
Mcoder authored 2018-01-03 08:39 . update py arugment

README

This project's aim is to voxelize the *.ply 3D model. But only for ply files, all assimp support files can be voxelized.

Import formats

Autodesk ( .fbx ), Collada ( .dae ), glTF ( .gltf, .glb ), Blender 3D ( .blend ), 3ds Max 3DS ( .3ds ), 3ds Max ASE ( .ase ), Wavefront Object ( .obj ), Industry Foundation Classes (IFC/Step) ( .ifc ), XGL ( .xgl,.zgl ), Stanford Polygon Library ( .ply ), AutoCAD DXF ( .dxf ), LightWave ( .lwo ), LightWave Scene ( .lws ), Modo ( .lxo ), Stereolithography ( .stl ), DirectX X ( .x ), AC3D ( .ac ), Milkshape 3D ( .ms3d ), TrueSpace ( .cob,.scn )

Export voxel formats

numpy

A numpy array with shape of you appointed.Example: you give a vexel size of (100, 100, 100). It will return a numpy array with shape (100, 100, 100). Filename: imagename.npy

When you need to import it, using numpy.load(filename).

JSON

For more convenient usage, it export a json file. Just reshape the numpy array to (-1, ) . As it shown below:

    '[0,1,0,1]'

Filename: iamgename.json

binvox

A format of binvox, using binvox-rw-py to write out .binvox file to floder.

Using this format, you can easily got the result in eyes with viewvox.

Requires

Usage

>>> import voxelization
>>> voxelization.voxelization("134212_1.ply")
('Bounding box: ', 350.86337, 268.0675, 62.311089, 140.45639, 59.910782, -137.18449)
('x_edge: ', 1.0958697001139324, '\ny_edge: ', 1.0841495990753174, '\nz_edge: ', 0.99747787475585936, '\nedge: ', 1.0958697001139324)
('The mesh ', '0', ' has vertices: ', (53215, 3))
('The mesh', '0', ' process successfully in ', 530.8458249568939, 's')
calculate all meshes voxel finished!
array([[[0, 0, 0, ..., 0, 0, 0],
            ......
        [0, 0, 0, ..., 0, 0, 0]]], dtype=int8)
>>>

The file run.sh is the usage of the script batch_voxelization.py. You can change your arguments, and run it just use command bash run.sh in linux.

Show

There is some works of the app. Those screenshot pictures are using viewvox Application.

ply3 view3 ply4 view4

Requires Introduction

PyAssimp

PyAssimp can import and export many formats of 3-D models, very useful.

numpy

NumPy is the fundamental package for scientific computing with Python.

PyFlann

FLANN (Fast Library for Approximate Nearest Neighbors) is a library for performing fast approximate nearest neighbor searches. FLANN is written in the C++ programming language. FLANN can be easily used in many contexts through the C, MATLAB and Python bindings provided with the library.

Comment ( 0 )

Sign in for post a comment

Python
1
https://gitee.com/CGL-HHUC/voxelization.git
git@gitee.com:CGL-HHUC/voxelization.git
CGL-HHUC
voxelization
voxelization
master

Help Search