How to convert HDRI background images to object files?
monajalal opened this issue · 1 comments
monajalal commented
I notice that in main_rand.py you are looking for background object files. Could you please share how you convert the polyhaven HDRI files to obj files?
https://blender.stackexchange.com/q/306416/96194
BlenderProc2_Cobot/main_rand.py
Line 55 in ea97fcc
monajalal commented
just a followup, I created an object and made it like this but it seems the board is crashing to it
somehow the method below is not making the pose correct such that the april tag board is laid out on top of it. Could you please suggest a fix?
images = list(Path('/home/mona/BlenderProc2_Cobot/BlenderProc/data/backgrounds').rglob('*.png')) + list(Path(' /home/mona/BlenderProc2_Cobot/BlenderProc/data/backgrounds').rglob('*.jpg'))
print('background images: ', images)
parts = ['mainshell', 'topshell', 'insert_mold', 'usb_c', 'female_usb', '55917-700lf']
obj_queue = []
for obj in Path("./CAD_model/models").rglob('*.obj'):
print('obj.name: ', obj.name)
if 'background' in obj.name:
print('background in obj name: ', obj.name)
# print(f'Skipping loading part {obj.name}')
print('dir(obj): ', dir(obj))
background = bproc.loader.load_obj(str(obj)).pop()
background.set_cp("category_id", 0)
pose = np.eye(4)
pose[:, 3] = np.array([0, 0, 0-0.01, 1]).T
background.set_scale([1, 1, 1])
background.set_local2world_mat(pose)
background.enable_rigidbody(active=False, collision_shape="CONVEX_HULL")
image = bpy.data.images.load(filepath=str(random.choice(images)))
for m in background.get_materials():
print('material in background is: ', m)
m.set_principled_shader_value('Base Color', image)
continue
## TODO(yangfei): should assign each part with unique id? e.g. mainshell_00
for _ in range(10):
obj_queue.append(bproc.loader.load_obj(str(obj)).pop())
part = obj_queue[-1]
print(obj.name)
# remove '.obj'
print('parts: ', parts)
idx = parts.index(obj.name[:-4])
part.set_cp("category_id", idx + 1)
part.set_name(parts[idx])
print('category_id =', part.get_cp("category_id"))
print('Part Name =', part.get_name())
I have:
(base) mona@ada:~/BlenderProc2_Cobot/BlenderProc/CAD_model/models$ ls
total 2.0M
drwxrwxr-x 4 mona mona 4.0K Dec 5 13:32 ..
-rw-rw-r-- 1 mona mona 1.8M Dec 6 10:06 abandoned_tank_farm_03_primary.png
-rw-rw-r-- 1 mona mona 225K Dec 6 11:36 55917-700lf.obj
-rw-rw-r-- 1 mona mona 242 Dec 6 11:36 55917-700lf.mtl
-rw-rw-r-- 1 mona mona 990 Dec 6 13:01 brick_background.obj
-rw-rw-r-- 1 mona mona 295 Dec 6 13:03 brick_background.mtl
drwxrwxr-x 2 mona mona 4.0K Dec 6 13:06 .
and
abandoned_tank_farm_03_primary.png
is