Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions df3d/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ def smooth_points2d(self, cam_id, private_cache=dict()):
private_cache[cam_id] = smooth_pose2d(cam.points2d)
return private_cache[cam_id]

def plot_2d(self, cam_id, img_id, with_corrections=False, smooth=False, joints=[]):
def plot_2d(self, cam_id, img_id, with_corrections=False,
smooth=False, joints=[], reprojection=False):
"""Plots the 2d pose estimation results.

Parameters:
Expand All @@ -311,11 +312,15 @@ def plot_2d(self, cam_id, img_id, with_corrections=False, smooth=False, joints=[
from pyba.config import df3d_bones, df3d_colors

if with_corrections:
pts2d = self.corrected_points2d(cam_id, img_id)
pts = self.corrected_points2d(cam_id, img_id)
else:
pts2d = None
pts = None

if reprojection:
pts = np.copy(self.camNet.points3d)
Comment on lines 314 to +320
Copy link
Copy Markdown
Member

@jasper-tms jasper-tms Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we raise an error if the user asks for with_corrections=True and reprojection=True? I don't understand exactly what happens in self.corrected_points2d, but I would guess these two arguments are incompatible, is that true? If so, adding if with_corrections and reprojection: raise ValueError('"with_corrections" and "reprojection" cannot both be set to True') near the start of this function would be great.


return self.camNet[cam_id].plot_2d(
img_id, points2d=pts2d, bones=df3d_bones, colors=df3d_colors
img_id, points=pts, bones=df3d_bones, colors=df3d_colors
)

def get_image(self, cam_id, img_id):
Expand Down
6 changes: 3 additions & 3 deletions df3d/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ def _make_video(video_path, imgs, fps=default_fps):

def _resize(current_shape, new_width):
width, height = current_shape
ratio = new_width / width;
ratio = new_width / width
return (int(width * ratio), int(height * ratio))


def _compute_2d_img(plot_2d, img_id, cam_id):
def _compute_2d_img(plot_2d, img_id, cam_id, reprojection=True):
"""Uses plot_2d to generate an image and resizes it using cv2.

Returns:
A numpy array containing the resized image.
"""
img = plot_2d(cam_id, img_id, smooth=True)
img = plot_2d(cam_id, img_id, smooth=True, reprojection=reprojection)
img = cv2.resize(img, (img2d_aspect[0]*img3d_dpi, img2d_aspect[1]*img3d_dpi))
return img

Expand Down
Loading