Monado OpenXR Runtime
t_calibration.cpp File Reference

Calibration code. More...

#include "util/u_sink.h"
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "util/u_frame.h"
#include "util/u_format.h"
#include "util/u_logging.h"
#include "tracking/t_tracking.h"
#include "tracking/t_calibration_opencv.hpp"
#include <opencv2/opencv.hpp>
#include <sys/stat.h>
#include <utility>
Include dependency graph for t_calibration.cpp:

Data Structures

struct  xrt::auxiliary::tracking::ViewState
 Current state for each view, one view for mono cameras, two for stereo. More...
 
class  xrt::auxiliary::tracking::Calibration
 Main class for doing calibration. More...
 

Macros

#define P(...)   snprintf(c.text, sizeof(c.text), __VA_ARGS__)
 

Typedefs

typedef std::vector< cv::Point3f > xrt::auxiliary::tracking::ModelF32
 Model of the thing we are measuring to calibrate, 32 bit. More...
 
typedef std::vector< cv::Point3d > xrt::auxiliary::tracking::ModelF64
 Model of the thing we are measuring to calibrate, 64 bit. More...
 
typedef std::vector< cv::Point2f > xrt::auxiliary::tracking::MeasurementF32
 A measurement of the model as viewed on the camera. More...
 
typedef std::vector< cv::Point2d > xrt::auxiliary::tracking::MeasurementF64
 In doubles, because OpenCV can't agree on a single type to use. More...
 
typedef std::vector< ModelF32 > xrt::auxiliary::tracking::ArrayOfModelF32s
 For each MeasurementF32 we take we also save the ModelF32. More...
 
typedef std::vector< ModelF64 > xrt::auxiliary::tracking::ArrayOfModelF64s
 For each MeasurementF64 we take we also save the ModelF64. More...
 
typedef std::vector< MeasurementF32 > xrt::auxiliary::tracking::ArrayOfMeasurementF32s
 A array of MeasurementF32. More...
 
typedef std::vector< MeasurementF64 > xrt::auxiliary::tracking::ArrayOfMeasurementF64s
 A array of MeasurementF64. More...
 
typedef std::vector< cv::Rect > xrt::auxiliary::tracking::ArrayOfRects
 A array of bounding rects. More...
 

Functions

static void xrt::auxiliary::tracking::to_stdout (const char *name, const cv::Mat &mat)
 
static void xrt::auxiliary::tracking::refresh_gui_frame (class Calibration &c, int rows, int cols)
 
static void xrt::auxiliary::tracking::send_rgb_frame (class Calibration &c)
 
static void xrt::auxiliary::tracking::ensure_buffers_are_allocated (class Calibration &c, int rows, int cols)
 
static void xrt::auxiliary::tracking::print_txt (cv::Mat &rgb, const char *text, double fontScale)
 
static void xrt::auxiliary::tracking::make_gui_str (class Calibration &c)
 
static void xrt::auxiliary::tracking::draw_rect (cv::Mat &rgb, const cv::Rect &rect, const cv::Scalar &colour)
 Simple helper to draw a bounding rect. More...
 
static void xrt::auxiliary::tracking::do_view_coverage (class Calibration &c, struct ViewState &view, cv::Mat &gray, cv::Mat &rgb, bool found)
 
static bool xrt::auxiliary::tracking::do_view_chess (class Calibration &c, struct ViewState &view, cv::Mat &gray, cv::Mat &rgb)
 
static bool xrt::auxiliary::tracking::do_view_circles (class Calibration &c, struct ViewState &view, cv::Mat &gray, cv::Mat &rgb)
 
static bool xrt::auxiliary::tracking::do_view (class Calibration &c, struct ViewState &view, cv::Mat &gray, cv::Mat &rgb)
 
static void xrt::auxiliary::tracking::remap_view (class Calibration &c, struct ViewState &view, cv::Mat &rgb)
 
static void xrt::auxiliary::tracking::build_board_position (class Calibration &c)
 
