Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datajuicer Data juicer VideoUndistortMapper

From Leeroopedia
Knowledge Sources
Domains Data_Processing, Mapping
Last Updated 2026-02-14 16:00 GMT

Overview

Concrete tool for removing lens distortion from raw videos provided by Data-Juicer.

Description

VideoUndistortMapper reads per-frame camera intrinsics and distortion coefficients from sample metadata, computes undistortion remap matrices using OpenCV's omnidir module (CMei's model), applies the remapping to each frame in batches, saves intermediate results as temporary TS files, and concatenates them into a final MP4 using FFmpeg with configurable CRF quality. The operator requires the sample to include 'intrinsics' and 'xi' fields and optionally accepts 'distortion_coefficients', 'rotation_matrix', and 'intrinsics_new'.

Usage

Use when you need to correct optical lens distortion artifacts from raw video data, producing geometrically accurate video needed for 3D reconstruction, SLAM, and other geometric computer vision tasks.

Code Reference

Source Location

Signature

@OPERATORS.register_module("video_undistort_mapper")
class VideoUndistortMapper(Mapper):
    def __init__(self, output_video_dir: str = DATA_JUICER_ASSETS_CACHE,
                 tag_field_name: str = MetaKeys.video_undistortion_tags,
                 batch_size_each_video: int = 1000,
                 crf: int = 22,
                 *args, **kwargs):

Import

from data_juicer.ops.mapper.video_undistort_mapper import VideoUndistortMapper

I/O Contract

Inputs

Name Type Required Description
output_video_dir str No Output directory to save undistorted videos. Default: DATA_JUICER_ASSETS_CACHE
tag_field_name str No Field name to store the undistortion tags. Default: "video_undistortion_tags"
batch_size_each_video int No Number of frames to process per temporary TS file batch. Default: 1000
crf int No Constant Rate Factor for FFmpeg encoding quality. Default: 22

Outputs

Name Type Description
sample[Fields.meta][tag_field_name] dict Contains 'new_video_path' pointing to the undistorted MP4 output file

Usage Examples

process:
  - video_undistort_mapper:
      output_video_dir: "./undistorted_videos"
      crf: 18
      batch_size_each_video: 500

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment