···3434 default: return t_num_params_from_distortion_model(model);
3535 }
3636}
3737+3838+/*!
3939+ * @brief Determines whether a camera distortion model is suitable for use in OpenCV as a fisheye distortion.
4040+ *
4141+ * @param model The distortion model in question.
4242+ */
4343+static inline bool
4444+t_camera_distortion_model_is_opencv_fisheye(const enum t_camera_distortion_model model)
4545+{
4646+ return model == T_DISTORTION_FISHEYE_KB4;
4747+}
4848+4949+/*!
5050+ * @brief Determines whether a camera distortion model is suitable for use in OpenCV as a non-fisheye distortion.
5151+ *
5252+ * @param model The distortion model in question.
5353+ */
5454+static inline bool
5555+t_camera_distortion_model_is_opencv_non_fisheye(const enum t_camera_distortion_model model)
5656+{
5757+ switch (model) {
5858+ case T_DISTORTION_OPENCV_RADTAN_5:
5959+ case T_DISTORTION_OPENCV_RADTAN_8:
6060+ case T_DISTORTION_OPENCV_RADTAN_14:
6161+ // @note WMR is not supported by OpenCV, but we re-interpret it into a format which is, so this is also valid.
6262+ case T_DISTORTION_WMR: return true;
6363+ default: return false;
6464+ }
6565+}
6666+3767/*!
3868 * @brief Essential calibration data wrapped for C++.
3969 *
+11-12
src/xrt/auxiliary/tracking/t_file.cpp
···1010 */
11111212#include "tracking/t_calibration_opencv.hpp"
1313+#include "tracking/t_tracking.h"
1314#include "util/u_misc.h"
1415#include "util/u_logging.h"
1516#include "util/u_json.hpp"
···8283 // calibration for does not match what was saved
8384 cv::Size image_size(calib.image_size_pixels.w, calib.image_size_pixels.h);
84858585- switch (calib.distortion_model) {
8686- case (T_DISTORTION_FISHEYE_KB4):
8686+ if (t_camera_distortion_model_is_opencv_fisheye(wrap.distortion_model)) {
8787 cv::fisheye::initUndistortRectifyMap(wrap.intrinsics_mat, // cameraMatrix
8888 wrap.distortion_mat, // distCoeffs
8989 rectify_transform_optional, // R
···9292 CV_32FC1, // m1type
9393 ret.remap_x, // map1
9494 ret.remap_y); // map2
9595- break;
9696- case T_DISTORTION_OPENCV_RADTAN_5:
9595+ } else if (t_camera_distortion_model_is_opencv_non_fisheye(wrap.distortion_model)) {
9796 cv::initUndistortRectifyMap(wrap.intrinsics_mat, // cameraMatrix
9897 wrap.distortion_mat, // distCoeffs
9998 rectify_transform_optional, // R
···102101 CV_32FC1, // m1type
103102 ret.remap_x, // map1
104103 ret.remap_y); // map2
105105- break;
106106- default: assert(false);
104104+ } else {
105105+ assert(!"Unsupported distortion model");
107106 }
108107109108 return ret;
···120119 cv::Size image_size(data->view[0].image_size_pixels.w, data->view[0].image_size_pixels.h);
121120 StereoCameraCalibrationWrapper wrapped(data);
122121122122+ t_camera_distortion_model distortion_model = data->view[0].distortion_model;
123123+123124 /*
124125 * Generate our rectification maps
125126 *
126127 * Here cv::noArray() means zero distortion.
127128 */
128128- switch (data->view[0].distortion_model) {
129129- case T_DISTORTION_FISHEYE_KB4: {
129129+ if (t_camera_distortion_model_is_opencv_fisheye(distortion_model)) {
130130#if 0
131131 //! @todo for some reason this looks weird?
132132 // Alpha of 1.0 kinda works, not really.
···175175 NULL, // validPixROI1
176176 NULL); // validPixROI2
177177#endif
178178- } break;
179179- case T_DISTORTION_OPENCV_RADTAN_5: {
178178+ } else if (t_camera_distortion_model_is_opencv_non_fisheye(distortion_model)) {
180179 // Have the same principal point on both.
181180 int flags = cv::CALIB_ZERO_DISPARITY;
182181 // Get all of the pixels from the camera.
···201200 cv::Size(), // newImageSize
202201 NULL, // validPixROI1
203202 NULL); // validPixROI2
204204- } break;
205205- default: assert(false);
203203+ } else {
204204+ assert(!"Unsupported distortion model");
206205 }
207206208207 view[0].rectify = calibration_get_undistort_map(data->view[0], view[0].rotation_mat, view[0].projection_mat);
+13
src/xrt/auxiliary/tracking/t_tracking.h
···170170 }
171171}
172172173173+static inline bool
174174+t_camera_distortion_model_is_fisheye(enum t_camera_distortion_model model)
175175+{
176176+ switch (model) {
177177+ case T_DISTORTION_FISHEYE_KB4: return true;
178178+ case T_DISTORTION_OPENCV_RADTAN_5:
179179+ case T_DISTORTION_OPENCV_RADTAN_8:
180180+ case T_DISTORTION_OPENCV_RADTAN_14:
181181+ case T_DISTORTION_WMR: return false;
182182+ default: U_LOG_E("Invalid distortion_model! %d", model); return false;
183183+ }
184184+}
185185+173186/*!
174187 * Parameters for @ref T_DISTORTION_OPENCV_RADTAN_5
175188 * @ingroup aux_tracking