The open source OpenXR runtime
1// Copyright 2021 Jan Schmidt <jan@centricular.com>
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Interface to read WMR cameras
6 * @author Jan Schmidt <jan@centricular.com>
7 * @ingroup drv_wmr
8 */
9
10#pragma once
11
12#include "util/u_debug.h"
13#include "util/u_logging.h"
14#include "xrt/xrt_config_have.h"
15#include "xrt/xrt_frame.h"
16#include "xrt/xrt_prober.h"
17
18#include "wmr_config.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24struct wmr_camera;
25
26struct wmr_camera_open_config
27{
28 struct xrt_prober_device *dev_holo;
29 struct wmr_camera_config **tcam_confs; //!< Pointers to tracking cameras. Will be copied.
30 struct xrt_frame_sink **tcam_sinks; //!< Sinks for tracking cameras
31 int tcam_count; //!< Tracking camera count
32 int slam_cam_count; //!< Number of tracking cameras to use for SLAM
33 enum u_logging_level log_level;
34};
35
36#ifdef XRT_HAVE_LIBUSB
37struct wmr_camera *
38wmr_camera_open(struct wmr_camera_open_config *config);
39void
40wmr_camera_free(struct wmr_camera *cam);
41
42/*!
43 * Starts the cameras.
44 */
45bool
46wmr_camera_start(struct wmr_camera *cam);
47bool
48wmr_camera_stop(struct wmr_camera *cam);
49
50/*!
51 * Set manual exposure and gain values
52 *
53 * @param cam Camera container
54 * @param camera_id Which camera to affect
55 * @param exposure Time the shutter is open, observed values 60-6000.
56 * @param gain Amplification of the analog signal, observed values: 16-255.
57 */
58int
59wmr_camera_set_exposure_gain(struct wmr_camera *cam, uint8_t camera_id, uint16_t exposure, uint8_t gain);
60
61#else
62
63/* Stubs to disable camera functions without libusb */
64static inline struct wmr_camera *
65wmr_camera_open(struct wmr_camera_open_config *config)
66{
67 (void)config;
68 return NULL;
69}
70static inline void
71wmr_camera_free(struct wmr_camera *cam)
72{
73 (void)cam;
74}
75static inline bool
76wmr_camera_start(struct wmr_camera *cam)
77{
78 (void)cam;
79 return false;
80}
81static inline bool
82wmr_camera_stop(struct wmr_camera *cam)
83{
84 (void)cam;
85 return false;
86}
87static inline int
88wmr_camera_set_exposure_gain(struct wmr_camera *cam, uint8_t camera_id, uint16_t exposure, uint8_t gain)
89{
90 (void)cam;
91 (void)camera_id;
92 (void)exposure;
93 (void)gain;
94 return -1;
95}
96
97#endif
98
99#ifdef __cplusplus
100}
101#endif