visionsim.interpolate package¶
Submodules¶
visionsim.interpolate.pose module¶
- class visionsim.interpolate.pose.pose_interp(transforms: npt.ArrayLike, ts: TypeAliasForwardRef('npt.ArrayLike') | None = None, k=3, normalize=False)[source]¶
Bases:
objectLinearly interpolate between 4x4 (or 3x4) transformation matrices by interpolating it’s components
- __init__(transforms: npt.ArrayLike, ts: TypeAliasForwardRef('npt.ArrayLike') | None = None, k=3, normalize=False) None[source]¶
Create a spline from the rotational and translational components of each pose. Specifically, we use scipy’s RotationSpline and BSpline respectively.
- Parameters:
transforms (npt.ArrayLike) – Poses to interpolate as matrices.
ts (npt.ArrayLike | None, optional) – Time of each pose. Defaults to None, meaning linspace between [0, 1].
k (int, optional) – B-spline degree for translation. Default is cubic (i.e: 3).
normalize (bool, optional) – If true, normalize rotations by their determinants. Defaults to False.
- Raises:
RuntimeError – raised when rotations are not normalized.
- __call__(ts: npt.ArrayLike, order: Literal[0, 1, 2] = 0) npt.NDArray[source]¶
Compute interpolated poses, or their derivatives.
- Parameters:
ts (npt.ArrayLike) – Times of interest.
order (Literal[0, 1, 2], optional) –
Order of differentiation:
0 (default): return pose as 4x4 matrices
- 1: return velocities, where the first row is the angular rates
in rad/sec and second row are positional velocities.
- 2: return the accelerations, packaged as angular acceleration
(in rad/sec/sec) then positional.
Defaults to 0.
- Returns:
Interpolated poses (Tx4x4) or their derivatives (2xTx3)
- Return type:
npt.NDArray
Module contents¶
- visionsim.interpolate.interpolate_poses(transforms, normalize: bool = False, n: int = 2, k: int = 3)[source]¶
Interpolate between pose matrices
- Parameters:
transforms – List of pose matrices to interpolate between
normalize (bool) – Whether the interpolation should be normalized or not
n (int) – Number of poses to interpolate between existing poses
k (int) – Order of spline interpolation, see
pose_interp
- Returns:
List of interpolated poses
- visionsim.interpolate.interpolate_frames(input_dir: str | PathLike, output_dir: str | PathLike, interpolation_method: Literal['rife'] = 'rife', n: int = 2)[source]¶
Interpolate between image frames
Note: Currently only RIFE is supported for frame interpolation but we intend to add more
- Parameters:
input_dir (pathlib.Path) – Path to directory containing images to interpolate
output_dir (pathlib.Path) – Path to directory to output interpolated frames
interpolation_method (str) – The image interpolation method used
n (int) – Number of frames to interpolate between existing frames
- visionsim.interpolate.poses_and_frames_to_json(transforms, new_poses, output_dir: str | PathLike, file_name: str = 'transforms.json')[source]¶
Combines interpolated poses (matrices) and frames into a new transforms.json file
- Parameters:
transforms – Original transforms JSON file
new_poses – List of interpolated pose matrices
output_dir (pathlib.Path) – Path to directory containing interpolated frames
file_name – Name of new transforms JSON file