mirror of
https://github.com/CopterExpress/clover.git
synced 2026-05-26 11:43:25 +00:00
Add tool for rescaling camera info file
Generate fisheye_cam camera info for all the different resolutions
This commit is contained in:
65
clover/camera_info/fisheye_cam_1280x720.yaml
Normal file
65
clover/camera_info/fisheye_cam_1280x720.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
# Generated from fisheye_cam.yaml by rescale_camera_info.py
|
||||
camera_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 415.5985593268293
|
||||
- 0.0
|
||||
- 400.0
|
||||
- 0.0
|
||||
- 312.35267324512984
|
||||
- 225.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
rows: 3
|
||||
camera_name: main_camera_optical
|
||||
distortion_coefficients:
|
||||
cols: 8
|
||||
data:
|
||||
- 0.215356885
|
||||
- -0.117472846
|
||||
- -0.000306197672
|
||||
- -0.000109444025
|
||||
- -0.00453657258
|
||||
- 0.573090623
|
||||
- -0.127574577
|
||||
- -0.0286125589
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
rows: 1
|
||||
distortion_model: plumb_bob
|
||||
image_height: 720
|
||||
image_width: 1280
|
||||
projection_matrix:
|
||||
cols: 4
|
||||
data:
|
||||
- 415.5985593268293
|
||||
- 0.0
|
||||
- 405.4752811707317
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 312.35267324512984
|
||||
- 205.91677004464282
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
- 0.0
|
||||
rows: 3
|
||||
rectification_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
rows: 3
|
||||
65
clover/camera_info/fisheye_cam_1920x1080.yaml
Normal file
65
clover/camera_info/fisheye_cam_1920x1080.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
# Generated from fisheye_cam.yaml by rescale_camera_info.py
|
||||
camera_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 1246.7956779804879
|
||||
- 0.0
|
||||
- 1200.0
|
||||
- 0.0
|
||||
- 702.7935148015422
|
||||
- 506.25
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
rows: 3
|
||||
camera_name: main_camera_optical
|
||||
distortion_coefficients:
|
||||
cols: 8
|
||||
data:
|
||||
- 0.215356885
|
||||
- -0.117472846
|
||||
- -0.000306197672
|
||||
- -0.000109444025
|
||||
- -0.00453657258
|
||||
- 0.573090623
|
||||
- -0.127574577
|
||||
- -0.0286125589
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
rows: 1
|
||||
distortion_model: plumb_bob
|
||||
image_height: 1080
|
||||
image_width: 1920
|
||||
projection_matrix:
|
||||
cols: 4
|
||||
data:
|
||||
- 1246.7956779804879
|
||||
- 0.0
|
||||
- 1216.4258435121951
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 702.7935148015422
|
||||
- 463.31273260044634
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
- 0.0
|
||||
rows: 3
|
||||
rectification_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
rows: 3
|
||||
65
clover/camera_info/fisheye_cam_2592x1944.yaml
Normal file
65
clover/camera_info/fisheye_cam_2592x1944.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
# Generated from fisheye_cam.yaml by rescale_camera_info.py
|
||||
camera_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 5049.522495820976
|
||||
- 0.0
|
||||
- 4860.0
|
||||
- 0.0
|
||||
- 2846.313734946246
|
||||
- 2050.3125
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
rows: 3
|
||||
camera_name: main_camera_optical
|
||||
distortion_coefficients:
|
||||
cols: 8
|
||||
data:
|
||||
- 0.215356885
|
||||
- -0.117472846
|
||||
- -0.000306197672
|
||||
- -0.000109444025
|
||||
- -0.00453657258
|
||||
- 0.573090623
|
||||
- -0.127574577
|
||||
- -0.0286125589
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
rows: 1
|
||||
distortion_model: plumb_bob
|
||||
image_height: 1944
|
||||
image_width: 2592
|
||||
projection_matrix:
|
||||
cols: 4
|
||||
data:
|
||||
- 5049.522495820976
|
||||
- 0.0
|
||||
- 4926.52466622439
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 2846.313734946246
|
||||
- 1876.4165670318075
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
- 0.0
|
||||
rows: 3
|
||||
rectification_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
rows: 3
|
||||
65
clover/camera_info/fisheye_cam_320x240.yaml
Normal file
65
clover/camera_info/fisheye_cam_320x240.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
# Generated from fisheye_cam.yaml by rescale_camera_info.py
|
||||
camera_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 166.23942373073172
|
||||
- 0.0
|
||||
- 160.0
|
||||
- 0.0
|
||||
- 166.5880923974026
|
||||
- 120.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
rows: 3
|
||||
camera_name: main_camera_optical
|
||||
distortion_coefficients:
|
||||
cols: 8
|
||||
data:
|
||||
- 0.215356885
|
||||
- -0.117472846
|
||||
- -0.000306197672
|
||||
- -0.000109444025
|
||||
- -0.00453657258
|
||||
- 0.573090623
|
||||
- -0.127574577
|
||||
- -0.0286125589
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
rows: 1
|
||||
distortion_model: plumb_bob
|
||||
image_height: 240
|
||||
image_width: 320
|
||||
projection_matrix:
|
||||
cols: 4
|
||||
data:
|
||||
- 166.23942373073172
|
||||
- 0.0
|
||||
- 162.19011246829268
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 166.5880923974026
|
||||
- 109.82227735714285
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
- 0.0
|
||||
rows: 3
|
||||
rectification_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
rows: 3
|
||||
65
clover/camera_info/fisheye_cam_3840x2160.yaml
Normal file
65
clover/camera_info/fisheye_cam_3840x2160.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
# Generated from fisheye_cam.yaml by rescale_camera_info.py
|
||||
camera_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 30297.13497492585
|
||||
- 0.0
|
||||
- 29160.0
|
||||
- 0.0
|
||||
- 12808.411807258106
|
||||
- 9226.40625
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
rows: 3
|
||||
camera_name: main_camera_optical
|
||||
distortion_coefficients:
|
||||
cols: 8
|
||||
data:
|
||||
- 0.215356885
|
||||
- -0.117472846
|
||||
- -0.000306197672
|
||||
- -0.000109444025
|
||||
- -0.00453657258
|
||||
- 0.573090623
|
||||
- -0.127574577
|
||||
- -0.0286125589
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
rows: 1
|
||||
distortion_model: plumb_bob
|
||||
image_height: 2160
|
||||
image_width: 3840
|
||||
projection_matrix:
|
||||
cols: 4
|
||||
data:
|
||||
- 30297.13497492585
|
||||
- 0.0
|
||||
- 29559.14799734634
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 12808.411807258106
|
||||
- 8443.874551643134
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
- 0.0
|
||||
rows: 3
|
||||
rectification_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
rows: 3
|
||||
65
clover/camera_info/fisheye_cam_4056x3040.yaml
Normal file
65
clover/camera_info/fisheye_cam_4056x3040.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
# Generated from fisheye_cam.yaml by rescale_camera_info.py
|
||||
camera_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 192008.0929035926
|
||||
- 0.0
|
||||
- 184801.5
|
||||
- 0.0
|
||||
- 81119.941445968
|
||||
- 58433.90625
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
rows: 3
|
||||
camera_name: main_camera_optical
|
||||
distortion_coefficients:
|
||||
cols: 8
|
||||
data:
|
||||
- 0.215356885
|
||||
- -0.117472846
|
||||
- -0.000306197672
|
||||
- -0.000109444025
|
||||
- -0.00453657258
|
||||
- 0.573090623
|
||||
- -0.127574577
|
||||
- -0.0286125589
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
rows: 1
|
||||
distortion_model: plumb_bob
|
||||
image_height: 3040
|
||||
image_width: 4056
|
||||
projection_matrix:
|
||||
cols: 4
|
||||
data:
|
||||
- 192008.0929035926
|
||||
- 0.0
|
||||
- 187331.10043318244
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 81119.941445968
|
||||
- 53477.87216040651
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
- 0.0
|
||||
rows: 3
|
||||
rectification_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
rows: 3
|
||||
65
clover/camera_info/fisheye_cam_640x480.yaml
Normal file
65
clover/camera_info/fisheye_cam_640x480.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
# Generated from fisheye_cam.yaml by rescale_camera_info.py
|
||||
camera_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 166.23942373073172
|
||||
- 0.0
|
||||
- 160.0
|
||||
- 0.0
|
||||
- 166.5880923974026
|
||||
- 120.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
rows: 3
|
||||
camera_name: main_camera_optical
|
||||
distortion_coefficients:
|
||||
cols: 8
|
||||
data:
|
||||
- 0.215356885
|
||||
- -0.117472846
|
||||
- -0.000306197672
|
||||
- -0.000109444025
|
||||
- -0.00453657258
|
||||
- 0.573090623
|
||||
- -0.127574577
|
||||
- -0.0286125589
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
rows: 1
|
||||
distortion_model: plumb_bob
|
||||
image_height: 480
|
||||
image_width: 640
|
||||
projection_matrix:
|
||||
cols: 4
|
||||
data:
|
||||
- 166.23942373073172
|
||||
- 0.0
|
||||
- 162.19011246829268
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 166.5880923974026
|
||||
- 109.82227735714285
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
- 0.0
|
||||
rows: 3
|
||||
rectification_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
rows: 3
|
||||
65
clover/camera_info/fisheye_cam_800x600.yaml
Normal file
65
clover/camera_info/fisheye_cam_800x600.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
# Generated from fisheye_cam.yaml by rescale_camera_info.py
|
||||
camera_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 207.79927966341464
|
||||
- 0.0
|
||||
- 200.0
|
||||
- 0.0
|
||||
- 208.23511549675322
|
||||
- 150.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
rows: 3
|
||||
camera_name: main_camera_optical
|
||||
distortion_coefficients:
|
||||
cols: 8
|
||||
data:
|
||||
- 0.215356885
|
||||
- -0.117472846
|
||||
- -0.000306197672
|
||||
- -0.000109444025
|
||||
- -0.00453657258
|
||||
- 0.573090623
|
||||
- -0.127574577
|
||||
- -0.0286125589
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
rows: 1
|
||||
distortion_model: plumb_bob
|
||||
image_height: 600
|
||||
image_width: 800
|
||||
projection_matrix:
|
||||
cols: 4
|
||||
data:
|
||||
- 207.79927966341464
|
||||
- 0.0
|
||||
- 202.73764058536585
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 208.23511549675322
|
||||
- 137.27784669642855
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 0.0
|
||||
- 1.0
|
||||
- 0.0
|
||||
rows: 3
|
||||
rectification_matrix:
|
||||
cols: 3
|
||||
data:
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
- 0
|
||||
- 0
|
||||
- 0
|
||||
- 1
|
||||
rows: 3
|
||||
68
clover/tools/rescale_camera_info.py
Executable file
68
clover/tools/rescale_camera_info.py
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2024 Copter Express Technologies
|
||||
#
|
||||
# Author: Oleg Kalachev <okalachev@gmail.com>
|
||||
#
|
||||
# Distributed under MIT License (available at https://opensource.org/licenses/MIT).
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
|
||||
"""Rescale camera info
|
||||
|
||||
Rescale camera info files for different resolutions.
|
||||
|
||||
Usage:
|
||||
rescale_camera_info.py <camera_info_file>
|
||||
rescale_camera_info.py (-h | --help)
|
||||
|
||||
Options:
|
||||
<camera_info_file> Path to the source camera info file
|
||||
|
||||
Example:
|
||||
rescale_camera_info.py camera_info.yaml
|
||||
"""
|
||||
|
||||
from docopt import docopt
|
||||
import yaml
|
||||
|
||||
arguments = docopt(__doc__)
|
||||
|
||||
camera_info = yaml.safe_load(open(arguments['<camera_info_file>']))
|
||||
RESOLUTIONS = (
|
||||
(320, 240), # QVGA
|
||||
(640, 480), # VGA
|
||||
(800, 600), # SVGA
|
||||
(1280, 720), # HD
|
||||
(1920, 1080), # FullHD
|
||||
(2592, 1944), # 5MP
|
||||
(3840, 2160), # 4K
|
||||
(4056, 3040),
|
||||
)
|
||||
# TODO: retrieve resolutions list (v4l2-ctl --list-formats-ext)
|
||||
|
||||
for resolution in RESOLUTIONS:
|
||||
width_k = resolution[0] / camera_info['image_width']
|
||||
height_k = resolution[1] / camera_info['image_height']
|
||||
|
||||
camera_info_rescaled = camera_info.copy()
|
||||
camera_info_rescaled['image_width'] = resolution[0]
|
||||
camera_info_rescaled['image_height'] = resolution[1]
|
||||
|
||||
# See http://docs.ros.org/api/sensor_msgs/html/msg/CameraInfo.html for clarification
|
||||
camera_info_rescaled['camera_matrix']['data'][0] *= width_k
|
||||
camera_info_rescaled['camera_matrix']['data'][2] *= width_k
|
||||
camera_info_rescaled['camera_matrix']['data'][4] *= height_k
|
||||
camera_info_rescaled['camera_matrix']['data'][5] *= height_k
|
||||
|
||||
camera_info_rescaled['projection_matrix']['data'][0] *= width_k
|
||||
camera_info_rescaled['projection_matrix']['data'][2] *= width_k
|
||||
camera_info_rescaled['projection_matrix']['data'][5] *= height_k
|
||||
camera_info_rescaled['projection_matrix']['data'][6] *= height_k
|
||||
|
||||
output_file = arguments['<camera_info_file>'].replace('.yaml', '_{}x{}.yaml'.format(resolution[0], resolution[1]))
|
||||
with open(output_file, 'w') as f:
|
||||
f.write('# Generated from {} by rescale_camera_info.py\n'.format(arguments['<camera_info_file>']))
|
||||
yaml.dump(camera_info_rescaled, f)
|
||||
|
||||
print('Saved {}'.format(output_file))
|
||||
Reference in New Issue
Block a user