def testDescribe(self): scene = SunCgSceneLoader.loadHouseFromJson( "0004d52d1aeeb8ae6de39d6bd993e992", TEST_SUNCG_DATA_DIR) semantics = SuncgSemantics(scene, TEST_SUNCG_DATA_DIR) objNode = scene.scene.find('**/object-561*') desc = semantics.describeObject(objNode) self.assertTrue(desc == "small linen coffee table made of wood")
def generate_scene_metadata(house_id): """ Generates a JSON file that contains a list of objects, and directional relationships b/w each pair of objects :param house_id: :return: """ env = BasicEnvironment(houseId=house_id, suncgDatasetRoot=TEST_SUNCG_DATA_DIR) scene = env.scene keys = ['shape', 'size', 'color', 'material'] metadata = { 'info': { 'split': 'train' }, 'scenes': [{ "split": "train", "image_index": 0, "image_filename": "SUNCG_env_000000.png", "objects": [], "relationships": {} }] } semantic_world = SuncgSemantics(scene, TEST_SUNCG_DATA_DIR) for idx, obj in enumerate(scene.getAllObjects()): props = get_object_properties(obj, semantic_world) metadata['scenes'][0]['objects'].append( {k: v for k, v in props.iteritems() if k in keys}) metadata['scenes'][0]['relationships'] = compute_all_relationships( env.scene) return metadata
def generate_metadata_from_instances(scene, instances_found): """ Generates a JSON file that contains a list of objects, and directional relationships b/w each pair of objects :param house_id: :return: """ keys = ['shape', 'size', 'color', 'material'] metadata = { 'info': { 'split': 'train' }, 'scenes': [{ "split": "train", "image_index": 0, "image_filename": "SUNCG_env_000000.png", "objects": [], "relationships": {} }] } semantic_world = SuncgSemantics(scene, TEST_SUNCG_DATA_DIR) objects_seen = [] for idx, obj in enumerate(scene.getAllObjects()): instance_id = obj.getTag('instance-id') model_id = obj.getTag('instance-id') # Ignore cellings, floors and walls if instance_id in instances_found: props = get_object_properties(obj) if not props: continue objects_seen.append(obj) metadata['scenes'][0]['objects'].append( {k: v for k, v in props.iteritems() if k in keys}) metadata['scenes'][0]['relationships'] = compute_all_relationships( objects_seen) return metadata