Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Procedure for voxel generation #19

Closed
purugupta99 opened this issue Jul 28, 2020 · 11 comments
Closed

Procedure for voxel generation #19

purugupta99 opened this issue Jul 28, 2020 · 11 comments

Comments

@purugupta99
Copy link

Can you share the procedure for generating the voxels(.mat file) from the mesh files? I'm trying to generate similar dataset to be used for training MeshRCNN.
TIA

@xingyuansun
Copy link
Owner

Hi,

Thank you for asking! We previously used some MATLAB code to generate voxels from mesh grids. Unfortunately, it is difficult for me to access the code after moving to Princeton. However, you may still use tools like binvox to voxelize meshes. Thank you!

Best,
Xingyuan

@purugupta99
Copy link
Author

Hi @xingyuansun
I tried using binvox, but facing following issues:-

  1. I am converting .binvox files to .mat files using scipy and having problems with the orientation of object in the .mat file
  2. I am not able to get the R|t matrix of the camera in viewvox, viewvox is the file provided by the creator of binvox to view the .binvox file
    PFA the attached sample images from viewvox(.binvox file) and the .mat file respectively :-
    WhatsApp Image 2020-08-01 at 2 31 28 AM
    WhatsApp Image 2020-08-01 at 2 31 29 AM

@ZZWENG
Copy link

ZZWENG commented Sep 2, 2020

Hi, @purugupta99 I am going through the same procedure and am wondering if you figured it out? My obj file had xyz range of [-1, 1] but the coordinates stored in the binvox files have range approximately in [0, 256]. Is there any scaling we need to do before feeding the obj to binvox, or is there a way to get the R, T matrices?

Edit: Nevermind, I figured it out.

@bluestyle97
Copy link

Hi, @ZZWENG , I'm facing the same issue, could you please kindly teach me how you figure it out?

@bluestyle97
Copy link

bluestyle97 commented Oct 15, 2020

Hi, @purugupta99 , could you please tell me what program you are using to visualize the binvox files as in the upper picture?

Edit: It is viewvox, I ignore that, nervermind.

@ZZWENG
Copy link

ZZWENG commented Oct 15, 2020

Hi, @ZZWENG , I'm facing the same issue, could you please kindly teach me how you figure it out?

I am not sure what your use case is, so it may not be applicable to you. For me, I first convert all .obj files to .binvox files

ls path/*.obj | xargs -n1 ./binvox -d 128

And then, I used binvox_rw module to convert .binvox to .mat, and then used meshrcnn's utilility function to load the .mat file.

import binvox_rw
from scipy.io import savemat
model = binvox_rw.read_as_3d_array(open(binvox_fname, 'rb'))
voxels = model.data.astype(np.int).transpose(0,2,1)
voxels[:, 1, :] = -voxels[:, 1, :]
savemat(mat_fname, {'voxel': voxels})
from meshrcnn.utils import shape as shape_utils
my_voxels = shape_utils.read_voxel(mat_fname)

@bluestyle97
Copy link

bluestyle97 commented Oct 15, 2020

Hi, @ZZWENG Thanks a lot for your kind reply! I'm trying to train meshrcnn on a custom 3D model dataset too. Could you please explain why you did these two operations when converting .binvox to .mat? Is them essential and what do they mean?

voxels = model.data.astype(np.int).transpose(0,2,1)
voxels[:, 1, :] = -voxels[:, 1, :]

@ZZWENG
Copy link

ZZWENG commented Oct 15, 2020

Hi, @ZZWENG Thanks a lot for your kind reply! I'm trying to train meshrcnn on a custom 3D model dataset too. Could you please explain why you did these two operations when converting .binvox to .mat? Is them essential and what do they mean?

voxels = model.data.astype(np.int).transpose(0,2,1)
voxels[:, 1, :] = -voxels[:, 1, :]

I remember doing that while I was trying to replicate a pix3D voxel file using its .obj file. Maybe it is not necessary for you.

@bluestyle97
Copy link

bluestyle97 commented Oct 16, 2020 via email

@jiayaozhang
Copy link

@bluestyle97

Hi, I know how to get the voxel.mat then, but i have a question about how to get the rot_mat and trans_mat ?
Can you help me?

@H19012
Copy link

H19012 commented Nov 1, 2022

Does anybody know the way to convert .mat to .binvox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants