Ocean
Loading...
Searching...
No Matches
cv/calibration/Utilities.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_CV_CALIBRATION_UTILITIES_H
9#define META_OCEAN_CV_CALIBRATION_UTILITIES_H
10
15
16#include "ocean/base/Frame.h"
17#include "ocean/base/Worker.h"
18
21
22namespace Ocean
23{
24
25namespace CV
26{
27
28namespace Calibration
29{
30
31/**
32 * This class implements utility functions for calibration.
33 * @ingroup cvcalibration
34 */
35class OCEAN_CV_CALIBRATION_EXPORT Utilities
36{
37 public:
38
39 /**
40 * Paints the outline of a calibration board.
41 * @param frame The frame to which the outline will be painted, must be valid
42 * @param camera The camera profile defining the projection, must be valid
43 * @param board_T_camera The camera pose transforming camera to board, with default camera looking towards the negative z-space with y-axis upwards, must be valid
44 * @param calibrationBoard The calibration board for which the outline will be painted, must be valid
45 * @param color The color of the outline, must be valid
46 * @param thickness The thickness of the outline, possible values are {1, 3, 5, 7}
47 * @return True, if succeeded
48 */
49 static bool paintCalibrationBoardOutline(Frame& frame, const AnyCamera& camera, const HomogenousMatrix4& board_T_camera, const MetricCalibrationBoard& calibrationBoard, const uint8_t* color, const unsigned int thickness = 1u);
50
51 /**
52 * Paints the observation information of a calibration board.
53 * @param frame The frame to which the observation information will be painted, must be valid
54 * @param calibrationBoard The calibration board for which the observation information will be painted, must be valid
55 * @param calibrationBoardObservation The observation information of the calibration board, must be valid
56 * @param drawCorrespondences True to draw the 2D/3D correspondences of the observation; False, to draw the projected 3D object points of all visible marker points
57 * @return True, if succeeded
58 */
59 static bool paintCalibrationBoardObservation(Frame& frame, const MetricCalibrationBoard& calibrationBoard, const CalibrationBoardObservation& calibrationBoardObservation, const bool drawCorrespondences);
60
61 /**
62 * Visualizes the distortion of a camera with a grid.
63 * @param camera The camera profile for which the distortion/undistortion is visualized, must be valid
64 * @param horizontalBins Number of horizontal bins, with range [1, camera.width() / 2u)
65 * @param verticalBins Number of vertical bins, with range [1, camera.height() / 2u)
66 * @param undistort True, to visualize the undistorted frame, otherwise the distorted frame is visualized
67 * @param worker Optional worker object to distribute the computation
68 * @return Resulting frame with visualized distortion/undistortion
69 */
70 static Frame visualizeDistortionGrid(const AnyCamera& camera, const unsigned int horizontalBins, const unsigned int verticalBins, const bool undistort, Worker* worker = nullptr);
71
72 /**
73 * Visualizes the distortion of a camera with displacement vectors.
74 * @param camera The camera profile for which the distortion is visualized, must be valid
75 * @param horizontalBins Number of horizontal bins, with range [1, camera.width() / 2]
76 * @param verticalBins Number of vertical bins, with range [1, camera.height() / 2]
77 * @return Resulting distortion frame with visualized distortion
78 */
79 static Frame visualizeDistortionVectors(const AnyCamera& camera, const unsigned int horizontalBins, const unsigned int verticalBins);
80
81 /**
82 * Parses the type of a calibration board from a string.
83 * The string must have the format 'calibrationBoard_<Id>_<HorizontalMarkers>x<VerticalMarkers> - e.g., 'calibrationBoard_0_8x13'
84 * @param calibrationBoardType The string with the calibration board type to parse
85 * @param calibrationBoard The resulting calibration board
86 * @return True, if succeeded
87 */
88 static bool parseCalibrationBoard(const std::string& calibrationBoardType, CalibrationBoard& calibrationBoard);
89
90 /**
91 * Parses the marker dimension from a string.
92 * The string must have the format '<HorizontalMarkers>x<VerticalMarkers>' - e.g., '8x13'
93 * @param markerDimension The string with the marker dimension to parse
94 * @param horizontalMarkers The resulting number of horizontal markers, with range [1, infinity)
95 * @param verticalMarkers The resulting number of vertical markers, with range [1, infinity)
96 * @return True, if succeeded
97 */
98 static bool parseMarkerDimension(const std::string& markerDimension, int32_t& horizontalMarkers, int32_t& verticalMarkers);
99
100 /**
101 * Returns an ideal calibration board for a specific paper type.
102 * @param paperType The type of the paper to be used, must be valid
103 * @param id The id of the calibration board, with range [0, infinity)
104 * @param paperWidth Optional resulting width of the paper, nullptr if not of interest
105 * @param paperHeight Optional resulting height of the paper, nullptr if not of interest
106 * @return The calibration board optimized for the specified paper type, invalid if the calibration board could not be created
107 */
108 static CalibrationBoard createBoardForPaper(const MetricSize::PaperType paperType, const unsigned int id, MetricSize* paperWidth = nullptr, MetricSize* paperHeight = nullptr);
109};
110
111}
112
113}
114
115}
116
117#endif // META_OCEAN_CV_CALIBRATION_MARKER_H
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
This class implements a basic calibration board.
Definition CalibrationBoard.h:38
This class implements an observation of a calibration board.
Definition CalibrationBoardObservation.h:45
This class extends the calibration board with metric information.
Definition MetricCalibrationBoard.h:39
This class implements an object holding a metric size like width, height, length, or thickness.
Definition MetricSize.h:32
PaperType
Definition of different paper types.
Definition MetricSize.h:52
This class implements utility functions for calibration.
Definition cv/calibration/Utilities.h:36
static bool parseCalibrationBoard(const std::string &calibrationBoardType, CalibrationBoard &calibrationBoard)
Parses the type of a calibration board from a string.
static bool paintCalibrationBoardOutline(Frame &frame, const AnyCamera &camera, const HomogenousMatrix4 &board_T_camera, const MetricCalibrationBoard &calibrationBoard, const uint8_t *color, const unsigned int thickness=1u)
Paints the outline of a calibration board.
static bool parseMarkerDimension(const std::string &markerDimension, int32_t &horizontalMarkers, int32_t &verticalMarkers)
Parses the marker dimension from a string.
static Frame visualizeDistortionGrid(const AnyCamera &camera, const unsigned int horizontalBins, const unsigned int verticalBins, const bool undistort, Worker *worker=nullptr)
Visualizes the distortion of a camera with a grid.
static Frame visualizeDistortionVectors(const AnyCamera &camera, const unsigned int horizontalBins, const unsigned int verticalBins)
Visualizes the distortion of a camera with displacement vectors.
static CalibrationBoard createBoardForPaper(const MetricSize::PaperType paperType, const unsigned int id, MetricSize *paperWidth=nullptr, MetricSize *paperHeight=nullptr)
Returns an ideal calibration board for a specific paper type.
static bool paintCalibrationBoardObservation(Frame &frame, const MetricCalibrationBoard &calibrationBoard, const CalibrationBoardObservation &calibrationBoardObservation, const bool drawCorrespondences)
Paints the observation information of a calibration board.
This class implements Ocean's image class.
Definition Frame.h:1808
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
The namespace covering the entire Ocean framework.
Definition Accessor.h:15