brjathu shubham-goel commited on
Commit
83d5202
1 Parent(s): ad3be6b

Update hmr2/utils/renderer.py (#4)

Browse files

- Update hmr2/utils/renderer.py (c442416eb131e3d224a150965ba0b0c16aea07e8)


Co-authored-by: Shubham Goel <shubham-goel@users.noreply.huggingface.co>

Files changed (1) hide show
  1. hmr2/utils/renderer.py +6 -7
hmr2/utils/renderer.py CHANGED
@@ -145,9 +145,6 @@ class Renderer:
145
  self.cfg = cfg
146
  self.focal_length = cfg.EXTRA.FOCAL_LENGTH
147
  self.img_res = cfg.MODEL.IMAGE_SIZE
148
- # self.renderer = pyrender.OffscreenRenderer(viewport_width=self.img_res,
149
- # viewport_height=self.img_res,
150
- # point_size=1.0)
151
 
152
  self.camera_center = [self.img_res // 2, self.img_res // 2]
153
  self.faces = faces
@@ -208,7 +205,7 @@ class Renderer:
208
  camera_pose[:3, 3] = camera_translation
209
  camera_center = [image.shape[1] / 2., image.shape[0] / 2.]
210
  camera = pyrender.IntrinsicsCamera(fx=self.focal_length, fy=self.focal_length,
211
- cx=camera_center[0], cy=camera_center[1])
212
  scene.add(camera, pose=camera_pose)
213
 
214
 
@@ -292,7 +289,7 @@ class Renderer:
292
  # camera_pose[:3, 3] = camera_translation
293
  camera_center = [render_res[0] / 2., render_res[1] / 2.]
294
  camera = pyrender.IntrinsicsCamera(fx=self.focal_length, fy=self.focal_length,
295
- cx=camera_center[0], cy=camera_center[1])
296
 
297
  # Create camera node and add it to pyRender scene
298
  camera_node = pyrender.Node(camera=camera, matrix=camera_pose)
@@ -319,6 +316,7 @@ class Renderer:
319
  mesh_base_color=(1.0, 1.0, 0.9),
320
  scene_bg_color=(0,0,0),
321
  render_res=[256, 256],
 
322
  ):
323
 
324
  renderer = pyrender.OffscreenRenderer(viewport_width=render_res[0],
@@ -339,8 +337,9 @@ class Renderer:
339
  camera_pose = np.eye(4)
340
  # camera_pose[:3, 3] = camera_translation
341
  camera_center = [render_res[0] / 2., render_res[1] / 2.]
342
- camera = pyrender.IntrinsicsCamera(fx=self.focal_length, fy=self.focal_length,
343
- cx=camera_center[0], cy=camera_center[1])
 
344
 
345
  # Create camera node and add it to pyRender scene
346
  camera_node = pyrender.Node(camera=camera, matrix=camera_pose)
 
145
  self.cfg = cfg
146
  self.focal_length = cfg.EXTRA.FOCAL_LENGTH
147
  self.img_res = cfg.MODEL.IMAGE_SIZE
 
 
 
148
 
149
  self.camera_center = [self.img_res // 2, self.img_res // 2]
150
  self.faces = faces
 
205
  camera_pose[:3, 3] = camera_translation
206
  camera_center = [image.shape[1] / 2., image.shape[0] / 2.]
207
  camera = pyrender.IntrinsicsCamera(fx=self.focal_length, fy=self.focal_length,
208
+ cx=camera_center[0], cy=camera_center[1], zfar=1e12)
209
  scene.add(camera, pose=camera_pose)
210
 
211
 
 
289
  # camera_pose[:3, 3] = camera_translation
290
  camera_center = [render_res[0] / 2., render_res[1] / 2.]
291
  camera = pyrender.IntrinsicsCamera(fx=self.focal_length, fy=self.focal_length,
292
+ cx=camera_center[0], cy=camera_center[1], zfar=1e12)
293
 
294
  # Create camera node and add it to pyRender scene
295
  camera_node = pyrender.Node(camera=camera, matrix=camera_pose)
 
316
  mesh_base_color=(1.0, 1.0, 0.9),
317
  scene_bg_color=(0,0,0),
318
  render_res=[256, 256],
319
+ focal_length=None,
320
  ):
321
 
322
  renderer = pyrender.OffscreenRenderer(viewport_width=render_res[0],
 
337
  camera_pose = np.eye(4)
338
  # camera_pose[:3, 3] = camera_translation
339
  camera_center = [render_res[0] / 2., render_res[1] / 2.]
340
+ focal_length = focal_length if focal_length is not None else self.focal_length
341
+ camera = pyrender.IntrinsicsCamera(fx=focal_length, fy=focal_length,
342
+ cx=camera_center[0], cy=camera_center[1], zfar=1e12)
343
 
344
  # Create camera node and add it to pyRender scene
345
  camera_node = pyrender.Node(camera=camera, matrix=camera_pose)