generate normal image

This commit is contained in:
2022-12-28 19:17:25 +00:00
parent 0652130e65
commit e5780de5e5
3 changed files with 36 additions and 10 deletions
+18 -7
View File
@@ -6,6 +6,7 @@ os.environ["CUDA_VISIBLE_DEVICES"] = '0'
import math
import time
import torch
import kornia
import torchvision as tv
import numpy as np
import scipy.io as sio
@@ -17,7 +18,7 @@ from render import Render, DepthRenderer
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
from superSMPL.IO import readPC2Frame, writePC2
from utils.data_utils import Frame, read_frames_file, mask_faces
from utils.data_utils import Frame, read_frames_file, mask_faces, get_normals_from_depth
from cloth3d.read import DataReader
from cloth3d.util import quads2tris
@@ -71,10 +72,16 @@ class Dataset(Dataset):
t = time.perf_counter() - start
print(t)
start = time.perf_counter()
depth_image, v2i = self.render(combined, combined_faces, info['camLoc'])
depth_image, depth_mask, v2i, K = self.render(combined, combined_faces, info['camLoc'])
t = time.perf_counter() - start
print(t)
pc = kornia.geometry.depth.depth_to_3d(depth_image[None,None,:,:], K, normalize_points=True)
pc = pc[0,:,depth_mask].cpu().numpy()
normal_image = get_normals_from_depth(depth_image[None,:,:], depth_mask[None,:,:], K)
depth_image = depth_image.cpu().numpy()
dist_img = depth_image[v2i[idx, 1], v2i[idx, 0]]
depth_image[v2i[idx, 1], v2i[idx, 0]] = 100
@@ -84,12 +91,16 @@ class Dataset(Dataset):
import plotly.express as ex
import plotly.graph_objects as go
ex.imshow(deodr_depth[:,:,0]).show()
ex.imshow(depth_image).show()
# ex.imshow(deodr_depth[:,:,0]).show()
# ex.imshow(depth_image).show()
ex.imshow(normal_image[0].cpu().numpy()).show()
go.Figure(data = [go.Scatter3d(x=combined[:, 0], y=combined[:, 1], z=combined[:, 2], marker=dict(size=3, line=dict(width=0)), mode='markers'),
go.Scatter3d(x=[combined[idx, 0]], y=[combined[idx, 1]], z=[combined[idx, 2]], marker=dict(size=10, line=dict(width=0)), mode='markers'),
]).show()
# go.Figure(data = [go.Scatter3d(x=combined[:, 0], y=combined[:, 1], z=combined[:, 2], marker=dict(size=3, line=dict(width=0)), mode='markers'),
# go.Scatter3d(x=[combined[idx, 0]], y=[combined[idx, 1]], z=[combined[idx, 2]], marker=dict(size=10, line=dict(width=0)), mode='markers'),
# ]).show()
# go.Figure(data = [go.Scatter3d(x=pc[0,:], y=pc[1,:], z=pc[2,:], marker=dict(size=3, line=dict(width=0)), mode='markers'),
# ]).show()
# v2i_coverage = np.zeros((480, 640), dtype=np.float32)
# v2i_coverage[v2i[:,0], v2i[:, 1]] = 1