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:
Slack Notification,SIFT,Halo Visualization,Cosine Similarity,Gaze Detection,Camera Focus,Image Convert Grayscale,Image Blur,SIFT Comparison,VLM As Detector,VLM As Classifier,Identify Changes,Mask Visualization,Polygon Visualization,Email Notification,Dynamic Crop,Camera Calibration,Color Visualization,SIFT Comparison,Background Subtraction,Grid Visualization,Polygon Visualization,Image Contours,Identify Outliers,VLM As Detector,Polygon Zone Visualization,Twilio SMS Notification,Webhook Sink,Roboflow Vision Events,Email Notification,Absolute Static Crop,Detections Consensus,PTZ Tracking (ONVIF),Roboflow Custom Metadata,Label Visualization,Image Slicer,Twilio SMS/MMS Notification,Circle Visualization,Local File Sink,JSON Parser,Stability AI Outpainting,Reference Path Visualization,Crop Visualization,Dot Visualization,Roboflow Dataset Upload,Bounding Box Visualization,Model Monitoring Inference Aggregator,Heatmap Visualization,Icon Visualization,Image Preprocessing,Stability AI Image Generation,Stability AI Inpainting,Pixelate Visualization,Relative Static Crop,Camera Focus,Ellipse Visualization,Background Color Visualization,Dynamic Zone,Blur Visualization,Keypoint Visualization,Corner Visualization,Stitch Images,Motion Detection,Morphological Transformation,Model Comparison Visualization,Contrast Equalization,Perspective Correction,Triangle Visualization,Image Threshold,Halo Visualization,Trace Visualization,Classification Label Visualization,Roboflow Dataset Upload,Line Counter Visualization,Image Slicer,VLM As Classifier,S3 Sink,QR Code Generator,Text Display,Depth Estimation - outputs:
Single-Label Classification Model,OpenAI,Anthropic Claude,SIFT,Multi-Label Classification Model,Halo Visualization,Google Gemini,SAM2 Video Tracker,Camera Focus,Barcode Detection,Image Convert Grayscale,VLM As Detector,LMM For Classification,Template Matching,Qwen3-VL,Google Gemini,OC-SORT Tracker,LMM,Color Visualization,Camera Calibration,SIFT Comparison,Background Subtraction,Polygon Visualization,Image Contours,Polygon Zone Visualization,Roboflow Vision Events,Email Notification,Absolute Static Crop,SAM 3,Label Visualization,Florence-2 Model,YOLO-World Model,Segment Anything 2 Model,SAM 3,Llama 3.2 Vision,Object Detection Model,EasyOCR,Instance Segmentation Model,Crop Visualization,Roboflow Dataset Upload,Bounding Box Visualization,Single-Label Classification Model,Heatmap Visualization,Icon Visualization,Anthropic Claude,Pixelate Visualization,Ellipse Visualization,Background Color Visualization,Camera Focus,Qwen3.5-VL,Buffer,Relative Static Crop,Blur Visualization,Object Detection Model,Stitch Images,Dominant Color,GLM-OCR,Contrast Equalization,Keypoint Detection Model,Triangle Visualization,Perspective Correction,Time in Zone,Image Threshold,Halo Visualization,Trace Visualization,Classification Label Visualization,SmolVLM2,Florence-2 Model,Line Counter Visualization,OpenAI,VLM As Classifier,Seg Preview,Instance Segmentation Model,Keypoint Detection Model,Text Display,Single-Label Classification Model,OpenAI,Gaze Detection,SORT Tracker,Image Blur,ByteTrack Tracker,Instance Segmentation Model,VLM As Classifier,Multi-Label Classification Model,Mask Visualization,Anthropic Claude,Polygon Visualization,Qwen2.5-VL,Dynamic Crop,Moondream2,VLM As Detector,Semantic Segmentation Model,Byte Tracker,OpenAI,Image Slicer,Twilio SMS/MMS Notification,Object Detection Model,Circle Visualization,CLIP Embedding Model,Stability AI Outpainting,Keypoint Detection Model,Reference Path Visualization,CogVLM,Dot Visualization,Pixel Color Count,Image Preprocessing,Clip Comparison,Stability AI Image Generation,Stability AI Inpainting,OCR Model,Keypoint Visualization,Detections Stabilizer,Semantic Segmentation Model,Corner Visualization,Motion Detection,Morphological Transformation,Clip Comparison,Model Comparison Visualization,QR Code Detection,Roboflow Dataset Upload,Perception Encoder Embedding Model,Google Vision OCR,Google Gemini,Multi-Label Classification Model,Image Slicer,Detections Stitch,SAM 3,Depth Estimation
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
}