Closed mikkelmedm closed 2 years ago
Okay, so guess I found a workable solution. But not sure how good it is.
In utility/SegMapRendererUtility.py
I changed it to
def _set_world_background_color(color):
""" Set the background color of the blender world obejct.
:param color: A 3-dim array containing the background color in range [0, 255]
"""
nodes = bpy.context.scene.world.node_tree.nodes
links = bpy.context.scene.world.node_tree.links
# Unlink any incoming link
if len(nodes.get("Background").inputs['Color'].links) > 0:
links.remove(nodes.get("Background").inputs['Color'].links[0])
# Set strength to 1 as it would act as a multiplier
nodes.get("Background").inputs['Strength'].default_value = 0 # CHANGED THIS TO 0 INSTEAD OF 1
nodes.get("Background").inputs['Color'].default_value = color + [0] # CHANGED THIS TO 0 INSTEAD OF 1
This seem to avoid the error, but not knowledable enough in Blender to know the consequences.
Above didn't help. Still working on a fix.
Still looking for a fix to this
Same issue, hope for solution! T^T。
Hey @mikkelmedm and @saprrow,
sorry for the late response. Apparently the hdr image was still active during rendering the seg maps which lead to having more colors than objects in the image.
You can fix the error by adding two lines to the end of _set_world_background_color
:
def _set_world_background_color(color: mathutils.Vector):
""" Set the background color of the blender world object.
:param color: A 3-dim array containing the background color in range [0, 255]
"""
nodes = bpy.context.scene.world.node_tree.nodes
links = bpy.context.scene.world.node_tree.links
# Unlink any incoming link that would overwrite the default value
if len(nodes.get("Background").inputs['Color'].links) > 0:
links.remove(nodes.get("Background").inputs['Color'].links[0])
# Set strength to 1 as it would act as a multiplier
nodes.get("Background").inputs['Strength'].default_value = 1
nodes.get("Background").inputs['Color'].default_value = color + [1]
# Make sure the background node is connected to the output node
output_node = Utility.get_the_one_node_with_type(nodes, "Output")
links.new(nodes.get("Background").outputs["Background"], output_node.inputs["Surface"])
I will create a PR to fix this on the main branch
Describe the bug Duplicate of #283. This error seem to pop up after a few runs at a certain angle, where it appears camera is facing the sky. Seem the fix of #283 is already implemented in the newer versions, so very curios to what could help in this scenario.
General Information
blenderproc run main.py output
parser = argparse.ArgumentParser()
Paths:
parser.add_argument('output_dir', default="trackar_data/output", help="Path to where the final files will be saved ") parser.add_argument('--cc_textures_path', default="resources/cctextures", help="Path to downloaded cc textures")
Parameters:
parser.add_argument('--bound_box', default=False, help="True for BBox keypoints - False for unique keypoints")
parser.add_argument('--scene', default="heineken.blend", help="Path to the scene.blend file") parser.add_argument('--object_name', default="beer", help="Name of object in .blend file with keypoints") parser.add_argument('--multi_obj', default=False, help="If the scene contains multiple objects to load one at random")
parser.add_argument('haven_path', nargs='?', default="resources/haven_dataset", help="The folder where the
hdri
folder can be found, to load an world environment")parser.add_argument('--num_runs', default=10, help="Number of runs") parser.add_argument('--frames_per_run', default=15, help="Number of frames for each run") parser.add_argument('--out_size', default=(256, 512), help="Output width and output height") parser.add_argument('--cam_dist_min', default=0.25, help="Minimum radius of camera sampler shell") parser.add_argument('--cam_dist_max', default=0.8, help="Maximum radius of camera sampler shell") parser.add_argument('--distractor_objs_min', default=2, help="Minimum number of occluding/distractor objects to add to the scene") parser.add_argument('--distractor_objs_max', default=15, help="Maximum number of occluding/distractor objects to add to the scene") args = parser.parse_args()
bproc.init()
output_dir = "/".join(args.output_dir.split("/")[:-1]) if args.output_dir[-1].isdigit() else args.output_dir
Set to True for faster outputs during debbuging
DEBUG = True
if DEBUG: bproc.renderer.set_max_amount_of_samples(10)
else: distractor_objs_max = args.distractor_objs_max distractor_objs_min = args.distractor_objs_min bproc.renderer.set_light_bounces(
diffuse_bounces = 200, glossy_bounces = 200, max_bounces = 200, transmission_bounces = 200, transparent_max_bounces = 200 ) bproc.renderer.set_max_amount_of_samples(256) # TODO: Should we leave this as default on 1024 ?? takes longer
load the blender object(s) into the scene
load_blend_objs = bproc.loader.load_blend(args.scene)
scale = 0.15
set segmap_class (category_id) and physics properties
for obj in load_blend_objs: obj.set_cp("category_id", 1)
Load subset of cctextures each rerun:
cc_textures = random.sample(bproc.loader.load_ccmaterials(args.cc_textures_path), 50)
light_point = bproc.types.Light() light_point.set_energy(200)
Iteratively generate a new scene with random camera/light/object placements:
for r in range(args.num_runs):