def render_plot(dmap: Depthmap) -> np.ndarray: # detect floor and child floor: float = dmap.get_floor_level() mask = dmap.segment_child(floor) # dmap.detect_floor(floor) # prepare plots output_plots = [ render_depth(dmap), render_normal(dmap), render_segmentation(floor, mask, dmap), render_confidence(dmap), ] if dmap.has_rgb: highest_point: np.ndarray = dmap.get_highest_point(mask) output_rgb = render_rgb(dmap) output_rgb = blur_face(output_rgb, highest_point, dmap, CHILD_HEAD_HEIGHT_IN_METERS) output_plots.append(output_rgb) return np.concatenate(output_plots, axis=1)
def __init__(self, dmap: Depthmap, rgb_fpath: str): """Create object from depthmap and rgb file path""" self.floor = dmap.get_floor_level() self.rgb = cv2.imread(str(rgb_fpath)) dim = (640, int(self.rgb.shape[0] / self.rgb.shape[1] * 640.0)) self.rgb = cv2.resize(self.rgb, dim, cv2.INTER_AREA) dmap.resize(self.rgb.shape[1], self.rgb.shape[0]) self.dmap = dmap self.rgb_fpath = rgb_fpath cache_fpath = f'{rgb_fpath}-hrnet.json' try: with open(cache_fpath) as json_file: self.persons_coordinates = json.load(json_file) except OSError: self.persons_coordinates = HRNET_MODEL.result_on_artifact_level_from_image( self.rgb, rgb_fpath, '0') with open(cache_fpath, 'w') as json_file: json.dump(self.persons_coordinates, json_file, cls=NumpyEncoder)