tangled
alpha
login
or
join now
matrixfurry.com
/
monado
0
fork
atom
The open source OpenXR runtime
0
fork
atom
overview
issues
pulls
pipelines
t/cli: Add calib-dump command
Jakob Bornecrantz
3 years ago
17a14d5b
7d72b74a
+61
-1
4 changed files
expand all
collapse all
unified
split
src
xrt
targets
cli
CMakeLists.txt
cli_cmd_calibration_dump.c
cli_common.h
cli_main.c
+5
src/xrt/targets/cli/CMakeLists.txt
···
6
6
7
7
add_executable(
8
8
cli
9
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
22
+
endif()
23
23
+
24
24
+
if(XRT_HAVE_OPENCV)
25
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
1
+
// Copyright 2019-2023, Collabora, Ltd.
2
2
+
// SPDX-License-Identifier: BSL-1.0
3
3
+
/*!
4
4
+
* @file
5
5
+
* @brief Loads and dumps a calibration file.
6
6
+
* @author Jakob Bornecrantz <jakob@collabora.com>
7
7
+
*/
8
8
+
9
9
+
#include "xrt/xrt_compiler.h"
10
10
+
#include "xrt/xrt_config_have.h"
11
11
+
12
12
+
#include "cli_common.h"
13
13
+
14
14
+
#ifdef XRT_HAVE_OPENCV
15
15
+
#include "tracking/t_tracking.h"
16
16
+
#endif
17
17
+
18
18
+
#include <string.h>
19
19
+
#include <stdio.h>
20
20
+
21
21
+
#define P(...) fprintf(stderr, __VA_ARGS__)
22
22
+
23
23
+
int
24
24
+
cli_cmd_calibration_dump(int argc, const char **argv)
25
25
+
{
26
26
+
#ifdef XRT_HAVE_OPENCV
27
27
+
if (argc < 3) {
28
28
+
P("Must be given a file path\n");
29
29
+
return 1;
30
30
+
}
31
31
+
32
32
+
const char *filename = argv[2];
33
33
+
34
34
+
struct t_stereo_camera_calibration *data = NULL;
35
35
+
if (!t_stereo_camera_calibration_load(filename, &data)) {
36
36
+
P("Could not load '%s'!\n", filename);
37
37
+
return 1;
38
38
+
}
39
39
+
40
40
+
t_stereo_camera_calibration_dump(data);
41
41
+
t_stereo_camera_calibration_reference(&data, NULL);
42
42
+
43
43
+
return 0;
44
44
+
#else
45
45
+
P("Not compiled with XRT_HAVE_OPENCV, so can't load calibration files!\n");
46
46
+
return 1;
47
47
+
#endif
48
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
21
+
cli_cmd_calibration_dump(int argc, const char **argv);
22
22
+
23
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
27
-
P("Usage: %s command [options]\n", argv[0]);
27
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
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
58
+
if (strcmp(argv[1], "calib-dump") == 0) {
59
59
+
return cli_cmd_calibration_dump(argc, argv);
60
60
+
}
57
61
if (strcmp(argv[1], "lighthouse") == 0) {
58
62
return cli_cmd_lighthouse(argc, argv);
59
63
}