2019-10-22 17:45:25 +00:00
|
|
|
// Copyright 2019, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Code to generate disortion meshes.
|
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "xrt/xrt_device.h"
|
|
|
|
#include "xrt/xrt_defines.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Values to create a distortion mesh from panotools values.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
struct u_panotools_values
|
|
|
|
{
|
|
|
|
//! Panotools universal distortion k (reverse order from OpenHMD).
|
|
|
|
float distortion_k[5];
|
|
|
|
//! Panotools post distortion scale, <r, g, b>.
|
|
|
|
float aberration_k[3];
|
|
|
|
//! Panotools warp scale.
|
|
|
|
float scale;
|
|
|
|
//! Center of the lens.
|
|
|
|
struct xrt_vec2 lens_center;
|
|
|
|
//! Viewport size.
|
|
|
|
struct xrt_vec2 viewport_size;
|
|
|
|
};
|
|
|
|
|
2020-09-29 01:55:38 +00:00
|
|
|
/*!
|
|
|
|
* Values to create a distortion mesh from Vive configuration values.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
struct u_vive_values
|
|
|
|
{
|
|
|
|
float aspect_x_over_y;
|
|
|
|
float grow_for_undistort;
|
|
|
|
|
|
|
|
//! Left/right
|
2020-09-29 17:08:21 +00:00
|
|
|
float undistort_r2_cutoff;
|
2020-09-29 01:55:38 +00:00
|
|
|
|
|
|
|
//! Left/right, x/y
|
2020-09-29 17:08:21 +00:00
|
|
|
float center[2];
|
2020-09-29 01:55:38 +00:00
|
|
|
|
|
|
|
//! left/right, r/g/b, a/b/c
|
2020-09-29 17:08:21 +00:00
|
|
|
float coefficients[3][3];
|
2020-09-29 01:55:38 +00:00
|
|
|
};
|
|
|
|
|
2019-10-22 17:45:25 +00:00
|
|
|
/*!
|
2020-08-12 18:32:07 +00:00
|
|
|
* Distortion correction implementation for Panotools distortion values.
|
2019-10-24 14:01:04 +00:00
|
|
|
*
|
2020-01-26 16:00:14 +00:00
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2020-08-12 18:32:07 +00:00
|
|
|
bool
|
|
|
|
u_compute_distortion_panotools(struct u_panotools_values *values,
|
|
|
|
float u,
|
|
|
|
float v,
|
2020-09-30 14:35:57 +00:00
|
|
|
struct xrt_uv_triplet *result);
|
2020-01-26 16:00:14 +00:00
|
|
|
|
2020-09-29 17:08:21 +00:00
|
|
|
/*!
|
|
|
|
* Distortion correction implementation for the Vive, Vive Pro, Valve Index
|
|
|
|
* distortion values found in the HMD configuration.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
u_compute_distortion_vive(struct u_vive_values *values,
|
|
|
|
float u,
|
|
|
|
float v,
|
2020-09-30 14:35:57 +00:00
|
|
|
struct xrt_uv_triplet *result);
|
2020-09-29 17:08:21 +00:00
|
|
|
|
2020-01-26 16:00:14 +00:00
|
|
|
/*!
|
2020-08-12 18:32:07 +00:00
|
|
|
* Identity distortion correction sets all result coordinates to u,v.
|
2019-10-22 17:45:25 +00:00
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
2020-08-12 18:32:07 +00:00
|
|
|
bool
|
2020-09-30 14:35:57 +00:00
|
|
|
u_compute_distortion_none(float u, float v, struct xrt_uv_triplet *result);
|
2019-10-22 17:45:25 +00:00
|
|
|
|
|
|
|
/*!
|
2020-08-12 18:32:07 +00:00
|
|
|
* Given a @ref xrt_device generates meshes by calling
|
|
|
|
* xdev->compute_distortion(), populates xdev->hmd_parts.distortion.mesh
|
2019-10-22 17:45:25 +00:00
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
2020-08-12 18:32:07 +00:00
|
|
|
* @relatesalso xrt_device
|
2019-10-22 17:45:25 +00:00
|
|
|
*/
|
|
|
|
void
|
2020-08-12 18:32:07 +00:00
|
|
|
u_compute_distortion_mesh(struct xrt_device *xdev);
|
2019-10-22 17:45:25 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|