data_juicer.ops.mapper.video_undistort_mapper module#

data_juicer.ops.mapper.video_undistort_mapper.get_global_intrinsics(ks)[source]#
class data_juicer.ops.mapper.video_undistort_mapper.VideoUndistortMapper(*args, **kwargs)[source]#

Bases: Mapper

Undistort raw videos with corresponding camera intrinsics and distortion coefficients.

__init__(output_video_dir: str = None, undistorted_video_field: str = 'undistorted_video', camera_calibration_field: str = 'camera_calibration', batch_size_each_video: int = 1000, crf: int = 22, *args, **kwargs)[source]#

Initialization method.

Parameters:
  • output_video_dir – Output directory to save undistorted videos.

  • undistorted_video_field – The field name to store the tags. It’s “undistorted_video” in default.

  • camera_calibration_field – The field name where the camera calibration info is stored.

  • batch_size_each_video – Number of frames to process and save per temporary TS file batch.

  • crf – Constant Rate Factor (CRF) for FFmpeg encoding quality.

  • args – extra args

  • kwargs – extra args

concatenate_ts_files(folder, video_name, batch_counts)[source]#

Concatenate batch TS files into final mp4.

create_ffmpeg_writer(output_path, width, height, fps, crf)[source]#

Spawn an ffmpeg async encoding process for writing raw frames.

process_single(sample, context=False)[source]#

For sample level, sample –> sample

Parameters:

sample – sample to process

Returns:

processed sample