Skip to content

Get Intrinsics ​

SUMMARY

Get Intrinsics returns the camera's intrinsic calibration parameters — focal lengths, principal point, and distortion coefficients. These are essential for projecting 3D points into pixel coordinates, undistorting images, and building accurate camera models for calibration workflows.

Available on: Intel RealSense, Zivid.

The Skill ​

The return signature differs between cameras:

RealSense — read through get_parameter("intrinsics", stream=...), where stream is "color" (the default) or "depth", and returns 2 values:

python
intrinsic_matrix, distortion_coefficients = camera.get_parameter("intrinsics", stream="color")
ValueTypeDescription
intrinsic_matrixnp.ndarray3x3 pinhole intrinsic matrix K = [[f_x, 0, ppx], [0, f_y, ppy], [0, 0, 1]], float64
distortion_coefficientsnp.ndarray1D distortion coefficients in OpenCV order, float64

Zivid — takes no arguments and returns 5 values:

python
f_x, f_y, c_x, c_y, coeffs = camera.get_intrinsics()
ValueTypeDescription
f_xfloatFocal length in x (pixels)
f_yfloatFocal length in y (pixels)
c_xfloatPrincipal point x offset from top-left corner (pixels)
c_yfloatPrincipal point y offset from top-left corner (pixels)
coeffslist[float]Distortion coefficients [k1, k2, k3, p1, p2] (radial + tangential)

The Code ​

python
"""
Connect to a RealSense camera and retrieve the intrinsic parameters
for both the depth and colour sensors.
"""
import numpy as np
from loguru import logger

from telekinesis.medulla.cameras import realsense
from telekinesis.medulla.cameras.realsense import StreamProfile


def main():
    camera = realsense.RealSenseD405(name="my_realsense_camera")
    try:
        camera.connect(serial_number="244222074143")

        # The intrinsics follow the resolution, so set the stream profile first
        camera.set_parameter(
            "stream_profile",
            StreamProfile.from_strings("color", 424, 240, "bgr8", 90),
        )

        # Query intrinsics for the colour sensor
        camera_matrix, dist_coeffs = camera.get_parameter("intrinsics", stream="color")

        logger.info(f"Color sensor intrinsics:")
        logger.info(f"  Camera matrix:\n{camera_matrix}")
        logger.info(f"  Distortion coeffs: {dist_coeffs}")

        # Query intrinsics for the depth sensor
        camera_matrix_d, dist_coeffs_d = camera.get_parameter("intrinsics", stream="depth")

        logger.info(f"Depth sensor intrinsics:")
        logger.info(f"  Camera matrix:\n{camera_matrix_d}")
        logger.info(f"  Distortion coeffs: {dist_coeffs_d}")

        # The matrix can be stored as the host-side calibration directly
        camera.intrinsic_matrix = camera_matrix
    finally:
        camera.disconnect()


if __name__ == "__main__":
    main()
python
"""
Connect to a Zivid camera and retrieve its intrinsic parameters.
"""
import numpy as np
from loguru import logger

from telekinesis.medulla.cameras import zivid


def main():
    camera = zivid.Zivid2M70(name="my_zivid_camera")
    try:
        camera.connect()

        f_x, f_y, c_x, c_y, coeffs = camera.get_intrinsics()

        logger.info(f"Focal length:    fx={f_x:.2f}, fy={f_y:.2f}")
        logger.info(f"Principal point: cx={c_x:.2f}, cy={c_y:.2f}")
        logger.info(f"Distortion:      {coeffs}")

        # Build OpenCV-compatible camera matrix
        camera_matrix = np.array([
            [f_x,  0,   c_x],
            [0,    f_y, c_y],
            [0,    0,   1  ],
        ], dtype=np.float64)

        dist_coeffs = np.array(coeffs, dtype=np.float64)

        logger.info(f"Camera matrix:\n{camera_matrix}")
        logger.info(f"Distortion coefficients: {dist_coeffs}")
    finally:
        camera.disconnect()


if __name__ == "__main__":
    main()

The Explanation of the Code ​

After connect has initialised the camera, the intrinsics are read from the underlying SDK as the factory-calibrated intrinsic parameters of the connected device. On RealSense this is get_parameter("intrinsics", stream=...); on Zivid it is get_intrinsics().

Per-camera behavior:

  • RealSense — takes a stream keyword ("color" or "depth") and reads the intrinsic parameters from the negotiated librealsense stream profile for that stream, starting acquisition by itself if needed. Returns the 3x3 intrinsic matrix and the distortion coefficients. The values follow the configured stream_profile, so read them again after changing the resolution. Since the depth and colour sensors have different optics and may run at different resolutions, their intrinsics differ — query both when you need to map between them. The result is not written to the host-side intrinsic_matrix and distortion_coefficients; assign it yourself if you want to store it (the RealSense streams are usually delivered already rectified, so the device often reports all-zero distortion). Connected to a simulated camera, the intrinsics are those of the simulated pinhole camera, with zero distortion.
  • Zivid — takes no arguments and queries the Zivid SDK's experimental calibration API. Returns 5 values with radial (k1, k2, k3) and tangential (p1, p2) distortion coefficients.

The focal lengths (f_x, f_y) and principal point (ppx/ppy in the RealSense matrix, c_x/c_y on Zivid) describe the ideal pinhole projection from 3D world coordinates to 2D pixel coordinates. Some RealSense models (the D405 among them) report the inverse_brown_conrady model, whose coefficients are not in OpenCV order; a warning is logged in that case and the coefficients should not be used for undistortion.

RealSense returns the standard OpenCV camera matrix and distortion vector directly, and the Zivid example shows how to assemble them from the returned values. Both can be passed to functions like cv2.undistort, cv2.projectPoints, or cv2.solvePnP.

python
camera_matrix = np.array([
    [f_x,  0,   c_x],
    [0,    f_y, c_y],
    [0,    0,   1  ],
], dtype=np.float64)

Parameter Configuration ​

ParameterTypeDefaultDescription
streamstr"color"RealSense only, passed to get_parameter("intrinsics", stream=...). Which stream to read intrinsics for, one of "color", "depth", "infrared_left", or "infrared_right". Not accepted by Zivid, which has a single sensor and takes no arguments.

Returns ​

TypeDescription
tuple (RealSense, 2 values)(intrinsic_matrix, distortion_coefficients) — a 3x3 float64 matrix and a 1D float64 array; see the table above.
tuple (Zivid, 5 values)(f_x, f_y, c_x, c_y, coeffs) — see the table above for each value.

Raises ​

ExceptionCondition
RuntimeErrorCamera is not connected (RealSense, Zivid)
ValueErrorRealSense: stream is not a supported stream name
RuntimeErrorRealSense, connected to a simulated camera: the simulated camera standing in for the stream is not a pinhole camera

IDS and Webcam expose no factory intrinsics query.

Where to Use the Skill ​

  • Hand-eye calibration — feed the intrinsic parameters into a calibration routine that computes the transform between the camera and robot flange.
  • Image undistortion — remove lens distortion from captured images before running computer vision algorithms.
  • 3D-to-2D projection — project point cloud coordinates onto the image plane for overlay visualisation or region-of-interest selection.
  • Pose estimation — use with cv2.solvePnP to estimate the pose of known objects from 2D-3D correspondences.