pclausen / obj2png Goto Github PK
View Code? Open in Web Editor NEWPython script for converting 3D triangular mesh (obj) to image file (png) with MatPlotLib
License: MIT License
Python script for converting 3D triangular mesh (obj) to image file (png) with MatPlotLib
License: MIT License
Running the script gave me throws this error. I suspect it is because of a version mismatch.
I think you should specify version numbers in your requirements.txt
Traceback (most recent call last):
File "obj2png/src/obj2png.py", line 122, in
ob.Plot(outfile,elevation=elevation,azim=azim,dpi=dpi,scale=scale,animate=animate)
File "/content/obj2png/src/ObjFile.py", line 184, in Plot
ax.set_box_aspect(np.ptp(limits, axis = 1))
AttributeError: 'Axes3DSubplot' object has no attribute 'set_box_aspect'`
Hello,
Before I try to use your great tool, I would like to know if it converts to png only the .obj file or also (.obj + .mtl) bundles ? And also (.obj + .mtl + .png) bundles (meaning .obj with textures)?
Thanks.
Hi,
Great work, thanks.
Can we able to get the rotation and translation of the object as matrix?
Best regards, Suresh
Hi,
I am trying to use your tool on my Mac.
I installed python3.
Now I do:
python3 obj2png.py -i bunny.obj -v
I get the following errors:
Traceback (most recent call last):
File "/Users/xxx/obj2png/obj2png-main/src/obj2png.py", line 32, in <module>
import ObjFile
File "/Users/xxx/obj2png/obj2png-main/src/ObjFile.py", line 32, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
In line 32 of your code in obj2png.py, there is:
import ObjFile
How can I solve this problem?
Thanks.
Hello dear pclausen,
first things first: thank you so much for this script, it is exactly what I need!
But when running the script as you propose, I am facing the following issue:
Traceback (most recent call last):
File "obj2png.py", line 121, in <module>
ob = ObjFile.ObjFile(objfile)
File "/Users/obj2png/src/ObjFile.py", line 59, in __init__
self.ObjParse(obj_file)
File "/Users/obj2png/src/ObjFile.py", line 97, in ObjParse
faces.append(ObjFile.ToInts(f[1:]))
File "/Users/obj2png/src/ObjFile.py", line 133, in ToInts
v.append(int(nn))
ValueError: invalid literal for int() with base 10: '1/'
Apparently, I am not able to fix this issue.
Can you help?
Cheers :)
thanks for your great work!!!
it is working well when I use the obj. file that you give, but when I use my obj file, there comes bugs as below:
python obj2png.py -i /home/wutao/SMPL-master/obj2png-master/src/rp_janna_posed_004_30k.obj -v
Namespace(animate=False, azim=None, elevation=None, objfiles=['/home/wutao/SMPL-master/obj2png-master/src/rp_janna_posed_004_30k.obj'], outfile=None, quality=None, scale=None, view=True)
Traceback (most recent call last):
File "obj2png.py", line 122, in
ob.Plot(outfile,elevation=elevation,azim=azim,dpi=dpi,scale=scale,animate=animate)
File "/home/wutao/SMPL-master/obj2png-master/src/ObjFile.py", line 178, in Plot
ax.plot_trisurf(self.nodes[:,0],self.nodes[:,1],self.nodes[:,2], triangles=tri)
IndexError: too many indices for array
Do you know how to solve this?
thank you so much!
rp_janna_posed_004_30k.zip
Thanks for your work. And I still have met this problem after I download the latest version code. Could you fix it again?
PS D:\obj2png-master\src> python obj2png.py -i 2.obj
Namespace(animate=False, azim=None, elevation=None, objfiles=['2.obj'], outfile=None, quality=None, scale=None, view=False)
Converting 2.obj to 2.png
Traceback (most recent call last):
File "obj2png.py", line 122, in
ob.Plot(outfile,elevation=elevation,azim=azim,dpi=dpi,scale=scale,animate=animate)
File "D:\obj2png-master\src\ObjFile.py", line 178, in Plot
ax.plot_trisurf(self.nodes[:,0],self.nodes[:,1],self.nodes[:,2], triangles=tri)
IndexError: too many indices for array
2.zip
Hi,
Not an issue but a question/request.
I searched the web and can't find the solution so I was hoping you could help.
I am transforming my obj to png but would like to have the possibility to clip/cut the object. Not sure what the right word for it is but here is an example:
My object .obj file looks like this:
Another way of seeing this would be:
I would want to move the camera in space, to get very close to the object, or better go through the object, and halfway in in it, where the other half is out of picture and clipped, i would want to create a .png of the current view.
Any idea how i could achieve that?
Hello,
First of all, this is a fantastic script, thank you.
I am noticing that the plotting of the obj is not the correct proportion. loading the attached file, I get
while opening it in windows gives me:
I would also like to change the color from blue to something else, and I haven't figured out how to do that yet.
Any help?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.