def test_is_child_fully_visible(): depthmap_dir = str(TOOLKIT_DIR / 'huawei_p40pro') depthmap_fname = 'depth_dog_1622182020448_100_282.depth' calibration_file = str(TOOLKIT_DIR / 'huawei_p40pro' / 'camera_calibration.txt') dmap = Depthmap.create_from_zip(depthmap_dir, depthmap_fname, 0, calibration_file) # Run standard normal visibility check floor = dmap.get_floor_level() mask = dmap.segment_child(floor) assert dmap.is_child_fully_visible(mask) # Run visibility check when child is covering most of the camera margin = 5 x1 = margin x2 = dmap.width - margin y1 = margin y2 = dmap.height - margin mask[x1:x2, y1:y2] = MASK_CHILD assert not dmap.is_child_fully_visible(mask)
def show(depthmap_dir: str, calibration_file: str, original_orientation=False): global DMAP fig.canvas.manager.set_window_title(depth_filenames[IDX_CUR_DMAP]) rgb_filename = rgb_filenames[IDX_CUR_DMAP] if rgb_filenames else 0 DMAP = Depthmap.create_from_zip(depthmap_dir, depth_filenames[IDX_CUR_DMAP], rgb_filename, calibration_file) angle = DMAP.get_angle_between_camera_and_floor() logging.info('angle between camera and floor is %f', angle) output = render_plot(DMAP) if original_orientation: output = ndimage.rotate(output, 90) plt.imshow(output) plot_names = [ 'depth', 'normals', 'child/background segmentation', 'confidence' ] if DMAP.has_rgb: plot_names.append('rgb') plot_title = '\n'.join( [f'{i}: {plot_name}' for i, plot_name in enumerate(plot_names)]) plt.title(plot_title) plt.show()