Last active
September 9, 2020 16:00
-
-
Save yuki-inaho/dc717e857347f8f060a7cec69e10fc5f to your computer and use it in GitHub Desktop.
convert intrinsic parameters of see3cam so as to conform 720p to 1080p
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import toml | |
| import click | |
| from collections import OrderedDict | |
| from ruamel import yaml # "import yaml" cannot deal with nested list | |
| import pdb | |
| import copy | |
| SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| @click.command() | |
| @click.option('--toml-path', '-t', default='{}/../cfg/camera_parameter.toml'.format(SCRIPT_DIR)) | |
| def main(toml_path): | |
| toml_base_name = os.path.basename(toml_path)[:-5] | |
| toml_dir = os.path.dirname(toml_path) | |
| decoder = toml.TomlDecoder(_dict=OrderedDict) | |
| encoder = toml.TomlEncoder(_dict=OrderedDict) | |
| toml_params = toml.load(open(toml_path), _dict=OrderedDict, decoder=decoder) | |
| cx_720p = toml_params["Rgb"]["cx"] | |
| cy_720p = toml_params["Rgb"]["cy"] | |
| diff_x = cx_720p - 1280.0/2 | |
| diff_y = cy_720p - 720.0/2 | |
| toml_params_1080p = copy.deepcopy(toml_params) | |
| toml_params_1080p["Rgb"]["cx"] = 1920/2.0 + diff_x | |
| toml_params_1080p["Rgb"]["cy"] = 1080/2.0 + diff_y | |
| toml_params_1080p["Rgb"]["width"] = 1920 | |
| toml_params_1080p["Rgb"]["height"] = 1080 | |
| toml_path_1080p = os.path.join(toml_dir, toml_base_name + "_1080p.toml") | |
| with open(toml_path_1080p, "w") as f: | |
| toml.encoder.dump(toml_params_1080p, f) | |
| print("generated") | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment