robot_msgs

CameraInfo

Image size, camera matrix k, distortion d, rectification r, projection p.

Full docstring
`k`, `r` and `p` are stored as matrices (ROS flattens them to 9, 9 and 12 numbers;
converters flatten). Pixel coordinates are (u = column, v = row), x right, y down, z forward.
`p` defaults to `[k | 0]` when left out.
Import
from robot_msgs.sensor import CameraInfo
ROS 2sensor_msgs/msg/CameraInfo

Preview

The figure robot_msgs.viz.plot(example) draws for the example below.

Plot of an example CameraInfo

Fields

NameTypeDefault
widthintrequired
heightintrequired
kArrayrequired
dArrayarray([], dtype=float64)
distortion_modelstr'plumb_bob'
rArrayarray([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
pArray | NoneNone
headerHeaderHeader()

Example

One instance from the package's own test catalog; the output is its real repr().

CameraInfo(width=640, height=480, k=float64[3×3], d=[], distortion_model='plumb_bob', r=float64[3×3], p=float64[3×4], header=Header(stamp=1761600000.25, frame_id='camera_color_optical_frame'))
to_dict() as JSON
{
  "_type": "sensor/CameraInfo",
  "width": 640,
  "height": 480,
  "k": {
    "dtype": "<f8",
    "shape": [3, 3],
    "data": [615.0, 0.0, 320.0, 0.0, 615.0, 240.0, 0.0, 0.0, 1.0]
  },
  "d": {
    "dtype": "<f8",
    "shape": [0],
    "data": []
  },
  "distortion_model": "plumb_bob",
  "r": {
    "dtype": "<f8",
    "shape": [3, 3],
    "data": [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
  },
  "p": {
    "dtype": "<f8",
    "shape": [3, 4],
    "data": [615.0, 0.0, 320.0, 0.0, 0.0, 615.0, 240.0, 0.0, 0.0, 0.0, 1.0, 0.0]
  },
  "header": {
    "_type": "std/Header",
    "stamp": 1761600000.25,
    "frame_id": "camera_color_optical_frame",
    "meta": {}
  }
}

Long arrays are cut after 16 values and say so with “…”.

Functions

Constructors

Classmethods and staticmethods: ways to build one.

from_intrinsics(
    fx: float,
    fy: float,
    cx: float,
    cy: float,
    width: int,
    height: int,
    d: Array | None = None,
    header: Header | None = None,
) -> CameraInfo

No docstring.

from_dict

from Msg
from_dict(data: Mapping[str, Any]) -> M

No docstring.

Properties

Read-only views computed from the fields.

cx: float

No docstring.

cy: float

No docstring.

fx: float

No docstring.

fy: float

No docstring.

Methods

Return new values; messages are never mutated.

project(points: Array) -> Array

(N, 3) points in the camera optical frame → (N, 2) pixels (u, v).

scaled(factor: float) -> CameraInfo

Intrinsics for the same image resized by factor (sizes round to whole pixels).

unproject(pixels: Array, depth: Array) -> Array

(N, 2) pixels (u, v) with (N,) depth z along the optical axis → (N, 3) points.

replace

from Msg
replace(**changes: Any) -> M

A copy with some fields changed. Validation runs again.

to_dict

from Msg
to_dict() -> dict[str, Any]

JSON-safe dict with a "_type" key; arrays keep their dtype and shape.

Uses

Types its fields refer to.

Header

robot_msgs 0.1.0 @ 2dc6666GitHub · MIT license · generated from the package, not written per type