From 0ff2e1d30f18a11a11e6b84f25763ccfd8628937 Mon Sep 17 00:00:00 2001 From: Laurent FAINSIN Date: Thu, 6 Apr 2023 09:27:46 +0200 Subject: [PATCH] fix: remove cursed open3d code --- datasets/shapenet_data_pc.py | 29 ---------------------------- datasets/shapenet_data_sv.py | 37 ------------------------------------ environment.yml | 2 -- 3 files changed, 68 deletions(-) diff --git a/datasets/shapenet_data_pc.py b/datasets/shapenet_data_pc.py index 78f4709..502d614 100644 --- a/datasets/shapenet_data_pc.py +++ b/datasets/shapenet_data_pc.py @@ -4,7 +4,6 @@ import numpy as np from torch.utils.data import Dataset from torch.utils import data import random -import open3d as o3d import numpy as np import torch.nn.functional as F @@ -234,34 +233,6 @@ class ShapeNet15kPointClouds(Uniform15KPC): -class PointCloudMasks(object): - ''' - render a view then save mask - ''' - def __init__(self, radius : float=10, elev: float =45, azim:float=315, ): - - self.radius = radius - self.elev = elev - self.azim = azim - - - def __call__(self, points): - - pcd = o3d.geometry.PointCloud() - pcd.points = o3d.utility.Vector3dVector(points) - - camera = [self.radius * np.sin(90-self.elev) * np.cos(self.azim), - self.radius * np.cos(90 - self.elev), - self.radius * np.sin(90 - self.elev) * np.sin(self.azim), - ] - # camera = [0,self.radius,0] - _, pt_map = pcd.hidden_point_removal(camera, self.radius) - - mask = torch.zeros_like(points) - mask[pt_map] = 1 - - return mask #points[pt_map] - #################################################################################### diff --git a/datasets/shapenet_data_sv.py b/datasets/shapenet_data_sv.py index 54edb92..63d5a4c 100644 --- a/datasets/shapenet_data_sv.py +++ b/datasets/shapenet_data_sv.py @@ -2,7 +2,6 @@ import warnings from torch.utils.data import Dataset from tqdm import tqdm from pathlib import Path -import open3d as o3d import os import numpy as np @@ -219,39 +218,3 @@ class ShapeNet_Multiview_Points(Dataset): return data - - - -class DepthToSingleViewPoints(object): - ''' - render a view then save mask - ''' - def __init__(self, cam_ext, cam_int): - - self.cam_ext = cam_ext.reshape(4,4) - self.cam_int = cam_int.reshape(3,3) - - - def __call__(self, depth_pth, depth_minmax_pth): - - depth_minmax = np.load(depth_minmax_pth) - depth_img = plt.imread(depth_pth)[...,0] - mask = np.where(depth_img == 0, -1.0, 1.0) - depth_img = 1 - depth_img - depth_img = (depth_img * (np.max(depth_minmax) - np.min(depth_minmax)) + np.min(depth_minmax)) * mask - - intr = o3d.camera.PinholeCameraIntrinsic(depth_img.shape[0], depth_img.shape[1], - self.cam_int[0, 0], self.cam_int[1, 1], self.cam_int[0,2], - self.cam_int[1,2]) - - depth_im = o3d.geometry.Image(depth_img.astype(np.float32, copy=False)) - - # rgbd_im = o3d.geometry.RGBDImage.create_from_color_and_depth(color_im, depth_im) - pcd = o3d.geometry.PointCloud.create_from_depth_image(depth_im, intr, self.cam_ext, depth_scale=1.) - pc = np.asarray(pcd.points) - - return pc, depth_img - - def __repr__(self): - return 'MeshToMaskedVoxel_'+str(self.radius)+str(self.resolution)+str(self.elev )+str(self.azim)+str(self.img_size ) - diff --git a/environment.yml b/environment.yml index 92bad73..07aa2ac 100644 --- a/environment.yml +++ b/environment.yml @@ -7,7 +7,6 @@ channels: - nvidia - conda-forge - pyg - - open3d-admin dependencies: - python @@ -15,7 +14,6 @@ dependencies: - torchvision - cudatoolkit - matplotlib - - open3d - tqdm - trimesh - scipy