t/cli: Add calib-dump command

This commit is contained in:
Jakob Bornecrantz 2023-01-29 01:34:35 +00:00
parent 7d72b74a68
commit 17a14d5b10
4 changed files with 61 additions and 1 deletions

View file

@ -6,6 +6,7 @@
add_executable(
cli
cli_cmd_calibration_dump.c
cli_cmd_lighthouse.c
cli_cmd_probe.c
cli_cmd_slambatch.c
@ -20,6 +21,10 @@ if(NOT WIN32)
target_sources(cli PRIVATE cli_cmd_calibrate.c)
endif()
if(XRT_HAVE_OPENCV)
target_link_libraries(cli PRIVATE aux_tracking)
endif()
set_target_properties(cli PROPERTIES OUTPUT_NAME monado-cli PREFIX "")
target_link_libraries(

View file

@ -0,0 +1,48 @@
// Copyright 2019-2023, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Loads and dumps a calibration file.
* @author Jakob Bornecrantz <jakob@collabora.com>
*/
#include "xrt/xrt_compiler.h"
#include "xrt/xrt_config_have.h"
#include "cli_common.h"
#ifdef XRT_HAVE_OPENCV
#include "tracking/t_tracking.h"
#endif
#include <string.h>
#include <stdio.h>
#define P(...) fprintf(stderr, __VA_ARGS__)
int
cli_cmd_calibration_dump(int argc, const char **argv)
{
#ifdef XRT_HAVE_OPENCV
if (argc < 3) {
P("Must be given a file path\n");
return 1;
}
const char *filename = argv[2];
struct t_stereo_camera_calibration *data = NULL;
if (!t_stereo_camera_calibration_load(filename, &data)) {
P("Could not load '%s'!\n", filename);
return 1;
}
t_stereo_camera_calibration_dump(data);
t_stereo_camera_calibration_reference(&data, NULL);
return 0;
#else
P("Not compiled with XRT_HAVE_OPENCV, so can't load calibration files!\n");
return 1;
#endif
}

View file

@ -17,6 +17,9 @@ extern "C" {
int
cli_cmd_calibrate(int argc, const char **argv);
int
cli_cmd_calibration_dump(int argc, const char **argv);
int
cli_cmd_lighthouse(int argc, const char **argv);

View file

@ -24,13 +24,14 @@ cli_print_help(int argc, const char **argv)
}
P("Monado-CLI 0.0.1\n");
P("Usage: %s command [options]\n", argv[0]);
P("Usage: %s command [options] [file]\n", argv[0]);
P("\n");
P("Commands:\n");
P(" test - List found devices, for prober testing.\n");
P(" probe - Just probe and then exit.\n");
P(" lighthouse - Control the power of lighthouses [on|off].\n");
P(" calibrate - Calibrate a camera and save config (not implemented yet).\n");
P(" calib-dumb - Load and dump a calibration to stdout.\n");
P(" slambatch - Runs a sequence of EuRoC datasets with the SLAM tracker.\n");
return 1;
@ -54,6 +55,9 @@ main(int argc, const char **argv)
return cli_cmd_calibrate(argc, argv);
}
#endif // !XRT_OS_WINDOWS
if (strcmp(argv[1], "calib-dump") == 0) {
return cli_cmd_calibration_dump(argc, argv);
}
if (strcmp(argv[1], "lighthouse") == 0) {
return cli_cmd_lighthouse(argc, argv);
}