Lizmango / CV

computer vision
3 stars 0 forks source link

generate and reload camera parameter matrix #7

Open jacknlliu opened 6 years ago

jacknlliu commented 6 years ago

We follow the YAML configuration file format from ros-drivers/video_stream_opencv.

The format of the file camera_calibration.yaml:

image_width: 1280
image_height: 960
camera_name: "0800461000822014"
camera_matrix:
  rows: 3
  cols: 3
  data: [2302.59, 0, 610.756, 0, 2309.46, 506.539, 0, 0, 1]
distortion_model: plumb_bob
distortion_coefficients:
  rows: 1
  cols: 5
  data: [-0.225495, -0.363048, -0.000477994, -0.000132753, 0]
rectification_matrix:
  rows: 3
  cols: 3
  data: [1, 0, 0, 0, 1, 0, 0, 0, 1]
projection_matrix:
  rows: 3
  cols: 4
  data: [2302.59, 0, 610.756, 0, 0, 2309.46, 506.539, 0, 0, 0, 1, 0]

NOTE: The value of parameter distortion_model is fixed as plumb_bob.

TODO:

Reference

jacknlliu commented 6 years ago

An example:

import yaml

data = dict(
    A = 'a',
    B = dict(
        C = 'c',
        D = 'd',
        E = 'e',
    )
)

with open('data.yml', 'w') as outfile:
    yaml.dump(data, outfile, default_flow_style=False)

output of file

A: a
B:
  C: c
  D: d
  E: e

Reference

Lizmango commented 6 years ago

how to output a list in one row in yaml documents