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

Creating hdf5 files from .obj files #19

Closed
Komti13 opened this issue May 10, 2022 · 10 comments
Closed

Creating hdf5 files from .obj files #19

Komti13 opened this issue May 10, 2022 · 10 comments

Comments

@Komti13
Copy link

Komti13 commented May 10, 2022

Hello i was trying to create my own hdf5 dataset to use for ucsgnet. i want to generate the file from an .obj file extension but i keep getting empty hdf5 files please some help . i followed all the given instructions in the repository

@czq142857
Copy link
Owner

This repo does not contain code or instructions to create hdf5 files from obj files. Did you use the code from somewhere else?

Anyway, please make sure your input data (the binary voxels) are not emply. If they are not empty, the output hdf5 files should not be empty.

@Komti13
Copy link
Author

Komti13 commented May 10, 2022

i see so the only input type i can use is binary voxels and if i want to use obj files (meshes) i should convert them to binary voxels?

@czq142857
Copy link
Owner

Yes. You can read other issues for how to convert obj into binvox.

@Komti13
Copy link
Author

Komti13 commented May 10, 2022

okay thanks a lot for your help

@Komti13 Komti13 closed this as completed May 10, 2022
@Komti13 Komti13 reopened this May 12, 2022
@Komti13
Copy link
Author

Komti13 commented May 12, 2022

Excuse me i did the conversion to .binvox files but there this error in code of .mat files extension which i dont know what it stands for
image
can you please tell me what are the .mat files that i should get to avoid this error
and doing me a big favour can you inform me what i need as input (and where to put input files) to get all the data preparation files executed and the hdf5 files generated successfully. because in the code i found many different data paths and i am confused between them
voxel_input = /local-scratch/zhiqinc/shapenet_hsp/modelBlockedVoxels256/
image_input = /home/zhiqinc/zhiqinc/shapenet_atlas/ShapeNetRendering/
voxel_input_dir = "/home/zhiqinc/zhiqinc/shapenet_hsp/HSPvoxels256/"
img_input_dir = "/home/zhiqinc/zhiqinc/shapenet_hsp/HSPvoxels/"

@Komti13
Copy link
Author

Komti13 commented May 12, 2022

I tried to change the code and open the binvox file like following
image
and i get this error
image
ps: i tried another solution which is to convert .binvox to .mat file with this script xingyuansun/pix3d#19 (comment)
but the same error mentioned above

@czq142857
Copy link
Owner

You only need to assign the voxel grid to voxel_model_256. So here's what you should do.

Replace the following

		#get voxel models
		try:
			voxel_model_mat = loadmat(name_list[idx][1])
		except:
			print("error in loading")
			exit(-1)
		
		
		
		voxel_model_b = voxel_model_mat['b'][:].astype(np.int32)
		voxel_model_bi = voxel_model_mat['bi'][:].astype(np.int32)-1
		voxel_model_256 = np.zeros([256,256,256],np.uint8)
		for i in range(16):
			for j in range(16):
				for k in range(16):
					voxel_model_256[i*16:i*16+16,j*16:j*16+16,k*16:k*16+16] = voxel_model_b[voxel_model_bi[i,j,k]]
		#add flip&transpose to convert coord from shapenet_v1 to shapenet_v2
		voxel_model_256 = np.flip(np.transpose(voxel_model_256, (2,1,0)),2)

with

		voxel_model_file = open(name_list[idx][1], 'rb')
		voxel_model_256 = binvox_rw.read_as_3d_array(voxel_model_file).data.astype(np.uint8)
		#you need to make absolutely sure that the top direction of your shape is j-positive direction in the voxels,
		#otherwise the z-carving code will not work properly. (z-carving ≈ floodfill to make the voxels solid inside)
		#you can adjust the direction of your voxels via np.flip and np.transpose.

@czq142857 czq142857 changed the title Generating empty hdf5 files from .obj file Creating hdf5 files from .obj files May 12, 2022
@Komti13
Copy link
Author

Komti13 commented May 12, 2022

Thank you for your response it really helps, but unfortunately the error this time that the voxel is not of length 256. so it raise an error of index out of bounds
image
the object voxel_model_256 has a length of 64.

@czq142857
Copy link
Owner

So just prepare 256^3 voxels.

@Komti13
Copy link
Author

Komti13 commented May 12, 2022

Okay thank you for helping

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

2 participants