-
Notifications
You must be signed in to change notification settings - Fork 0
/
binvox-rw-py3.html
157 lines (154 loc) · 8.13 KB
/
binvox-rw-py3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Using binvox-rw-py with Python 3 — A Place for Asides</title>
<meta name="description" content="Title: Using binvox-rw-py with Python 3; Date: 2018-10-30; Author: Peter Mortimer">
<meta name="author" content="Peter">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="./theme/html5.js"></script>
<![endif]-->
<link href="./theme/css/ipython.css" rel="stylesheet">
<link href="./theme/css/jquery.tocify.css" rel="stylesheet">
<link href="./theme/css/lightbox.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<!--
<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/minty/bootstrap.min.css" rel="stylesheet">
-->
<link href="./theme/css/local.css" rel="stylesheet">
<link href="./theme/css/pygments.css" rel="stylesheet">
</head>
<body>
<div id="toc"></div><div class="container main">
<div class="page-header">
<div class="row">
<div class="col-8 col-sm-8">
<h1><a href="./">A Place for Asides</a>
<br> </div>
<div class="col-4 col-sm-4 page-header-links">
<p><a href="/pages/about.html">About</a> | <a href="/pages/publications.html">Publications</a> | <a href="/pages/previous-projects.html">Previous Projects</a> | <a href="/blog/index.html">Blog</a> | <a href="/pages/books.html">Book List</a> </p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="article" itemscope itemtype="http://schema.org/BlogPosting">
<div class="text-center article-header">
<h1 itemprop="name headline" class="article-title">Using binvox-rw-py with Python 3</h1>
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
<h4 itemprop="name">Peter Mortimer</h4>
</span>
<time datetime="2018-10-30T23:00:00+01:00" itemprop="datePublished">October 30 2018</time>
</div>
<div itemprop="articleBody" class="article-body"><h1 style="visibility:hidden;">Using binvox-rw-py with Python 3</h1>
<p>The Python project <strong>binvox-rw-py</strong> is based on the <a href="https://www.patrickmin.com/binvox/">binvox</a> project from Patrick Min. It is a simple and easy-to-use tool to convert 3D model files into 3D voxel grids (it supports most of the common 3D model file formats: .obj, .ply, .stl; the output format is typically the custom <strong>.binvox</strong> file format).</p>
<p>Some research projects in the field of 3D machine learning may use this library to create voxelized scenes for training. These voxelized scenes are used to train networks to learn a rudimentary understanding of the scene's geometry in a more easily quantifiable way. This is how I stumbled upon the <a href="https://github.com/dimatura/binvox-rw-py">binvox-rw-py</a> module, which enables you to read .binvox files as 3-dimensional Numpy arrays in Python. You can also write numpy arrays into .binvox using binvox-rw-py.</p>
<h3>Troubles with writing .binvox files in Python 3</h3>
<p>The original binvox-rw-py from the GitHub user <a href="https://github.com/dimatura/">dimatura</a> has issues with writing .binvox files when running it in Python 3, since it was implemented with the byte handling of Python 2 in mind. I discovered this after a few frustrating hours by simply reading and writing the same .binvox file I generated for my project and comparing the resulting voxelized scenes using <a href="https://www.patrickmin.com/viewvox/">viewvox</a> (which is also from Patrick Min):</p>
<p><img alt="Comparing the resulting voxelized scenes when reading and writing the same .binvox file using binvox-rw-py with Python 3. The left image shows the broken scene voxelization using dimatura's module with Python 3, while the right image shows the correct scene voxelization using pclausen's module with Python 3." src="./images/binvox/binvox_write_compare.png"></p>
<p>Luckly, the GitHub user <a href="https://github.com/pclausen/">pclausen</a> has already created a forked version of the <a href="https://github.com/pclausen/binvox-rw-py">binvox-rw-py</a> module that resolves this issue. This makes it possible to also use binvox-rw-py with Python 3.</p>
<p>Unfortunately, the fixed binvox-rw-py module by pclausen does not seem as well known as the original module by dimatura if you compare the number of stars for each GitHub repository (at the time of writing dimatura's repository has 69 stars, while pclausen's repo only has 2 stars). pclausen has even originally created an <a href="https://github.com/dimatura/binvox-rw-py/issues/3">issue</a> in dimatura's issue tracker for the binvox-rw-py regarding the Python 3 writing issue. The issue has not been closed even until today.</p>
<p>So I hope this post could help someone, who has been having issues using binvox-rw-py with Python 3 and save the person some time when trying to find the bug in his code.</p>
<p>To install pclausen's binvox-rw-py module using pip, simply write the following command:</p>
<div class="highlight"><pre><span></span>pip install git+https://github.com/pclausen/binvox-rw-py
</pre></div></div>
<hr>
<div>
Category:
<span itemprop="articleSection">
<a href="./category/python.html" rel="category">Python</a>
</span>
</div>
<div>
Tags:
<span itemprop="keywords">
<a href="./tag/binvox.html" rel="tag">binvox</a>
</span>
<span itemprop="keywords">
<a href="./tag/pip.html" rel="tag">pip</a>
</span>
</div>
</div>
</div>
</div> <!-- <hr> -->
</div> <!-- /container -->
<footer class="aw-footer bg-danger">
<div class="container"> <!-- footer -->
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="row">
<div class="col-md-3">
<h4>Navigation</h4>
<ul class="list-unstyled my-list-style">
<li><a href=".">A Place for Asides</a></li>
<li><a href="./pages/about.html"><i class="fa fa-About "></i> About</a></li>
<li><a href="./pages/blogroll.html"><i class="fa fa-Blogroll "></i> Blogroll</a></li>
<li><a href="./pages/books.html"><i class="fa fa-Books I've Read "></i> Books I've Read</a></li>
<li><a href="./pages/previous-projects.html"><i class="fa fa-Previous Projects "></i> Previous Projects</a></li>
<li><a href="./pages/publications.html"><i class="fa fa-Publications "></i> Publications</a></li>
</ul>
</div>
<div class="col-md-3">
<h4>Author</h4>
<ul class="list-unstyled my-list-style">
<li><a href="https://github.com/tonyromarock">GitHub</a></li>
</ul>
</div>
<div class="col-md-3">
<h4>Categories</h4>
<ul class="list-unstyled my-list-style">
<li><a href="./category/linux.html">Linux (1)</a></li>
<li><a href="./category/nonfiction.html">Nonfiction (1)</a></li>
<li><a href="./category/python.html">Python (3)</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</footer>
<div class="container bottom">
<div class="row">
<div class="col-md-12 text-center center-block aw-bottom">
<p>© Peter 2020</p>
<p>Powered by Pelican</p>
</div>
</div>
</div>
<!-- JavaScript -->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="./theme/js/jquery-ui-1.9.1.custom.min.js"></script>
<script src="./theme/js/jquery.tocify.min.js"></script>
<script src="./theme/js/lightbox.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("div.collapseheader").click(function () {
$header = $(this).children("span").first();
$codearea = $(this).children(".input_area");
$codearea.slideToggle(500, function () {
$header.text(function () {
return $codearea.is(":visible") ? "Collapse Code" : "Expand Code";
});
});
});
});
$(function() {
var toc = $("#toc").tocify({
context:"div.article-body",
selectors:"h1,h3",
showAndHide:"false",
extendPage:"false",
history:"true",
scrollHistory:"true"
}).data("toc-tocify");
});
lightbox.option({
'wrapAround': true
});
</script>
</body>
</html>