Camera Calibration¶
Class: CameraCalibrationBlockV1
Source: inference.core.workflows.core_steps.transformations.camera_calibration.v1.CameraCalibrationBlockV1
Remove lens distortions from images using camera calibration parameters (focal lengths, optical centers, and distortion coefficients) to correct radial and tangential distortions introduced by camera lenses, producing undistorted images suitable for accurate measurement, geometric analysis, and precision computer vision applications.
How This Block Works¶
Camera lenses introduce distortions that cause straight lines to appear curved and objects near image edges to appear stretched or compressed. This block corrects these distortions using known camera calibration parameters. The block:
- Receives input images and camera calibration parameters (focal lengths fx/fy, optical centers cx/cy, radial distortion coefficients k1/k2/k3, tangential distortion coefficients p1/p2)
- Constructs a camera matrix from the intrinsic parameters (focal lengths and optical centers) in the standard OpenCV format: 3x3 matrix with fx, fy on the diagonal, cx, cy as the optical center, and 1 in the bottom-right corner
- Assembles distortion coefficients into a 5-element array (k1, k2, p1, p2, k3) representing radial and tangential distortion parameters
- Computes an optimal new camera matrix using OpenCV's
getOptimalNewCameraMatrixto maximize the usable image area after correction (removes black borders that result from distortion correction) - Applies OpenCV's
undistortfunction to correct both radial distortions (barrel and pincushion distortion causing curved lines) and tangential distortions (lens misalignment causing skewed images) - Returns the corrected, undistorted image with straight lines corrected, edge distortions removed, and geometric accuracy restored
The block uses OpenCV's camera calibration functions under the hood, following standard computer vision camera calibration methodology (see OpenCV calibration tutorial for details on obtaining calibration parameters). Radial distortion coefficients (k1, k2, k3) correct barrel/pincushion distortion where image points are displaced radially from the optical center. Tangential distortion coefficients (p1, p2) correct distortion caused by lens misalignment. The calibration parameters must be obtained beforehand through a camera calibration process (typically using checkerboard patterns) or provided by the camera manufacturer.
Requirements¶
Camera Calibration Parameters: This block requires pre-computed camera calibration parameters obtained through camera calibration: - Focal lengths (fx, fy): Pixel focal lengths along x and y axes (may differ for non-square pixels) - Optical centers (cx, cy): Principal point coordinates (image center in ideal cameras) - Radial distortion coefficients (k1, k2, k3): Correct barrel and pincushion distortion - Tangential distortion coefficients (p1, p2): Correct lens misalignment distortion
These parameters are typically obtained using OpenCV's camera calibration process with a checkerboard pattern or similar calibration target. See OpenCV camera calibration documentation for calibration methodology.
Common Use Cases¶
- Measurement and Metrology Applications: Correct lens distortions for accurate measurement workflows (e.g., remove distortions before measuring object sizes, correct geometric distortions for precision measurements, undistort images for dimensional analysis), enabling accurate measurements from camera images
- Geometric Analysis Workflows: Prepare images for geometric computer vision tasks (e.g., undistort images before line detection, correct distortions for geometric shape analysis, prepare images for accurate angle measurements), enabling precise geometric analysis with corrected images
- Multi-Camera Systems: Standardize images from multiple cameras with different lens characteristics (e.g., undistort images from different camera angles, correct wide-angle lens distortions, standardize images from multiple cameras for stereo vision), enabling consistent image geometry across camera setups
- Pre-Processing for Precision Models: Prepare images for models requiring high geometric accuracy (e.g., undistort images before running geometric models, correct distortions for accurate feature detection, prepare images for precise pose estimation), enabling better accuracy for geometric computer vision tasks
- Wide-Angle and Fisheye Correction: Correct severe distortions from wide-angle or fisheye lenses (e.g., correct barrel distortion from wide-angle lenses, remove fisheye distortion effects, straighten curved lines in wide-angle images), enabling use of wide-angle lenses with standard computer vision workflows
- Video Stabilization Preparation: Correct lens distortions as part of video stabilization pipelines (e.g., undistort video frames before stabilization, correct camera-specific distortions in video streams, prepare frames for motion analysis), enabling more accurate video processing
Connecting to Other Blocks¶
This block receives images and produces undistorted images:
- After image loading blocks to correct lens distortions before processing, enabling accurate analysis with geometrically correct images
- Before measurement and analysis blocks that require geometric accuracy (e.g., size measurement, angle measurement, distance calculation, geometric shape analysis), enabling precise measurements from undistorted images
- Before geometric computer vision blocks that analyze lines, shapes, or spatial relationships (e.g., line detection, contour analysis, geometric pattern matching, pose estimation), enabling accurate geometric analysis with corrected images
- In multi-camera workflows to standardize images from different cameras before processing (e.g., undistort images from different camera angles, correct camera-specific distortions before comparison, standardize images for stereo vision), enabling consistent processing across camera setups
- Before detection or classification blocks in precision applications where geometric accuracy matters (e.g., detect objects in undistorted images for accurate localization, classify objects in geometrically correct images, run models requiring precise spatial relationships), enabling improved accuracy for detection and classification tasks
- In video processing workflows to correct distortions in video frames (e.g., undistort video frames for motion analysis, correct camera distortions in video streams, prepare frames for tracking algorithms), enabling accurate video analysis with corrected frames
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/camera-calibration@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
fx |
float |
Focal length along the x-axis in pixels. Part of the camera's intrinsic parameters. Typically obtained through camera calibration (e.g., using OpenCV calibration with a checkerboard pattern). Represents the camera's horizontal focal length. For square pixels, fx and fy are usually equal. Must be obtained from camera calibration or manufacturer specifications.. | ✅ |
fy |
float |
Focal length along the y-axis in pixels. Part of the camera's intrinsic parameters. Typically obtained through camera calibration (e.g., using OpenCV calibration with a checkerboard pattern). Represents the camera's vertical focal length. For square pixels, fx and fy are usually equal. Must be obtained from camera calibration or manufacturer specifications.. | ✅ |
cx |
float |
Optical center (principal point) x-coordinate in pixels. Part of the camera's intrinsic parameters representing the x-coordinate of the camera's principal point (image center in ideal cameras). Typically near half the image width. Obtained through camera calibration. Used with cy to define the optical center of the camera.. | ✅ |
cy |
float |
Optical center (principal point) y-coordinate in pixels. Part of the camera's intrinsic parameters representing the y-coordinate of the camera's principal point (image center in ideal cameras). Typically near half the image height. Obtained through camera calibration. Used with cx to define the optical center of the camera.. | ✅ |
k1 |
float |
First radial distortion coefficient. Part of the camera's distortion parameters used to correct barrel and pincushion distortion (where straight lines appear curved). k1 is typically the dominant radial distortion term. Positive values often indicate barrel distortion, negative values indicate pincushion distortion. Obtained through camera calibration.. | ✅ |
k2 |
float |
Second radial distortion coefficient. Part of the camera's distortion parameters used to correct higher-order radial distortion effects. k2 helps correct more complex radial distortion patterns beyond the first-order k1 term. Obtained through camera calibration. Often smaller in magnitude than k1.. | ✅ |
k3 |
float |
Third radial distortion coefficient. Part of the camera's distortion parameters used to correct additional higher-order radial distortion effects. k3 is typically the smallest radial distortion term and is used for very precise distortion correction, especially for wide-angle lenses. Obtained through camera calibration. Often set to 0 for standard lenses.. | ✅ |
p1 |
float |
First tangential distortion coefficient. Part of the camera's distortion parameters used to correct tangential distortion caused by lens misalignment. p1 corrects skew distortions where the lens is not perfectly aligned with the image sensor. Obtained through camera calibration. For well-aligned lenses, p1 and p2 are often close to zero.. | ✅ |
p2 |
float |
Second tangential distortion coefficient. Part of the camera's distortion parameters used to correct additional tangential distortion effects. p2 works together with p1 to correct lens misalignment distortions. Obtained through camera calibration. For well-aligned lenses, p1 and p2 are often close to zero.. | ✅ |
use_fisheye_model |
bool |
Enable Fisheye distortion model (Rational/Divisional). If true, uses a different mathematical model better suited for fisheye lenses. When enabled, k1 is the primary parameter, and other coefficients are typically 0.. | ✅ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Camera Calibration in version v1.
- inputs:
Email Notification,Contrast Equalization,PTZ Tracking (ONVIF),Grid Visualization,S3 Sink,Stability AI Image Generation,Model Comparison Visualization,Identify Changes,Absolute Static Crop,Keypoint Visualization,SIFT,Trace Visualization,Roboflow Dataset Upload,Twilio SMS/MMS Notification,QR Code Generator,Model Monitoring Inference Aggregator,Reference Path Visualization,Halo Visualization,SIFT Comparison,VLM As Classifier,VLM As Detector,Image Preprocessing,Crop Visualization,Identify Outliers,Label Visualization,Classification Label Visualization,Pixelate Visualization,Local File Sink,Twilio SMS Notification,Email Notification,Corner Visualization,Stitch Images,Background Subtraction,Morphological Transformation,Image Threshold,Background Color Visualization,Camera Calibration,Halo Visualization,Stability AI Outpainting,Roboflow Custom Metadata,Ellipse Visualization,Dynamic Zone,VLM As Classifier,Heatmap Visualization,Image Convert Grayscale,Detections Consensus,Triangle Visualization,Image Blur,Depth Estimation,Color Visualization,SIFT Comparison,Camera Focus,Text Display,Dot Visualization,Image Slicer,Polygon Visualization,Motion Detection,Circle Visualization,Blur Visualization,Cosine Similarity,Slack Notification,Icon Visualization,Camera Focus,Stability AI Inpainting,Polygon Visualization,Webhook Sink,Polygon Zone Visualization,Perspective Correction,Gaze Detection,Mask Visualization,Image Contours,Dynamic Crop,Roboflow Dataset Upload,JSON Parser,VLM As Detector,Image Slicer,Line Counter Visualization,Relative Static Crop,Bounding Box Visualization - outputs:
Dominant Color,Email Notification,Instance Segmentation Model,ByteTrack Tracker,Google Vision OCR,Contrast Equalization,Stability AI Image Generation,Model Comparison Visualization,Absolute Static Crop,Keypoint Visualization,Trace Visualization,SIFT,Roboflow Dataset Upload,Twilio SMS/MMS Notification,CLIP Embedding Model,Buffer,SAM 3,GLM-OCR,Reference Path Visualization,Halo Visualization,OCR Model,SIFT Comparison,VLM As Classifier,Time in Zone,Detections Stabilizer,VLM As Detector,Image Preprocessing,SORT Tracker,Perception Encoder Embedding Model,Crop Visualization,OpenAI,OpenAI,Label Visualization,Pixelate Visualization,Classification Label Visualization,Qwen3.5-VL,Corner Visualization,Stitch Images,Background Subtraction,LMM For Classification,EasyOCR,Morphological Transformation,Qwen2.5-VL,SAM 3,OpenAI,Clip Comparison,Single-Label Classification Model,Background Color Visualization,Anthropic Claude,Image Threshold,Google Gemini,Camera Calibration,Stability AI Outpainting,Halo Visualization,CogVLM,OpenAI,Single-Label Classification Model,Ellipse Visualization,Detections Stitch,VLM As Classifier,Heatmap Visualization,Image Convert Grayscale,Triangle Visualization,Semantic Segmentation Model,Image Blur,Depth Estimation,Barcode Detection,Color Visualization,Camera Focus,Text Display,Anthropic Claude,Dot Visualization,Image Slicer,SmolVLM2,SAM 3,Template Matching,Keypoint Detection Model,Polygon Visualization,Florence-2 Model,Motion Detection,Circle Visualization,Blur Visualization,Qwen3-VL,Multi-Label Classification Model,Google Gemini,LMM,Icon Visualization,Camera Focus,Stability AI Inpainting,Polygon Visualization,Polygon Zone Visualization,Florence-2 Model,Gaze Detection,Perspective Correction,Anthropic Claude,Instance Segmentation Model,Mask Visualization,Moondream2,QR Code Detection,Google Gemini,Image Contours,Clip Comparison,YOLO-World Model,Dynamic Crop,Roboflow Dataset Upload,Llama 3.2 Vision,Seg Preview,Keypoint Detection Model,Object Detection Model,Pixel Color Count,VLM As Detector,Object Detection Model,Image Slicer,Byte Tracker,Line Counter Visualization,Relative Static Crop,Multi-Label Classification Model,OC-SORT Tracker,Bounding Box Visualization,Segment Anything 2 Model
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Camera Calibration in version v1 has.
Bindings
-
input
image(image): Input image to remove lens distortions from. The image will be corrected for radial and tangential distortions using the provided camera calibration parameters. Works with images from cameras with known calibration parameters. The undistorted output image will have corrected geometry with straight lines straightened and edge distortions removed..fx(float): Focal length along the x-axis in pixels. Part of the camera's intrinsic parameters. Typically obtained through camera calibration (e.g., using OpenCV calibration with a checkerboard pattern). Represents the camera's horizontal focal length. For square pixels, fx and fy are usually equal. Must be obtained from camera calibration or manufacturer specifications..fy(float): Focal length along the y-axis in pixels. Part of the camera's intrinsic parameters. Typically obtained through camera calibration (e.g., using OpenCV calibration with a checkerboard pattern). Represents the camera's vertical focal length. For square pixels, fx and fy are usually equal. Must be obtained from camera calibration or manufacturer specifications..cx(float): Optical center (principal point) x-coordinate in pixels. Part of the camera's intrinsic parameters representing the x-coordinate of the camera's principal point (image center in ideal cameras). Typically near half the image width. Obtained through camera calibration. Used with cy to define the optical center of the camera..cy(float): Optical center (principal point) y-coordinate in pixels. Part of the camera's intrinsic parameters representing the y-coordinate of the camera's principal point (image center in ideal cameras). Typically near half the image height. Obtained through camera calibration. Used with cx to define the optical center of the camera..k1(float): First radial distortion coefficient. Part of the camera's distortion parameters used to correct barrel and pincushion distortion (where straight lines appear curved). k1 is typically the dominant radial distortion term. Positive values often indicate barrel distortion, negative values indicate pincushion distortion. Obtained through camera calibration..k2(float): Second radial distortion coefficient. Part of the camera's distortion parameters used to correct higher-order radial distortion effects. k2 helps correct more complex radial distortion patterns beyond the first-order k1 term. Obtained through camera calibration. Often smaller in magnitude than k1..k3(float): Third radial distortion coefficient. Part of the camera's distortion parameters used to correct additional higher-order radial distortion effects. k3 is typically the smallest radial distortion term and is used for very precise distortion correction, especially for wide-angle lenses. Obtained through camera calibration. Often set to 0 for standard lenses..p1(float): First tangential distortion coefficient. Part of the camera's distortion parameters used to correct tangential distortion caused by lens misalignment. p1 corrects skew distortions where the lens is not perfectly aligned with the image sensor. Obtained through camera calibration. For well-aligned lenses, p1 and p2 are often close to zero..p2(float): Second tangential distortion coefficient. Part of the camera's distortion parameters used to correct additional tangential distortion effects. p2 works together with p1 to correct lens misalignment distortions. Obtained through camera calibration. For well-aligned lenses, p1 and p2 are often close to zero..use_fisheye_model(boolean): Enable Fisheye distortion model (Rational/Divisional). If true, uses a different mathematical model better suited for fisheye lenses. When enabled, k1 is the primary parameter, and other coefficients are typically 0..
-
output
calibrated_image(image): Image in workflows.
Example JSON definition of step Camera Calibration in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/camera-calibration@v1",
"image": "$inputs.image",
"fx": 0.123,
"fy": 0.123,
"cx": 0.123,
"cy": 0.123,
"k1": 0.123,
"k2": 0.123,
"k3": 0.123,
"p1": 0.123,
"p2": 0.123,
"use_fisheye_model": true
}