diff --git a/Dockerfile b/Dockerfile index 9b6184c748ab5d727b1a5402085c098c28a7d3cc..a8ef376f02be2b8fbfd8cdf4e33e49751118b174 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # create docker container with image: docker run --name=mzy22_monodepth -e COLUMNS=300 --mount type=bind,source="$(pwd)",target=/monodepth_dev -it --gpus all mzy22/monodepth:v1.0 # ubuntu 20.04/cuda -FROM nvidia/cuda:11.4.2-devel-ubuntu20.04 +FROM nvidia/cuda:11.4.3-devel-ubuntu20.04 # FROM alpine:3.4 #-- setup building environment @@ -39,9 +39,11 @@ COPY . ./ RUN git submodule update --init RUN cd ./BoostingMonocularDepth/pix2pix/ && mkdir -p checkpoints/mergemodel # Midas weights -RUN wget https://github.com/isl-org/MiDaS/releases/download/v2_1/model-f6b98070.pt -O ./BoostingMonocularDepth/midas/model.pt +#RUN wget https://github.com/isl-org/MiDaS/releases/download/v2_1/model-f6b98070.pt -O ./BoostingMonocularDepth/midas/model.pt # Merge net weights -RUN wget -P ./BoostingMonocularDepth/pix2pix/checkpoints/mergemodel https://www.sfu.ca/~yagiz/CVPR21/latest_net_G.pth +#RUN wget -P ./BoostingMonocularDepth/pix2pix/checkpoints/mergemodel https://www.sfu.ca/~yagiz/CVPR21/latest_net_G.pth + +RUN cp ./weights/midas/model.pt ./BoostingMonocularDepth/midas/model.pt && cp ./weights/pix2pix/checkpoints/mergemodel/latest_net_G.pth ./BoostingMonocularDepth/pix2pix/checkpoints/mergemodel/latest_net_G.pth RUN pip3 install -r ./code/python/requirements.txt diff --git a/code/cpp/python/reinstall.sh b/code/cpp/python/reinstall.sh old mode 100755 new mode 100644 diff --git a/code/python/requirements.txt b/code/python/requirements.txt index 7de70ff31c42f902f144ceb782da93e2c8a09245..ab06c9e23ad07be18bb03a507f75651d40a3bba4 100644 --- a/code/python/requirements.txt +++ b/code/python/requirements.txt @@ -1,5 +1,6 @@ colorama>=0.4.4 matplotlib>=3.4.1 +numpy>=1.19.5 scikit-image>=0.18.1 scipy>=1.6.2 opencv-python>=4.5.1.48 diff --git a/code/python/src/utility/blending.py b/code/python/src/utility/blending.py index fcbd2085fe50566381b1f20546725b6bb124e785..9e18e938182356b7746fa5cc0f10beb23100ee05 100644 --- a/code/python/src/utility/blending.py +++ b/code/python/src/utility/blending.py @@ -260,9 +260,9 @@ class BlendIt: [tangent_sq_yv, tangent_sq_xv], order=1, mode='constant', cval=0.) - erp_radial_weights[erp_sq_yv.astype(np.int), erp_sq_xv.astype(np.int), triangle_index] = erp_face_radial_weights + erp_radial_weights[erp_sq_yv.astype(int), erp_sq_xv.astype(int), triangle_index] = erp_face_radial_weights - erp_frustum_weights[erp_sq_yv.astype(np.int), erp_sq_xv.astype(np.int), + erp_frustum_weights[erp_sq_yv.astype(int), erp_sq_xv.astype(int), triangle_index] = erp_face_frustum_weights self.frustum_blendweights = erp_frustum_weights @@ -294,11 +294,11 @@ class BlendIt: erp_face_image = ndimage.map_coordinates(tangent_images[triangle_index], [tangent_sq_yv, tangent_sq_xv], order=1, mode='constant', cval=0.) - nn_blending[erp_tri_yv.astype(np.int), erp_tri_xv.astype(np.int)] = \ + nn_blending[erp_tri_yv.astype(int), erp_tri_xv.astype(int)] = \ ndimage.map_coordinates(tangent_images[triangle_index], [tangent_tri_yv, tangent_tri_xv], order=1, mode='constant', cval=0.) - erp_depth_tensor[erp_sq_yv.astype(np.int), erp_sq_xv.astype(np.int), + erp_depth_tensor[erp_sq_yv.astype(int), erp_sq_xv.astype(int), triangle_index] = erp_face_image.astype(np.float64) return erp_depth_tensor, nn_blending @@ -322,7 +322,7 @@ class BlendIt: def get_frustum_blendweights(self, size): height, width = size - weight_matrix = np.zeros((height, width), dtype=np.float) + weight_matrix = np.zeros((height, width), dtype=float) x_list = np.linspace(0, width, width, endpoint=False) y_list = np.linspace(0, height, height, endpoint=False) @@ -343,8 +343,8 @@ class BlendIt: peak_bottom_right = np.array([np.max(peak_coors[0]), np.max(peak_coors[1])]) unit_dir = np.array([1/np.sqrt(2), 1/np.sqrt(2)]) - top_left = (peak_top_left - 2*self.diagonal_percentage*unit_dir).astype(np.int) - bottom_right = (peak_bottom_right + 2*self.diagonal_percentage*unit_dir).astype(np.int) + top_left = (peak_top_left - 2*self.diagonal_percentage*unit_dir).astype(int) + bottom_right = (peak_bottom_right + 2*self.diagonal_percentage*unit_dir).astype(int) total_dist[top_left[0]:bottom_right[0]+1, top_left[1]:bottom_right[1]+1] = 0 total_dist = (total_dist - np.min(total_dist)) / np.ptp(total_dist) total_dist[top_left[0]:bottom_right[0] + 1, top_left[1]:bottom_right[1] + 1] = 1 diff --git a/code/python/src/utility/cam_models.py b/code/python/src/utility/cam_models.py index 90cfe818acf67f61eb2a608b0522f75280d24e7e..cadf98125c040e195acdbdd44736e2d11827b5d1 100644 --- a/code/python/src/utility/cam_models.py +++ b/code/python/src/utility/cam_models.py @@ -316,11 +316,11 @@ def stitch_rgb_image(image_data_list, image_param_list, fisheye_model, subimage_ fisheye_3d_points = cam2world(fisheye_2d_points, fisheye_model) # point3d2obj(fisheye_3d_points, "D:/1.obj") - fisheye_image = np.zeros((fisheye_image_height, fisheye_image_width, channel_number), np.float) - fisheye_image_weight = np.zeros((fisheye_image_height, fisheye_image_width), np.float) + fisheye_image = np.zeros((fisheye_image_height, fisheye_image_width, channel_number), float) + fisheye_image_weight = np.zeros((fisheye_image_height, fisheye_image_width), float) for index in range(0, len(image_data_list)): - fisheye_image_weight_subimg = np.zeros((fisheye_image_height, fisheye_image_width), np.float) - fisheye_image_subimage = np.zeros((fisheye_image_height, fisheye_image_width, channel_number), np.float) + fisheye_image_weight_subimg = np.zeros((fisheye_image_height, fisheye_image_width), float) + fisheye_image_subimage = np.zeros((fisheye_image_height, fisheye_image_width, channel_number), float) image_param = image_param_list[index] image_data = image_data_list[index] @@ -342,7 +342,7 @@ def stitch_rgb_image(image_data_list, image_param_list, fisheye_model, subimage_ available_pixels_list_fov = np.logical_and(points_azimuth_inhfov, points_altitude_invfov) available_pixels_list_fov_mat = available_pixels_list_fov.reshape(fisheye_image_height, fisheye_image_width) - fisheye_2d_points_subimage = fisheye_2d_points[available_pixels_list_fov].astype(np.int) + fisheye_2d_points_subimage = fisheye_2d_points[available_pixels_list_fov].astype(int) # projection to pin-hole image pinhole_3d_points = (np.divide(pinhole_3d_points, pinhole_3d_points[2, :])) @@ -362,7 +362,7 @@ def stitch_rgb_image(image_data_list, image_param_list, fisheye_model, subimage_ order=1, mode='constant', cval=255.0) # compute blend weight - available_pixels_weight = np.ones(available_pixels_list.shape, np.float) + available_pixels_weight = np.ones(available_pixels_list.shape, float) available_pixels_weight[~available_pixels_list] = 0 fisheye_image_weight_subimg[available_pixels_list_fov_mat] = available_pixels_weight @@ -429,7 +429,7 @@ def sample_rgb_image(img, model, fov=[60, 60], canvas_size=[400, 400], sample_gr # NOTE world2cam use fast_poly, world2cam_slow use poly # fetch_from = world2cam(world_cs.T, model) fetch_from = world2cam_slow(world_cs, model).T - tangential_img = np.zeros(tuple(canvas_size) + (channel_number,), dtype=np.float) + tangential_img = np.zeros(tuple(canvas_size) + (channel_number,), dtype=float) for channel in range(0, channel_number): tangential_img[:, :, channel] = ndimage.map_coordinates(img[:, :, channel], [fetch_from[:, 1].reshape(canvas_size), fetch_from[:, 0].reshape(canvas_size)], order=1, mode='constant') @@ -501,12 +501,12 @@ def sample_img(img, cam_model, fov=53, run_midas=False): equirect_size = (3, 1000, 2000) # Size for equirectangular image equirect_3D_points, _ = equirect_cam2world(equirect_size[1:]) - equirect_3D_points_rgb = np.zeros((7, equirect_3D_points.shape[-1]), dtype=np.float) + equirect_3D_points_rgb = np.zeros((7, equirect_3D_points.shape[-1]), dtype=float) equirect_3D_points_rgb[0, :] = equirect_3D_points[0, :] equirect_3D_points_rgb[1, :] = equirect_3D_points[1, :] equirect_3D_points_rgb[2, :] = equirect_3D_points[2, :] - fisheye2equirec = np.zeros((3, equirect_3D_points.shape[-1]), dtype=np.float) + fisheye2equirec = np.zeros((3, equirect_3D_points.shape[-1]), dtype=float) # Lines 200-205 is for converting the whole fisheye to equirectangular # Points at the back of the cylinder are mapped to nan nan_boolean = np.bitwise_not(np.isnan(np.sum(equirect_3D_points.T, axis=1))) @@ -538,7 +538,7 @@ def sample_img(img, cam_model, fov=53, run_midas=False): world_cs = np.linalg.inv(pinhole_camera['rotation']) @ pinhole_cs # Fetch RGB from fisheye image to assemble perspective subview - fetch_from = world2cam(world_cs.T, cam_model).astype(np.int) + fetch_from = world2cam(world_cs.T, cam_model).astype(int) fetch_from[:, 0] = np.clip(fetch_from[:, 0], 0, width-1) fetch_from[:, 1] = np.clip(fetch_from[:, 1], 0, height-1) virtual2fisheye_idxs = np.dstack((fetch_from[:, 0].reshape(canvas_size), fetch_from[:, 1].reshape(canvas_size))) @@ -770,7 +770,7 @@ def generate_camera_orientation(hfov_fisheye, vfov_fisheye, hfov_pinhole, vfov_p overlap_area_v = v_index[0] + vfov_pinhole / 2.0 - (v_index[1] - vfov_pinhole / 2.0) log.debug("the vertical overlap angle is {}".format(overlap_area_v)) - z_rotation = np.zeros(x_rotation.shape, np.float) + z_rotation = np.zeros(x_rotation.shape, float) xyz_rotation_array = np.stack((x_rotation, y_rotation, z_rotation), axis=0) xyz_rotation_array = xyz_rotation_array.reshape([3, horizontal_size * vertical_size]) return xyz_rotation_array diff --git a/code/python/src/utility/depth_stitch.py b/code/python/src/utility/depth_stitch.py index a8b334d1ea31f159bba3d4db67b34946cc186e79..5bb75eb5330b2fca9a2dd4a8fe5e592998e7b4f4 100644 --- a/code/python/src/utility/depth_stitch.py +++ b/code/python/src/utility/depth_stitch.py @@ -57,8 +57,8 @@ def stitch_depth_subimage(depth_data_list, image_param_list, fisheye_model): fisheye_image_height = fisheye_model["intrinsics"]["image_size"][0] fisheye_image_width = fisheye_model["intrinsics"]["image_size"][1] - fisheye_depth = np.zeros((fisheye_image_height, fisheye_image_width), np.float) - fisheye_image_weight = np.zeros((fisheye_image_height, fisheye_image_width), np.float) + fisheye_depth = np.zeros((fisheye_image_height, fisheye_image_width), float) + fisheye_image_weight = np.zeros((fisheye_image_height, fisheye_image_width), float) # project the pinhole image to 3D x_list = np.linspace(0, fisheye_image_width, fisheye_image_width, endpoint=False) @@ -131,7 +131,7 @@ def find_corresponding(src_image, src_param, tar_image, tar_param, fisheye_model src_image_u_list = np.linspace(0, src_image_width, src_image_width, endpoint=False) # x src_image_v_list = np.linspace(0, src_image_height, src_image_height, endpoint=False) # y src_image_grid_u, src_image_grid_v = np.meshgrid(src_image_u_list, src_image_v_list) - src_image_grid_z = np.ones(src_image_grid_u.shape, np.float) + src_image_grid_z = np.ones(src_image_grid_u.shape, float) src_image_2d_points = np.stack((src_image_grid_u.ravel(), src_image_grid_v.ravel(), src_image_grid_z.ravel()), axis=1) # project the pinhole image to world coords (spherical 3D points) @@ -165,8 +165,8 @@ def find_corresponding(src_image, src_param, tar_image, tar_param, fisheye_model if src_image_2d_points_available.shape[0] == 0: log.debug("the do not have overlap between two images.") else: - src_image_avail_pixel_data = src_image[src_image_2d_points_available.astype(np.int)] - tar_image_avail_pixel_data = tar_image[tar_image_2d_points_available.astype(np.int)] + src_image_avail_pixel_data = src_image[src_image_2d_points_available.astype(int)] + tar_image_avail_pixel_data = tar_image[tar_image_2d_points_available.astype(int)] rms = np.sqrt(np.mean((src_image_avail_pixel_data - tar_image_avail_pixel_data) ** 2)) log.debug("The corresponding pixel rms is {}".format(rms)) diff --git a/code/python/src/utility/depthmap_utils.py b/code/python/src/utility/depthmap_utils.py index 1ec02d7c9113e9a3e4cf5eafec0382bc75682670..077ee304e2aaaf6bde1f9d518ddf4d56d7063c60 100644 --- a/code/python/src/utility/depthmap_utils.py +++ b/code/python/src/utility/depthmap_utils.py @@ -114,7 +114,6 @@ def depth_visual_save(depth_data, output_path, overwrite=True): im = ax.imshow(depth_data_temp, cmap="turbo") cbar = ax.figure.colorbar(im, ax=ax) plt.savefig(output_path, dpi=150) - # plt.imsave(output_path, dapthe_data_temp, cmap="turbo") plt.close(fig) @@ -757,7 +756,7 @@ def dispmap_normalize(dispmap, method = "", mask = None): :rtype: numpy """ if mask is None: - mask = np.ones_like(dispmap, dtype= np.bool) + mask = np.ones_like(dispmap, dtype=bool) dispmap_norm = None if method == "naive": @@ -832,4 +831,4 @@ def depthmap_pyramid(depthmap_list, pyramid_layer_number, pyramid_downscale): for layer_index in range(0, pyramid_layer_number): depthmap_pryamid[pyramid_layer_number - layer_index - 1][index] = pyramid[layer_index].astype(np.float64) - return depthmap_pryamid \ No newline at end of file + return depthmap_pryamid diff --git a/code/python/src/utility/gnomonic_projection.py b/code/python/src/utility/gnomonic_projection.py index 80524126f49b6c83fde489caa783335a8fcd0438..c4d07063fdc4d0e5a7a0ce6ccab53aba10b65d4b 100644 --- a/code/python/src/utility/gnomonic_projection.py +++ b/code/python/src/utility/gnomonic_projection.py @@ -96,7 +96,7 @@ def gnomonic_projection(theta, phi, theta_0, phi_0): # get cos_c's zero element index zeros_index = cos_c == 0 if np.any(zeros_index): - cos_c[zeros_index] = np.finfo(np.float).eps + cos_c[zeros_index] = np.finfo(float).eps x = np.cos(phi) * np.sin(theta - theta_0) / cos_c y = (np.cos(phi_0) * np.sin(phi) - np.sin(phi_0) * np.cos(phi) * np.cos(theta - theta_0)) / cos_c @@ -128,7 +128,7 @@ def reverse_gnomonic_projection(x, y, lambda_0, phi_1): # get rho's zero element index zeros_index = rho == 0 if np.any(zeros_index): - rho[zeros_index] = np.finfo(np.float).eps + rho[zeros_index] = np.finfo(float).eps c = np.arctan2(rho, 1) phi_ = np.arcsin(np.cos(c) * np.sin(phi_1) + (y * np.sin(c) * np.cos(phi_1)) / rho) @@ -187,11 +187,11 @@ def gnomonic2pixel(coord_gnom_x, coord_gnom_y, # TODO check add the padding whether necessary gnomonic2image_width_ratio = (tangent_image_width - 1.0) / (x_max - x_min + padding_size * 2.0) coord_pixel_x = (coord_gnom_x - x_min + padding_size) * gnomonic2image_width_ratio - coord_pixel_x = (coord_pixel_x + 0.5).astype(np.int) + coord_pixel_x = (coord_pixel_x + 0.5).astype(int) gnomonic2image_height_ratio = (tangent_image_height - 1.0) / (y_max - y_min + padding_size * 2.0) coord_pixel_y = -(coord_gnom_y - y_max - padding_size) * gnomonic2image_height_ratio - coord_pixel_y = (coord_pixel_y + 0.5).astype(np.int) + coord_pixel_y = (coord_pixel_y + 0.5).astype(int) return coord_pixel_x, coord_pixel_y diff --git a/code/python/src/utility/image_io.py b/code/python/src/utility/image_io.py index f1ba6655399ee3e8e627da07bd256b69c2b78e7d..c77903663c60d591ad037e78c6c8c9fbd86446b2 100644 --- a/code/python/src/utility/image_io.py +++ b/code/python/src/utility/image_io.py @@ -112,7 +112,7 @@ def image_save(image_data, image_file_path): """ # 0) convert the datatype image = None - if image_data.dtype in [np.float, np.int64, np.int]: + if image_data.dtype in [float, np.int64, int]: print("saved image array type is {}, converting to uint8".format(image_data.dtype)) image = image_data.astype(np.uint8) else: diff --git a/code/python/src/utility/pointcloud_utils.py b/code/python/src/utility/pointcloud_utils.py index d973230056d4f724280859f515571be43f0d17f4..7e6304c54d3d0c20ee322e77bff54d6b83622f72 100644 --- a/code/python/src/utility/pointcloud_utils.py +++ b/code/python/src/utility/pointcloud_utils.py @@ -107,7 +107,7 @@ def depthmap2pointclouds_perspective(depth_map, rgb_image, cam_int_param, output x_list = np.linspace(0, image_width, image_width, endpoint=False) y_list = np.linspace(0, image_height, image_height, endpoint=False) grid_x, grid_y = np.meshgrid(x_list, y_list) - gird_z = np.ones(grid_x.shape, np.float) + gird_z = np.ones(grid_x.shape, float) points_2d_pixel = np.stack((grid_x.ravel(), grid_y.ravel(), gird_z.ravel()), axis=1) points_2d_pixel = np.multiply(points_2d_pixel.T, depth_map.ravel()) points_3d_pixel = np.linalg.inv(cam_int_param) @ points_2d_pixel diff --git a/code/python/src/utility/polygon.py b/code/python/src/utility/polygon.py index 0c57e2204c13d2ebbcb244d05b4e56a5a5ee9397..174e7ea3bd34b5edac8a7a43b4dfc41fea398b91 100644 --- a/code/python/src/utility/polygon.py +++ b/code/python/src/utility/polygon.py @@ -85,7 +85,7 @@ def enlarge_polygon(old_points, offset): # 1) Move the points by the offset. # the points of line parallel to ij - v1 = np.array([old_points[j][0] - old_points[i][0], old_points[j][1] - old_points[i][1]], np.float) + v1 = np.array([old_points[j][0] - old_points[i][0], old_points[j][1] - old_points[i][1]], float) norm = np.linalg.norm(v1) v1 = v1 / norm * offset n1 = [-v1[1], v1[0]] @@ -93,7 +93,7 @@ def enlarge_polygon(old_points, offset): pij2 = [old_points[j][0] + n1[0], old_points[j][1] + n1[1]] # the points of line parallel to jk - v2 = np.array([old_points[k][0] - old_points[j][0], old_points[k][1] - old_points[j][1]], np.float) + v2 = np.array([old_points[k][0] - old_points[j][0], old_points[k][1] - old_points[j][1]], float) norm = np.linalg.norm(v2) v2 = v2 / norm * offset n2 = [-v2[1], v2[0]] diff --git a/code/python/src/utility/projection_icosahedron.py b/code/python/src/utility/projection_icosahedron.py index 3ce4d7d57eefda6fcd7cdef0e28c7d9d51dd8f4c..2e29c32bd2f8919dcef95fb536bbc474870a4142 100644 --- a/code/python/src/utility/projection_icosahedron.py +++ b/code/python/src/utility/projection_icosahedron.py @@ -280,7 +280,7 @@ def erp2ico_image(erp_image, tangent_image_width, padding_size=0.0, full_face_im gnom_range_xv, gnom_range_yv = np.meshgrid(gnom_range_x, gnom_range_y) # the tangent triangle points coordinate in tangent image - inside_list = np.full(gnom_range_xv.shape[:2], True, dtype=np.bool) + inside_list = np.full(gnom_range_xv.shape[:2], True, dtype=bool) if not full_face_image: gnom_range_xyv = np.stack((gnom_range_xv.flatten(), gnom_range_yv.flatten()), axis=1) pixel_eps = (gnomonic_x_max - gnomonic_x_min) / (tangent_image_width) @@ -433,7 +433,7 @@ def ico2erp_image(tangent_images, erp_image_height, padding_size=0.0, blender_me 0.0, tangent_image_width, tangent_image_height, tangent_gnomonic_range) for channel in range(0, images_channels_number): - erp_image[triangle_yv[available_pixels_list].astype(np.int), triangle_xv[available_pixels_list].astype(np.int), channel] = \ + erp_image[triangle_yv[available_pixels_list].astype(int), triangle_xv[available_pixels_list].astype(int), channel] = \ ndimage.map_coordinates(tangent_images_subimage[:, :, channel], [tangent_yv, tangent_xv], order=1, mode='constant', cval=255) elif blender_method == "mean": triangle_points_tangent = [[gnomonic_x_min, gnomonic_y_max], @@ -447,7 +447,7 @@ def ico2erp_image(tangent_images, erp_image_height, padding_size=0.0, blender_me 0.0, tangent_image_width, tangent_image_height, tangent_gnomonic_range) for channel in range(0, images_channels_number): erp_face_image = ndimage.map_coordinates(tangent_images_subimage[:, :, channel], [tangent_yv, tangent_xv], order=1, mode='constant', cval=255) - erp_image[triangle_yv[available_pixels_list].astype(np.int), triangle_xv[available_pixels_list].astype(np.int), channel] += erp_face_image.astype(np.float64) + erp_image[triangle_yv[available_pixels_list].astype(int), triangle_xv[available_pixels_list].astype(int), channel] += erp_face_image.astype(np.float64) face_weight_mat = np.ones(erp_face_image.shape, np.float64) erp_weight_mat[triangle_yv[available_pixels_list].astype(np.int64), triangle_xv[available_pixels_list].astype(np.int64)] += face_weight_mat diff --git a/code/python/src/utility/serialization.py b/code/python/src/utility/serialization.py index ff888620ca865608b5fe21820be7f54ccf4222ec..635936d5bb930112e35554f4b8577abeea7c638c 100644 --- a/code/python/src/utility/serialization.py +++ b/code/python/src/utility/serialization.py @@ -2,7 +2,7 @@ from PIL import Image import numpy as np import matplotlib.pyplot as plt - +from matplotlib.colors import ListedColormap import metrics import json import os @@ -12,6 +12,10 @@ from logger import Logger log = Logger(__name__) log.logger.propagate = False +ideal_range_diff = 317/880 +lower_bound = 0.3198863636 +custom_cmap = ListedColormap(plt.get_cmap("binary")(np.linspace(lower_bound, lower_bound + ideal_range_diff, 256))) + class NumpyArrayEncoder(json.JSONEncoder): """Assistant class for serialize the numpy to json. @@ -324,18 +328,19 @@ def load_dispmapalign_intermediate_data(filepath, file_format): def save_metrics(output_file, pred_metrics, times, times_header, idx, blending_methods): - if idx == 0: - with open(output_file, "w") as f: - f.write(','.join(list(pred_metrics[0].keys()) + times_header)) - f.write("\n") + if pred_metrics is not None: + if idx == 0: + with open(output_file, "w") as f: + f.write(','.join(list(pred_metrics[0].keys()) + times_header)) + f.write("\n") + f.close() + + with open(output_file, "a") as f: + for idx, key in enumerate(blending_methods): + f.write(','.join(list(np.array(list(pred_metrics[idx].values())).astype(str)) + [str(t) for t in times])) + f.write("\n") f.close() - with open(output_file, "a") as f: - for idx, key in enumerate(blending_methods): - f.write(','.join(list(np.array(list(pred_metrics[idx].values())).astype(str)) + [str(t) for t in times])) - f.write("\n") - f.close() - def save_predictions(output_folder, erp_gt_depthmap, erp_rgb_image_data, estimated_depthmap, persp_monodepth, idx=0): # Plot error maps @@ -353,10 +358,11 @@ def save_predictions(output_folder, erp_gt_depthmap, erp_rgb_image_data, estimat pred = estimated_depthmap[key] plt.imsave(os.path.join(output_folder, "{:03}_360monodepth_{}_{}.png".format(idx, persp_monodepth, key)), - pred, cmap="turbo", vmin=vmin, vmax=vmax) + pred, cmap=custom_cmap, vmin=vmin, vmax=vmax) - plt.imsave(os.path.join(output_folder, "{:03}_GT.png".format(idx)), - erp_gt_depthmap, vmin=vmin, vmax=vmax, cmap="turbo") + if erp_gt_depthmap is not None: + plt.imsave(os.path.join(output_folder, "{:03}_GT.png".format(idx)), erp_gt_depthmap, vmin=vmin, vmax=vmax, cmap=custom_cmap) + plt.imsave(os.path.join(output_folder, "{:03}_rgb.png".format(idx)), erp_rgb_image_data) # metrics.visualize_error_maps(pred, erp_gt_depthmap, mask, idx=idx, diff --git a/code/python/src/utility/spherical_coordinates.py b/code/python/src/utility/spherical_coordinates.py index 32991ead7284d56321002b02ee687ac3840685c8..5d724eb942d145bc20ade5bc7a6848e14c9f6d01 100644 --- a/code/python/src/utility/spherical_coordinates.py +++ b/code/python/src/utility/spherical_coordinates.py @@ -148,10 +148,10 @@ def car2sph(points_car, min_radius=1e-10): valid_list = radius > min_radius # set the 0 radius to origin. - theta = np.zeros((points_car.shape[0]), np.float) + theta = np.zeros((points_car.shape[0]), float) theta[valid_list] = np.arctan2(points_car[:, 0][valid_list], points_car[:, 2][valid_list]) - phi = np.zeros((points_car.shape[0]), np.float) + phi = np.zeros((points_car.shape[0]), float) phi[valid_list] = -np.arcsin(np.divide(points_car[:, 1][valid_list], radius[valid_list])) return np.stack((theta, phi), axis=1) diff --git a/code/python/src/utility/subimage.py b/code/python/src/utility/subimage.py index dc911163deee0cb1dc6773d4143d550d4857eebe..2ecd22125732158bb87e8dade1ef3edce45f897d 100644 --- a/code/python/src/utility/subimage.py +++ b/code/python/src/utility/subimage.py @@ -83,7 +83,7 @@ def draw_corresponding(src_image_data, tar_image_data, pixel_corresponding_array # 2) warp src image src_warp_image = np.zeros(src_image_data.shape, src_image_data.dtype) - pixel_corresponding_array_temp = pixel_corresponding_array.astype(np.int) + pixel_corresponding_array_temp = pixel_corresponding_array.astype(int) src_y = pixel_corresponding_array_temp[:, 0] src_x = pixel_corresponding_array_temp[:, 1] tar_y = pixel_corresponding_array_temp[:, 2] @@ -328,7 +328,7 @@ def erp_ico_proj(erp_image, padding_size, tangent_image_width, corr_downsample_f # down-sample the pixel corresponding relationship if corr_downsample_factor != 1.0 and pixels_corr_dict_subimage[subimage_index_tar] is not None: corr_number = pixels_corr_dict_subimage[subimage_index_tar].shape[0] - corr_index = np.linspace(0, corr_number -1, num = int(corr_number * corr_downsample_factor)).astype(np.int) + corr_index = np.linspace(0, corr_number -1, num = int(corr_number * corr_downsample_factor)).astype(int) corr_index = np.unique(corr_index) pixels_corr_dict_subimage[subimage_index_tar] = pixels_corr_dict_subimage[subimage_index_tar][corr_index,:] @@ -410,7 +410,7 @@ def erp_ico_draw_corresponding(src_image_data, tar_image_data, pixel_correspondi # 1) warp src image src_warp = np.zeros(src_image_data_np.shape, src_image_data_np.dtype) - pixel_corresponding_array_temp = pixel_corresponding_array.astype(np.int) + pixel_corresponding_array_temp = pixel_corresponding_array.astype(int) src_y = pixel_corresponding_array_temp[:, 0] src_x = pixel_corresponding_array_temp[:, 1] tar_y = pixel_corresponding_array_temp[:, 2] diff --git a/data/0001_rgbOld.jpg b/data/0001_rgbOld.jpg new file mode 100644 index 0000000000000000000000000000000000000000..579ab928288686a9e8402f33f7c4406ea9b83540 Binary files /dev/null and b/data/0001_rgbOld.jpg differ diff --git a/data/erp_00/0001_depth.dpt b/data/erp_00/0001_depth.dpt old mode 100755 new mode 100644 diff --git a/data/erp_00/0001_rgb.jpg b/data/erp_00/0001_rgb.jpg old mode 100755 new mode 100644 diff --git a/data/erp_00/hansung.jpg b/data/erp_00/hansung.jpg new file mode 100644 index 0000000000000000000000000000000000000000..167d408542f64b454557a37aaf0fd7e6ed0f8d23 Binary files /dev/null and b/data/erp_00/hansung.jpg differ diff --git a/data/erp_00_data.txt b/data/erp_00_data.txt index a9e7d4167cadea3ee209de8158caa3a8322fdfbf..a757967fe535349bb450fa700dd9d48a1fc91c87 100644 --- a/data/erp_00_data.txt +++ b/data/erp_00_data.txt @@ -1 +1 @@ -../../../data/erp_00/0001_rgb.jpg ../../../data/erp_00/0001_depth.dpt \ No newline at end of file +../../../data/erp_00/hansung.jpg None \ No newline at end of file