Monado OpenXR Runtime
wmr_camera.h
Go to the documentation of this file.
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
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
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
u_logging_level
Logging level enum.
Definition: u_logging.h:43
Definition: wmr_config.h:106
Definition: wmr_camera.h:27
struct xrt_frame_sink ** tcam_sinks
Sinks for tracking cameras.
Definition: wmr_camera.h:30
int tcam_count
Tracking camera count.
Definition: wmr_camera.h:31
struct wmr_camera_config ** tcam_confs
Pointers to tracking cameras.
Definition: wmr_camera.h:29
int slam_cam_count
Number of tracking cameras to use for SLAM.
Definition: wmr_camera.h:32
Definition: wmr_camera.c:88
A object that is sent frames.
Definition: xrt_frame.h:58
A probed device, may or may not be opened.
Definition: xrt_prober.h:85
Small debug helpers.
Basic logging functionality.
__le16 exposure
observed 60 to 6000 (but supports up to ~9000)
Definition: wmr_camera.c:4
__le16 gain
observed 16 to 255
Definition: wmr_camera.c:5
int wmr_camera_set_exposure_gain(struct wmr_camera *cam, uint8_t camera_id, uint16_t exposure, uint8_t gain)
Set manual exposure and gain values.
Definition: wmr_camera.c:704
bool wmr_camera_start(struct wmr_camera *cam)
Starts the cameras.
Definition: wmr_camera.c:577
WMR and MS HoloLens configuration structures.
Data frame header.
Common interface to probe for devices.