static void xrt::auxiliary::tracking::push_model (Calibration &c)
 
static void xrt::auxiliary::tracking::push_measurement (ViewState &view)
 
static bool xrt::auxiliary::tracking::has_measurement_moved (MeasurementF64 &last, MeasurementF64 &current)
 Returns true if any one of the measurement points have moved. More...
 
static bool xrt::auxiliary::tracking::moved_state_check (struct ViewState &view)
 
static XRT_NO_INLINE void xrt::auxiliary::tracking::process_stereo_samples (class Calibration &c, int cols, int rows)
 
static void xrt::auxiliary::tracking::process_view_samples (class Calibration &c, struct ViewState &view, int cols, int rows)
 
static void xrt::auxiliary::tracking::update_public_status (class Calibration &c, bool found)
 
static void xrt::auxiliary::tracking::do_capture_logic_mono (class Calibration &c, struct ViewState &view, bool found, cv::Mat &gray, cv::Mat &rgb)
 Logic for capturing a frame. More...
 
static void xrt::auxiliary::tracking::do_capture_logic_stereo (class Calibration &c, cv::Mat &gray, cv::Mat &rgb, bool l_found, struct ViewState &l_view, cv::Mat &l_gray, cv::Mat &l_rgb, bool r_found, struct ViewState &r_view, cv::Mat &r_gray, cv::Mat &r_rgb)
 Capture logic for stereo frames. More...
 
static void xrt::auxiliary::tracking::make_calibration_frame_mono (class Calibration &c)
 Make a mono frame. More...
 
static void xrt::auxiliary::tracking::make_calibration_frame_sbs (class Calibration &c)
 Make a stereo frame side by side. More...
 
static void xrt::auxiliary::tracking::make_calibration_frame (class Calibration &c, struct xrt_frame *xf)
 
static void xrt::auxiliary::tracking::make_remap_view (class Calibration &c, struct xrt_frame *xf)
 
static XRT_NO_INLINE void xrt::auxiliary::tracking::process_frame_l8 (class Calibration &c, struct xrt_frame *xf)
 
static XRT_NO_INLINE void xrt::auxiliary::tracking::process_frame_yuv (class Calibration &c, struct xrt_frame *xf)
 
static XRT_NO_INLINE void xrt::auxiliary::tracking::process_frame_yuyv (class Calibration &c, struct xrt_frame *xf)
 
static XRT_NO_INLINE void xrt::auxiliary::tracking::process_frame_uyvy (class Calibration &c, struct xrt_frame *xf)
 
static XRT_NO_INLINE void xrt::auxiliary::tracking::process_frame_rgb (class Calibration &c, struct xrt_frame *xf)
 
static XRT_NO_INLINE void xrt::auxiliary::tracking::process_load_image (class Calibration &c, struct xrt_frame *xf)
 
void xrt::auxiliary::tracking::t_calibration_frame (struct xrt_frame_sink *xsink, struct xrt_frame *xf)
 
int xrt::auxiliary::tracking::t_calibration_stereo_create (struct xrt_frame_context *xfctx, const struct t_calibration_params *params, struct t_calibration_status *status, struct xrt_frame_sink *gui, struct xrt_frame_sink **out_sink)
 
static std::vector< cv::Vec2f > xrt::auxiliary::tracking::generateInputCoordsAndReserveOutputCoords (const cv::Size &size, std::vector< cv::Vec2f > &outputCoords)
 Helper for NormalizedCoordsCache constructors. More...
 
static void xrt::auxiliary::tracking::populateCacheMats (const cv::Size &size, const std::vector< cv::Vec2f > &inputCoords, const std::vector< cv::Vec2f > &outputCoords, cv::Mat_< float > &cacheX, cv::Mat_< float > &cacheY)
 Helper for NormalizedCoordsCache constructors. More...
 

Detailed Description

Typedef Documentation

◆ ArrayOfMeasurementF32s

