Skip to content

Commit

Permalink
fix to graphics.softras/transform.Projection (#127)
Browse files Browse the repository at this point in the history
Signed-off-by: Michele Sanna <sanna@arrival.com>
  • Loading branch information
cosw0t authored and Caenorst committed Jan 21, 2020
1 parent 320f527 commit 4d7dd1a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/renderers/NMR/neural_renderer/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, image_size=256, anti_aliasing=True, background_color=[0,0,0],
self.perspective = perspective
self.viewing_angle = viewing_angle
self.eye = [0, 0, -(1. / math.tan(math.radians(self.viewing_angle)) + 1)]
self.camera_direction = [0, 0, 1]
self.camera_direction = camera_direction
else:
raise ValueError('Camera mode has to be one of projection, look or look_at')

Expand Down
6 changes: 3 additions & 3 deletions examples/renderers/SoftRas/soft_renderer/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def __init__(self, P, dist_coeffs=None, orig_size=512):

if isinstance(self.P, np.ndarray):
self.P = torch.from_numpy(self.P).cuda()
if self.P is None or P.ndimension() != 3 or self.P.shape[1] != 3 or self.P.shape[2] != 4:
if self.P is None or self.P.ndimension() != 3 or self.P.shape[1] != 3 or self.P.shape[2] != 4:
raise ValueError('You need to provide a valid (batch_size)x3x4 projection matrix')
if dist_coeffs is None:
self.dist_coeffs = torch.cuda.FloatTensor([[0., 0., 0., 0., 0.]]).repeat(P.shape[0], 1)
self.dist_coeffs = torch.cuda.FloatTensor([[0., 0., 0., 0., 0.]]).repeat(self.P.shape[0], 1)

def forward(self, vertices):
vertices = srf.projection(vertices, self.P, self.dist_coeffs, self.orig_size)
Expand Down Expand Up @@ -77,7 +77,7 @@ def __init__(self, camera_direction=[0,0,1], perspective=True, viewing_angle=30,
self.viewing_angle = viewing_angle
self.viewing_scale = viewing_scale
self._eye = eye
self.camera_direction = [0, 0, 1]
self.camera_direction = camera_direction

if self._eye is None:
self._eye = [0, 0, -(1. / math.tan(math.radians(self.viewing_angle)) + 1)]
Expand Down
6 changes: 3 additions & 3 deletions kaolin/graphics/softras/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def __init__(self, P, dist_coeffs=None, orig_size=512):

if isinstance(self.P, np.ndarray):
self.P = torch.from_numpy(self.P).cuda()
if self.P is None or P.ndimension() != 3 or self.P.shape[1] != 3 or self.P.shape[2] != 4:
if self.P is None or self.P.ndimension() != 3 or self.P.shape[1] != 3 or self.P.shape[2] != 4:
raise ValueError('You need to provide a valid (batch_size)x3x4 projection matrix')
if dist_coeffs is None:
self.dist_coeffs = torch.cuda.FloatTensor([[0., 0., 0., 0., 0.]]).repeat(P.shape[0], 1)
self.dist_coeffs = torch.cuda.FloatTensor([[0., 0., 0., 0., 0.]]).repeat(self.P.shape[0], 1)

def forward(self, vertices):
vertices = srf.projection(vertices, self.P, self.dist_coeffs, self.orig_size)
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(self, camera_direction=[0,0,1], perspective=True, viewing_angle=30,
self.viewing_angle = viewing_angle
self.viewing_scale = viewing_scale
self._eye = eye
self.camera_direction = [0, 0, 1]
self.camera_direction = camera_direction

if self._eye is None:
self._eye = [0, 0, -(1. / math.tan(math.radians(self.viewing_angle)) + 1)]
Expand Down

0 comments on commit 4d7dd1a

Please sign in to comment.