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

Front 3D dataset renderting problem #1137

Open
JiChenha0 opened this issue Jul 31, 2024 · 4 comments
Open

Front 3D dataset renderting problem #1137

JiChenha0 opened this issue Jul 31, 2024 · 4 comments
Labels
first answer provided question Question, not yet a bug ;)

Comments

@JiChenha0
Copy link

Describe the issue

When I render images using the Front3D dataset, only the textures of the furniture are loaded correctly, while the walls and ceilings do not have any textures. Is this due to the JSON files in the Front3D dataset itself, or is there something that needs to be modified?

Minimal code example

import blenderproc as bproc
import argparse
import os
import numpy as np


parser = argparse.ArgumentParser()
parser.add_argument("front", help="Path to the 3D front file")
parser.add_argument("future_folder", help="Path to the 3D Future Model folder.")
parser.add_argument("front_3D_texture_path", help="Path to the 3D FRONT texture folder.")
parser.add_argument("output_dir", help="Path to where the data should be saved")
args = parser.parse_args()

if not os.path.exists(args.front) or not os.path.exists(args.future_folder):
    raise Exception("One of the two folders does not exist!")

bproc.init()
mapping_file = bproc.utility.resolve_resource(os.path.join("front_3D", "3D_front_mapping.csv"))
mapping = bproc.utility.LabelIdMapping.from_csv(mapping_file)

# set the light bounces
bproc.renderer.set_light_bounces(diffuse_bounces=200, glossy_bounces=200, max_bounces=200,
                                  transmission_bounces=200, transparent_max_bounces=200)

# load the front 3D objects
loaded_objects = bproc.loader.load_front3d(
    json_path=args.front,
    future_model_path=args.future_folder,
    front_3D_texture_path=args.front_3D_texture_path,
    label_mapping=mapping
)

# Init sampler for sampling locations inside the loaded front3D house
point_sampler = bproc.sampler.Front3DPointInRoomSampler(loaded_objects)

# Init bvh tree containing all mesh objects
bvh_tree = bproc.object.create_bvh_tree_multi_objects([o for o in loaded_objects if isinstance(o, bproc.types.MeshObject)])

poses = 0
tries = 0


def check_name(name):
    for category_name in ["chair", "sofa", "table", "bed"]:
        if category_name in name.lower():
            return True
    return False


# filter some objects from the loaded objects, which are later used in calculating an interesting score
special_objects = [obj.get_cp("category_id") for obj in loaded_objects if check_name(obj.get_name())]

proximity_checks = {"min": 1.0, "avg": {"min": 2.5, "max": 3.5}, "no_background": True}
while tries < 10000 and poses < 10:
    # Sample point inside house
    height = np.random.uniform(1.4, 1.8)
    location = point_sampler.sample(height)
    # Sample rotation (fix around X and Y axis)
    rotation = np.random.uniform([1.2217, 0, 0], [1.338, 0, np.pi * 2])
    cam2world_matrix = bproc.math.build_transformation_mat(location, rotation)

    # Check that obstacles are at least 1 meter away from the camera and have an average distance between 2.5 and 3.5
    # meters and make sure that no background is visible, finally make sure the view is interesting enough
    if bproc.camera.scene_coverage_score(cam2world_matrix, special_objects, special_objects_weight=10.0) > 0.8 \
            and bproc.camera.perform_obstacle_in_view_check(cam2world_matrix, proximity_checks, bvh_tree):
        bproc.camera.add_camera_pose(cam2world_matrix)
        poses += 1
    tries += 1

# Also render normals
bproc.renderer.enable_normals_output()
bproc.renderer.enable_segmentation_output(map_by=["category_id"])

# render the whole pipeline
data = bproc.renderer.render()

# write the data to a .hdf5 container
bproc.writer.write_hdf5(args.output_dir, data)

Files required to run the code

No response

Expected behavior

I expect the walls and ceilings to load their textures correctly during rendering.

BlenderProc version

3.5.1

@JiChenha0 JiChenha0 added the question Question, not yet a bug ;) label Jul 31, 2024
@cornerfarmer
Copy link
Member

The walls and ceiling dont have textures provided by the front 3d json files. You can take a look at https://github.com/DLR-RM/BlenderProc/blob/main/examples/datasets/front_3d_with_improved_mat/README.md to see how to assign random textures to these parts.

@JiChenha0
Copy link
Author

The walls and ceiling dont have textures provided by the front 3d json files. You can take a look at https://github.com/DLR-RM/BlenderProc/blob/main/examples/datasets/front_3d_with_improved_mat/README.md to see how to assign random textures to these parts.

Thank you so much!
I also want to know can Blenderproc generate .navmesh file?

@cornerfarmer
Copy link
Member

No that is not possible per default. You would need to write a custom exporter for that.

@JiChenha0
Copy link
Author

When I render the Front 3D dataset, the windows appear gray, which looks quite jarring. Is there any way to resolve this issue? For example, can I generate a view of the scenery outside the windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first answer provided question Question, not yet a bug ;)
Projects
None yet
Development

No branches or pull requests

2 participants