mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-21 06:01:43 +00:00
t/calibration: Make it possible to select number distortion parameters
This commit is contained in:
parent
9aff6fb9b3
commit
dbb6b1f43c
|
@ -519,7 +519,7 @@ process_stereo_samples(class Calibration &c, int cols, int rows)
|
|||
cv::Size image_size(cols, rows);
|
||||
cv::Size new_image_size(cols, rows);
|
||||
|
||||
StereoCameraCalibrationWrapper wrapped = {};
|
||||
StereoCameraCalibrationWrapper wrapped = {5}; // We only use five distortion parameters.
|
||||
wrapped.view[0].image_size_pixels.w = image_size.width;
|
||||
wrapped.view[0].image_size_pixels.h = image_size.height;
|
||||
wrapped.view[1].image_size_pixels = wrapped.view[0].image_size_pixels;
|
||||
|
|
|
@ -42,7 +42,7 @@ struct CameraCalibrationWrapper
|
|||
: base(calib), image_size_pixels(calib.image_size_pixels),
|
||||
image_size_pixels_cv(calib.image_size_pixels.w, calib.image_size_pixels.h),
|
||||
intrinsics_mat(3, 3, &calib.intrinsics[0][0]),
|
||||
distortion_mat(XRT_DISTORTION_MAX_DIM, 1, &calib.distortion[0]),
|
||||
distortion_mat(base.distortion_num, 1, &calib.distortion[0]),
|
||||
distortion_fisheye_mat(4, 1, &calib.distortion_fisheye[0]), use_fisheye(calib.use_fisheye)
|
||||
{
|
||||
assert(isDataStorageValid());
|
||||
|
@ -55,7 +55,7 @@ struct CameraCalibrationWrapper
|
|||
return intrinsics_mat.size() == cv::Size(3, 3) &&
|
||||
(double *)intrinsics_mat.data == &(base.intrinsics[0][0]) &&
|
||||
|
||||
distortion_mat.size() == cv::Size(1, XRT_DISTORTION_MAX_DIM) &&
|
||||
distortion_mat.size() == cv::Size(1, base.distortion_num) &&
|
||||
(double *)distortion_mat.data == &(base.distortion[0]) &&
|
||||
|
||||
distortion_fisheye_mat.size() == cv::Size(1, 4) &&
|
||||
|
@ -81,10 +81,10 @@ struct StereoCameraCalibrationWrapper
|
|||
|
||||
|
||||
static t_stereo_camera_calibration *
|
||||
allocData()
|
||||
allocData(uint32_t distortion_num)
|
||||
{
|
||||
t_stereo_camera_calibration *data_ptr = NULL;
|
||||
t_stereo_camera_calibration_alloc(&data_ptr);
|
||||
t_stereo_camera_calibration_alloc(&data_ptr, distortion_num);
|
||||
return data_ptr;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,8 @@ struct StereoCameraCalibrationWrapper
|
|||
assert(isDataStorageValid());
|
||||
}
|
||||
|
||||
StereoCameraCalibrationWrapper() : StereoCameraCalibrationWrapper(allocData())
|
||||
StereoCameraCalibrationWrapper(uint32_t distortion_num)
|
||||
: StereoCameraCalibrationWrapper(allocData(distortion_num))
|
||||
{
|
||||
|
||||
// The function allocData returns with a ref count of one,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2019-2020, Collabora, Ltd.
|
||||
// Copyright 2019-2021, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
|
@ -11,12 +11,17 @@
|
|||
#include "util/u_misc.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
void
|
||||
t_stereo_camera_calibration_alloc(struct t_stereo_camera_calibration **out_c)
|
||||
t_stereo_camera_calibration_alloc(struct t_stereo_camera_calibration **out_c, uint32_t distortion_num)
|
||||
{
|
||||
assert(distortion_num == 5 || distortion_num == 14);
|
||||
|
||||
struct t_stereo_camera_calibration *c = U_TYPED_CALLOC(struct t_stereo_camera_calibration);
|
||||
c->view[0].distortion_num = distortion_num;
|
||||
c->view[1].distortion_num = distortion_num;
|
||||
t_stereo_camera_calibration_reference(out_c, c);
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ t_stereo_camera_calibration_load_v1(FILE *calib_file, struct t_stereo_camera_cal
|
|||
{
|
||||
using xrt::auxiliary::tracking::StereoCameraCalibrationWrapper;
|
||||
t_stereo_camera_calibration *data_ptr = NULL;
|
||||
t_stereo_camera_calibration_alloc(&data_ptr);
|
||||
t_stereo_camera_calibration_alloc(&data_ptr, 5); // Hardcoded to 5 distortion parameters.
|
||||
StereoCameraCalibrationWrapper wrapped(data_ptr);
|
||||
|
||||
// Dummy matrix
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2019-2020, Collabora, Ltd.
|
||||
// Copyright 2019-2021, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
|
@ -45,7 +45,7 @@ struct xrt_tracked_hand;
|
|||
*/
|
||||
|
||||
//! Maximum size of rectilinear distortion coefficient array
|
||||
#define XRT_DISTORTION_MAX_DIM (5)
|
||||
#define XRT_DISTORTION_MAX_DIM (14)
|
||||
|
||||
/*!
|
||||
* @brief Essential calibration data for a single camera, or single lens/sensor
|
||||
|
@ -59,8 +59,10 @@ struct t_camera_calibration
|
|||
//! Camera intrinsics matrix
|
||||
double intrinsics[3][3];
|
||||
|
||||
//! Rectilinear distortion coefficients: k1, k2, p1, p2[, k3[, k4, k5,
|
||||
//! k6[, s1, s2, s3, s4]]
|
||||
//! Number of distortion parameters (non-fisheye).
|
||||
size_t distortion_num;
|
||||
|
||||
//! Rectilinear distortion coefficients: k1, k2, p1, p2[, k3[, k4, k5, k6[, s1, s2, s3, s4[, Tx, Ty]]]]
|
||||
double distortion[XRT_DISTORTION_MAX_DIM];
|
||||
|
||||
//! Fisheye camera distortion coefficients
|
||||
|
@ -95,10 +97,12 @@ struct t_stereo_camera_calibration
|
|||
/*!
|
||||
* Allocates a new stereo calibration data, unreferences the old @p calib.
|
||||
*
|
||||
* Also initializes view[s]::distortion_num, only 5 and 14 is accepted.
|
||||
*
|
||||
* @public @memberof t_stereo_camera_calibration
|
||||
*/
|
||||
void
|
||||
t_stereo_camera_calibration_alloc(struct t_stereo_camera_calibration **calib);
|
||||
t_stereo_camera_calibration_alloc(struct t_stereo_camera_calibration **calib, uint32_t distortion_num);
|
||||
|
||||
/*!
|
||||
* Only to be called by @p t_stereo_camera_calibration_reference.
|
||||
|
|
Loading…
Reference in a new issue