Scroll to navigation

MRCAL(1) mrcal: camera projection, calibration toolkit MRCAL(1)

NAME

mrcal-from-ros - Converts a ROS/OpenCV-formatted camera model to the .cameramodel file format

SYNOPSIS

  $ cat model1.yaml
  image_width: 2448
  image_height: 2050
  camera_name: prosilica
  camera_matrix:
    rows: 3
    cols: 3
    data: [4827.94, 0, 1223.5, 0, 4835.62, 1024.5, 0, 0, 1]
  distortion_model: plumb_bob
  distortion_coefficients:
    rows: 1
    cols: 5
    data: [-0.41527, 0.31874, -0.00197, 0.00071, 0]
  rectification_matrix:
    rows: 3
    cols: 3
    data: [1, 0, 0, 0, 1, 0, 0, 0, 1]
  projection_matrix:
    rows: 3
    cols: 4
    data: [4827.94, 0, 1223.5, 0, 0, 4835.62, 1024.5, 0, 0, 0, 1, 0]
  $ mrcal-from-ros model1.yaml model2.yaml
  Wrote model1.cameramodel
  Wrote model2.cameramodel
  $ cat model1.cameramodel
  {
      'lensmodel':  'LENSMODEL_OPENCV5',
      # intrinsics are fx,fy,cx,cy,distortion0,distortion1,....
      'intrinsics': [ 4827.94, 4835.62, 1223.5, 1024.5, -0.41527, 0.31874, -0.00197, 0.00071, 0,],
      'rt_cam_ref': [ 0, 0, 0, 0, 0, 0,],
      'extrinsics': [ 0, 0, 0, 0, 0, 0,], # for compatibility with mrcal < 2.5
      'imagersize': [ 2448, 2050,],
  }
  $ rostopic echo -n1 -b tst.bag /camera/camera_info \
    | head -n -1                                     \
    | mrcal-from-ros                                 \
    > model.cameramodel

DESCRIPTION

File formats supported by mrcal are described at <https://mrcal.secretsauce.net/cameramodels.html#cameramodel-file-formats>

This tool converts the given model(s) to the cameramodel file format. No changes to the content are made; this is purely a format converter (the mrcal-convert-lensmodel tool fits different lens models instead). Model filenames are given on the commandline. Output is written to the same directory, with the same filename, but with a .cameramodel extension.

If the model is omitted or given as "-", the input is read from standard input, and the output is written to standard output.

Note: there's no corresponding mrcal-to-ros tool at this time, because the behavior of such a tool isn't well-defined. Talk to me if this would be useful to you, to clarify what it should do, exactly.

OPTIONS

POSITIONAL ARGUMENTS

  model            Input camera model

OPTIONAL ARGUMENTS

  -h, --help       show this help message and exit
  --force, -f      By default existing files are not overwritten. Pass --force
                   to overwrite them without complaint
  --outdir OUTDIR  Directory to write the output models into. If omitted, we
                   write the output models to the same directory as the input
                   models

REPOSITORY

<https://www.github.com/dkogan/mrcal>

AUTHOR

Dima Kogan, "<dima@secretsauce.net>"

LICENSE AND COPYRIGHT

Copyright (c) 2017-2023 California Institute of Technology ("Caltech"). U.S. Government sponsorship acknowledged. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0
2026-01-27 mrcal 2.5.2-4