def ssv_obj_norm(self, ssv_id, obj_type): """ Get mesh normals of a specific obj type for ssv_id. :param ssv_id: int :param obj_type: str :return: dict """ start = time.time() self.logger.info('Loading ssv {} {} mesh normals' ''.format(ssv_id, obj_type)) ssv = self.ssd.get_super_segmentation_object(int(ssv_id)) ssv.load_attr_dict() if obj_type == "sj": try: obj_type = "syn_ssv" _ = ssv.attr_dict[obj_type] # try to query mapped syn_ssv objects log_gate.debug("Loading '{}' objects instead of 'sj' for SSV " "{}.".format(obj_type, ssv_id)) except KeyError: pass # if not existent, create mesh _ = ssv.load_mesh(obj_type) mesh = ssv._load_obj_mesh_compr(obj_type) dtime = time.time() - start self.logger.info('Got ssv {} {} mesh normals after' ' {:.2f}'.format(ssv_id, obj_type, dtime)) if len(mesh) == 2: return "" try: return b"".join(mesh[2]) except TypeError: # contains str, not byte return "".join(mesh[2])
def ssv_obj_mesh(self, ssv_id, obj_type): """ Get mesh of a specific obj type for ssv_id. :param ssv_id: int :param obj_type: str :return: dict """ ssv = self.ssd.get_super_segmentation_object(int(ssv_id)) ssv.load_attr_dict() if obj_type == "sj": try: obj_type = "syn_ssv" _ = ssv.attr_dict[obj_type] # try to query mapped syn_ssv objects log_gate.debug("Loading '{}' objects instead of 'sj' for SSV " "{}.".format(obj_type, ssv_id)) except KeyError: pass # if not existent, create mesh _ = ssv.load_mesh(obj_type) mesh = ssv._load_obj_mesh_compr(obj_type) if mesh is None: return None ret = {'vertices': mesh[1], 'indices': mesh[0], 'normals': mesh[2] if len(mesh) == 2 else []} return ret
def ssv_obj_mesh(ssv_id, obj_type): d = sg_state.backend.ssv_obj_mesh(ssv_id, obj_type) start = time.time() ret = json.dumps(d, cls=MyEncoder) log_gate.debug("JSON dump: {}".format(time.time() - start)) return ret
def route_ssv_skeleton(ssv_id): d = sg_state.backend.ssv_skeleton(ssv_id) start = time.time() ret = json.dumps(d, cls=MyEncoder) log_gate.debug("JSON dump: {}".format(time.time() - start)) return ret