Monado OpenXR Runtime
xrt::auxiliary::tracking::NormalizedCoordsCache Class Reference

Provides cached, precomputed normalized image coordinates from original, distorted ones. More...

#include <tracking/t_calibration_opencv.hpp>

Public Member Functions

 NormalizedCoordsCache (cv::Size size, const cv::Matx33d &intrinsics, const cv::Matx< double, 5, 1 > &distortion)
 Set up the precomputed cache for a given camera. More...
 
 NormalizedCoordsCache (cv::Size size, const cv::Matx33d &intrinsics, const cv::Matx< double, 5, 1 > &distortion, const cv::Matx33d &rectification, const cv::Matx33d &new_camera_matrix)
 Set up the precomputed cache for a given camera (overload for rectification and new camera matrix) More...
 
 NormalizedCoordsCache (cv::Size size, const cv::Matx33d &intrinsics, const cv::Matx< double, 5, 1 > &distortion, const cv::Matx33d &rectification, const cv::Matx< double, 3, 4 > &new_projection_matrix)
 Set up the precomputed cache for a given camera. More...
 
 NormalizedCoordsCache (cv::Size size, const cv::Mat &intrinsics, const cv::Mat &distortion)
 Set up the precomputed cache for a given camera. More...
 
cv::Vec2f getNormalizedImageCoords (cv::Point2f origCoords) const
 Get normalized, undistorted coordinates from a point in the original (distorted, etc.) image. More...
 
cv::Vec3f getNormalizedVector (cv::Point2f origCoords) const
 Get normalized vector in the camera-space direction corresponding to the original (distorted, etc.) image coordinates. More...
 

Detailed Description

Provides cached, precomputed normalized image coordinates from original, distorted ones.

Populates internal structures using cv::undistortPoints() and performs subpixel sampling to interpolate for each query. Essentially, this class lets you perform cv::undistortPoints() while caching the initial setup work required for that function.

Constructor & Destructor Documentation

◆ NormalizedCoordsCache() [1/4]

xrt::auxiliary::tracking::NormalizedCoordsCache::NormalizedCoordsCache ( cv::Size  size,
const cv::Matx33d &  intrinsics,
const cv::Matx< double, 5, 1 > &  distortion 
)

Set up the precomputed cache for a given camera.

Parameters
sizeSize of the image in pixels
intrinsicsCamera intrinsics matrix
distortionDistortion coefficients

This overload applies no rectification (R) and uses a normalized/identity new camera matrix (P).

References xrt::auxiliary::tracking::generateInputCoordsAndReserveOutputCoords(), and xrt::auxiliary::tracking::populateCacheMats().

◆ NormalizedCoordsCache() [2/4]

xrt::auxiliary::tracking::NormalizedCoordsCache::NormalizedCoordsCache ( cv::Size  size,
const cv::Matx33d &  intrinsics,
const cv::Matx< double, 5, 1 > &  distortion,
const cv::Matx33d &  rectification,
const cv::Matx33d &  new_camera_matrix 
)

Set up the precomputed cache for a given camera (overload for rectification and new camera matrix)

Parameters
sizeSize of the image in pixels
intrinsicsCamera intrinsics matrix
distortionDistortion coefficients
rectificationRectification matrix - corresponds to parameter R to cv::undistortPoints().
new_camera_matrixA 3x3 new camera matrix - corresponds to parameter P to cv::undistortPoints().

References xrt::auxiliary::tracking::generateInputCoordsAndReserveOutputCoords(), and xrt::auxiliary::tracking::populateCacheMats().

◆ NormalizedCoordsCache() [3/4]

xrt::auxiliary::tracking::NormalizedCoordsCache::NormalizedCoordsCache ( cv::Size  size,
const cv::Matx33d &  intrinsics,
const cv::Matx< double, 5, 1 > &  distortion,
const cv::Matx33d &  rectification,
const cv::Matx< double, 3, 4 > &  new_projection_matrix 
)

Set up the precomputed cache for a given camera.

(overload for rectification and new projection matrix)

Parameters
sizeSize of the image in pixels
intrinsicsCamera intrinsics matrix
distortionDistortion coefficients
rectificationRectification matrix - corresponds to parameter R to cv::undistortPoints().
new_projection_matrixA 3x4 new projection matrix - corresponds to parameter P to cv::undistortPoints().

References xrt::auxiliary::tracking::generateInputCoordsAndReserveOutputCoords(), and xrt::auxiliary::tracking::populateCacheMats().

◆ NormalizedCoordsCache() [4/4]

xrt::auxiliary::tracking::NormalizedCoordsCache::NormalizedCoordsCache ( cv::Size  size,
const cv::Mat &  intrinsics,
const cv::Mat &  distortion 
)

Set up the precomputed cache for a given camera.

Less-strongly-typed overload.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This overload applies no rectification (R) and uses a normalized/identity new camera matrix (P).

References xrt::auxiliary::tracking::generateInputCoordsAndReserveOutputCoords(), and xrt::auxiliary::tracking::populateCacheMats().

Member Function Documentation

◆ getNormalizedImageCoords()

cv::Vec2f xrt::auxiliary::tracking::NormalizedCoordsCache::getNormalizedImageCoords ( cv::Point2f  origCoords) const

Get normalized, undistorted coordinates from a point in the original (distorted, etc.) image.

Parameters
origCoordsImage coordinates in original image
Returns
Corresponding undistorted coordinates in a "normalized" image

◆ getNormalizedVector()

cv::Vec3f xrt::auxiliary::tracking::NormalizedCoordsCache::getNormalizedVector ( cv::Point2f  origCoords) const

Get normalized vector in the camera-space direction corresponding to the original (distorted, etc.) image coordinates.

Note that the Z component will be negative by convention.


The documentation for this class was generated from the following files: