GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ShapeCompletion3D/binvox-rw-py: Python module to read and write .binvox files.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

22 Commits
22 Commits

Folders and files

NameName
Last commit message
Last commit date
8a85.binvox
8a85.binvox
 
 
COPYING
COPYING
 
 
README.md
README.md
 
 
__init__.py
__init__.py
 
 
binvox_rw.py
binvox_rw.py
 
 
chair.binvox
chair.binvox
 
 
chair.png
chair.png
 
 
fat_chair.png
fat_chair.png
 
 
fix_binvox.py
fix_binvox.py
 
 
gazebo_config_gen.py
gazebo_config_gen.py
 
 
process_modelnet_meshs.py
process_modelnet_meshs.py
 
 
process_shrec_meshes.py
process_shrec_meshes.py
 
 
run_binvox.py
run_binvox.py
 
 
run_binvox_bigbird.py
run_binvox_bigbird.py
 
 
run_binvox_shrec.py
run_binvox_shrec.py
 
 
run_binvox_ycb.py
run_binvox_ycb.py
 
 
run_meshlab.py
run_meshlab.py
 
 

Repository files navigation

binvox-rw-py

Small Python module to read and write .binvox files. The voxel data is represented as dense 3-dimensional Numpy arrays in Python (a direct if somewhat wasteful representation for sparse models) or as an array of 3D coordinates (more memory-efficient for large and sparse models).

Binvox is a neat little program to convert 3D models into binary voxel format. The .binvox file format is a simple run length encoding format described here.

Code example

Suppose you have a voxelized chair model, chair.binvox (you can try it on the one in the repo). Here's how it looks in viewvox:

chair

Then

>>> import binvox_rw
>>> with open('chair.binvox', 'rb') as f:
...     model = binvox_rw.read(f)
...
>>> model.dims
[32, 32, 32]
>>> model.scale
41.133000000000003
>>> model.translate
[0.0, 0.0, 0.0]
>>> model.data
array([[[ True, False, False, ..., False, False, False],
        [ True, False, False, ..., False, False, False],
        [ True, False, False, ..., False, False, False],
        ..., 
       [[False, False, False, ..., False, False, False],
        [False, False, False, ..., False, False, False],
        [False, False, False, ..., False, False, False],
        ..., 
        [False, False, False, ..., False, False, False],
        [False, False, False, ..., False, False, False],
        [False, False, False, ..., False, False, False]]], dtype=bool)

You get the idea. model.data has the boolean 3D array. You can then manipulate however you wish. For example, here we dilate it with scipy.ndimage and write the dilated version to disk:

>>> import scipy.ndimage 
>>> scipy.ndimage.binary_dilation(model.data.copy(), output=model.data)
>>> model.write('dilated.binvox')

Then we get a fat chair:

fat chair

Sparse representation

To get the data as an array of coordinates, look at binvox_rw.read_coords.

Installation

This is a really simple, 200-line module. You should just stick into whatever project you're using. Or copy it to /usr/share/lib/pythonX.Y/site-packages if you really want a system-wide installation.


Daniel Maturana [email protected]

About

Python module to read and write .binvox files.

Resources

Readme
License
Activity
Custom properties

Stars

1 star

Watchers

4 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.