Skip to content

Commit 74fbb48

Browse files
Implement reprojection in 3d video
1 parent 15595ff commit 74fbb48

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

df3d/core.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ def smooth_points2d(self, cam_id, private_cache=dict()):
295295
private_cache[cam_id] = smooth_pose2d(cam.points2d)
296296
return private_cache[cam_id]
297297

298-
def plot_2d(self, cam_id, img_id, with_corrections=False, smooth=False, joints=[]):
298+
def plot_2d(self, cam_id, img_id, with_corrections=False,
299+
smooth=False, joints=[], reprojection=False):
299300
"""Plots the 2d pose estimation results.
300301
301302
Parameters:
@@ -311,11 +312,15 @@ def plot_2d(self, cam_id, img_id, with_corrections=False, smooth=False, joints=[
311312
from pyba.config import df3d_bones, df3d_colors
312313

313314
if with_corrections:
314-
pts2d = self.corrected_points2d(cam_id, img_id)
315+
pts = self.corrected_points2d(cam_id, img_id)
315316
else:
316-
pts2d = None
317+
pts = None
318+
319+
if reprojection:
320+
pts = np.copy(self.camNet.points3d)
321+
317322
return self.camNet[cam_id].plot_2d(
318-
img_id, points2d=pts2d, bones=df3d_bones, colors=df3d_colors
323+
img_id, points=pts, bones=df3d_bones, colors=df3d_colors
319324
)
320325

321326
def get_image(self, cam_id, img_id):

df3d/video.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ def _make_video(video_path, imgs, fps=default_fps):
110110

111111
def _resize(current_shape, new_width):
112112
width, height = current_shape
113-
ratio = new_width / width;
113+
ratio = new_width / width
114114
return (int(width * ratio), int(height * ratio))
115115

116116

117-
def _compute_2d_img(plot_2d, img_id, cam_id):
117+
def _compute_2d_img(plot_2d, img_id, cam_id, reprojection=True):
118118
"""Uses plot_2d to generate an image and resizes it using cv2.
119119
120120
Returns:
121121
A numpy array containing the resized image.
122122
"""
123-
img = plot_2d(cam_id, img_id, smooth=True)
123+
img = plot_2d(cam_id, img_id, smooth=True, reprojection=reprojection)
124124
img = cv2.resize(img, (img2d_aspect[0]*img3d_dpi, img2d_aspect[1]*img3d_dpi))
125125
return img
126126

0 commit comments

Comments
 (0)