typedef std::vector<MeasurementF32> xrt::auxiliary::tracking::ArrayOfMeasurementF32s

A array of MeasurementF32.

◆ ArrayOfMeasurementF64s

typedef std::vector<MeasurementF64> xrt::auxiliary::tracking::ArrayOfMeasurementF64s

A array of MeasurementF64.

◆ ArrayOfModelF32s

typedef std::vector<ModelF32> xrt::auxiliary::tracking::ArrayOfModelF32s

For each MeasurementF32 we take we also save the ModelF32.

◆ ArrayOfModelF64s

typedef std::vector<ModelF64> xrt::auxiliary::tracking::ArrayOfModelF64s

For each MeasurementF64 we take we also save the ModelF64.

◆ ArrayOfRects

typedef std::vector<cv::Rect> xrt::auxiliary::tracking::ArrayOfRects

A array of bounding rects.

◆ MeasurementF32

typedef std::vector<cv::Point2f> xrt::auxiliary::tracking::MeasurementF32

A measurement of the model as viewed on the camera.

◆ MeasurementF64

typedef std::vector<cv::Point2d> xrt::auxiliary::tracking::MeasurementF64

In doubles, because OpenCV can't agree on a single type to use.

◆ ModelF32

typedef std::vector<cv::Point3f> xrt::auxiliary::tracking::ModelF32

Model of the thing we are measuring to calibrate, 32 bit.

◆ ModelF64

typedef std::vector<cv::Point3d> xrt::auxiliary::tracking::ModelF64

Model of the thing we are measuring to calibrate, 64 bit.

Function Documentation

◆ do_capture_logic_mono()

static void xrt::auxiliary::tracking::do_capture_logic_mono ( class Calibration c,
struct ViewState view,
bool  found,
cv::Mat &  gray,
cv::Mat &  rgb 
)
static

◆ do_capture_logic_stereo()

static void xrt::auxiliary::tracking::do_capture_logic_stereo ( class Calibration c,
cv::Mat &  gray,
cv::Mat &  rgb,
bool  l_found,
struct ViewState l_view,
cv::Mat &  l_gray,
cv::Mat &  l_rgb,
bool  r_found,
struct ViewState r_view,
cv::Mat &  r_gray,
cv::Mat &  r_rgb 
)
static

◆ draw_rect()

static void xrt::auxiliary::tracking::draw_rect ( cv::Mat &  rgb,
const cv::Rect &  rect,
const cv::Scalar &  colour 
)
static

Simple helper to draw a bounding rect.

References xrt::auxiliary::tracking::draw_rect().

Referenced by xrt::auxiliary::tracking::draw_rect().

◆ generateInputCoordsAndReserveOutputCoords()

static std::vector< cv::Vec2f > xrt::auxiliary::tracking::generateInputCoordsAndReserveOutputCoords ( const cv::Size &  size,
std::vector< cv::Vec2f > &  outputCoords 
)
inlinestatic

◆ has_measurement_moved()

static bool xrt::auxiliary::tracking::has_measurement_moved ( MeasurementF64 last,
MeasurementF64 current 
)
static

Returns true if any one of the measurement points have moved.

References xrt::auxiliary::tracking::has_measurement_moved().

Referenced by xrt::auxiliary::tracking::has_measurement_moved().

◆ make_calibration_frame_mono()

static void xrt::auxiliary::tracking::make_calibration_frame_mono ( class Calibration c)
static

◆ make_calibration_frame_sbs()

static void xrt::auxiliary::tracking::make_calibration_frame_sbs ( class Calibration c)
static

◆ populateCacheMats()

static void xrt::auxiliary::tracking::populateCacheMats ( const cv::Size &  size,
const std::vector< cv::Vec2f > &  inputCoords,
const std::vector< cv::Vec2f > &  outputCoords,
cv::Mat_< float > &  cacheX,
cv::Mat_< float > &  cacheY 
)
inlinestatic