The open source OpenXR runtime

t/cli: Add calib-dump command

+61 -1
+5
src/xrt/targets/cli/CMakeLists.txt
··· 6 6 7 7 add_executable( 8 8 cli 9 + cli_cmd_calibration_dump.c 9 10 cli_cmd_lighthouse.c 10 11 cli_cmd_probe.c 11 12 cli_cmd_slambatch.c ··· 18 19 if(NOT WIN32) 19 20 # No getline on Windows, so until we have a portable impl 20 21 target_sources(cli PRIVATE cli_cmd_calibrate.c) 22 + endif() 23 + 24 + if(XRT_HAVE_OPENCV) 25 + target_link_libraries(cli PRIVATE aux_tracking) 21 26 endif() 22 27 23 28 set_target_properties(cli PROPERTIES OUTPUT_NAME monado-cli PREFIX "")
+48
src/xrt/targets/cli/cli_cmd_calibration_dump.c
··· 1 + // Copyright 2019-2023, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Loads and dumps a calibration file. 6 + * @author Jakob Bornecrantz <jakob@collabora.com> 7 + */ 8 + 9 + #include "xrt/xrt_compiler.h" 10 + #include "xrt/xrt_config_have.h" 11 + 12 + #include "cli_common.h" 13 + 14 + #ifdef XRT_HAVE_OPENCV 15 + #include "tracking/t_tracking.h" 16 + #endif 17 + 18 + #include <string.h> 19 + #include <stdio.h> 20 + 21 + #define P(...) fprintf(stderr, __VA_ARGS__) 22 + 23 + int 24 + cli_cmd_calibration_dump(int argc, const char **argv) 25 + { 26 + #ifdef XRT_HAVE_OPENCV 27 + if (argc < 3) { 28 + P("Must be given a file path\n"); 29 + return 1; 30 + } 31 + 32 + const char *filename = argv[2]; 33 + 34 + struct t_stereo_camera_calibration *data = NULL; 35 + if (!t_stereo_camera_calibration_load(filename, &data)) { 36 + P("Could not load '%s'!\n", filename); 37 + return 1; 38 + } 39 + 40 + t_stereo_camera_calibration_dump(data); 41 + t_stereo_camera_calibration_reference(&data, NULL); 42 + 43 + return 0; 44 + #else 45 + P("Not compiled with XRT_HAVE_OPENCV, so can't load calibration files!\n"); 46 + return 1; 47 + #endif 48 + }
+3
src/xrt/targets/cli/cli_common.h
··· 18 18 cli_cmd_calibrate(int argc, const char **argv); 19 19 20 20 int 21 + cli_cmd_calibration_dump(int argc, const char **argv); 22 + 23 + int 21 24 cli_cmd_lighthouse(int argc, const char **argv); 22 25 23 26 int
+5 -1
src/xrt/targets/cli/cli_main.c
··· 24 24 } 25 25 26 26 P("Monado-CLI 0.0.1\n"); 27 - P("Usage: %s command [options]\n", argv[0]); 27 + P("Usage: %s command [options] [file]\n", argv[0]); 28 28 P("\n"); 29 29 P("Commands:\n"); 30 30 P(" test - List found devices, for prober testing.\n"); 31 31 P(" probe - Just probe and then exit.\n"); 32 32 P(" lighthouse - Control the power of lighthouses [on|off].\n"); 33 33 P(" calibrate - Calibrate a camera and save config (not implemented yet).\n"); 34 + P(" calib-dumb - Load and dump a calibration to stdout.\n"); 34 35 P(" slambatch - Runs a sequence of EuRoC datasets with the SLAM tracker.\n"); 35 36 36 37 return 1; ··· 54 55 return cli_cmd_calibrate(argc, argv); 55 56 } 56 57 #endif // !XRT_OS_WINDOWS 58 + if (strcmp(argv[1], "calib-dump") == 0) { 59 + return cli_cmd_calibration_dump(argc, argv); 60 + } 57 61 if (strcmp(argv[1], "lighthouse") == 0) { 58 62 return cli_cmd_lighthouse(argc, argv); 59 63 }