8#ifndef META_OCEAN_TRACKING_UTILITIES_H
9#define META_OCEAN_TRACKING_UTILITIES_H
81 static inline void paintLine(
Frame& frame,
const Vector2& startPosition,
const Vector2& stopPosition,
const uint8_t* color =
nullptr,
const bool subPixel =
true);
95 static inline void paintLines(
Frame& frame,
const Vector2* startPositions,
const Vector2* stopPositions,
const size_t numberLines,
const uint8_t* color =
nullptr,
Worker* worker =
nullptr,
const bool subPixel =
true,
const Vector2& offsetStartPositions =
Vector2(0, 0),
const Vector2& offsetStopPositions =
Vector2(0, 0));
107 template <
unsigned int tSize>
108 static inline void paintLines(
Frame& frame,
const Vector2* startPositions,
const Vector2* stopPositions,
const size_t numberLines,
const uint8_t* color =
nullptr,
Worker* worker =
nullptr);
122 template <
unsigned int tSizeForeground,
unsigned int tSizeBackground>
123 static inline void paintLines(
Frame& frame,
const Vector2* startPositions,
const Vector2* stopPositions,
const size_t numberLines,
const uint8_t* colorForeground =
nullptr,
const uint8_t* colorBackground =
nullptr,
Worker* worker =
nullptr);
135 template <
unsigned int tSize>
136 static inline void paintPaths(
Frame& frame,
const Vectors2* paths,
const size_t size,
const uint8_t* color =
nullptr,
Worker* worker =
nullptr);
151 template <
unsigned int tSize>
152 static inline void paintPaths(
Frame& frame,
const Vectors2* paths,
const size_t size,
const uint8_t* color0,
const uint8_t* color1,
const Scalar* factors,
Worker* worker =
nullptr);
161 template <
unsigned int tSize = 1u>
172 template <
unsigned int tSize = 1u>
184 template <
unsigned int tPo
intSize>
198 template <
unsigned int tPo
intSize>
225 template <
unsigned int tChannels>
226 static void paintFeaturePoint8BitPerChannel(uint8_t* frame,
const unsigned int width,
const unsigned int height,
const Vector2& position,
const Scalar radius,
const Scalar orientation,
const uint8_t* color,
const uint8_t* shadowColor,
const unsigned int framePaddingElements = 0u);
258 template <
unsigned int tChannels>
259 static inline void paintFeaturePoints8BitPerChannel(uint8_t* frame,
const unsigned int width,
const unsigned int height,
const Vector2* positions,
const Scalar* radii,
const Scalar* orientations,
const size_t size,
const uint8_t* color,
const uint8_t* shadowColor,
const Vector2& explicitOffset,
const unsigned int framePaddingElements,
Worker* worker =
nullptr);
283 template <
unsigned int tObjectPo
intSize,
unsigned int tImagePo
intSize>
284 static inline void paintCorrespondences(
Frame& frame,
const AnyCamera& camera,
const HomogenousMatrix4& model_T_camera,
const Vector3* objectPoints,
const Vector2* imagePoints,
const size_t correspondences,
const Scalar maxSqrError,
const uint8_t* colorValidObjectPoints,
const uint8_t* colorValidImagePoints,
const uint8_t* colorInvalidObjectPoints,
const uint8_t* colorInvalidImagePoints,
const bool drawObjectPoints =
true,
const bool drawImagePoints =
true,
const bool drawConnections =
true,
Worker* worker =
nullptr);
347 static bool paintCorrespondencesHomography(
const Frame& frame0,
const Frame& frame1,
const SquareMatrix3& points1_H_points0,
const Vector2* points0,
const Vector2* points1,
const size_t numberPoints,
const bool fullCoverage,
Frame& result,
const uint8_t* foregroundColor =
nullptr,
const uint8_t* backgroundColor =
nullptr,
const uint8_t* startColor =
nullptr,
Worker* worker =
nullptr);
366 static bool paintCorrespondencesOrientations(
const PinholeCamera& pinholeCamera,
const Frame& frame0,
const Frame& frame1,
const SquareMatrix3& orientation0,
const SquareMatrix3& orientation1,
const Vector2* points0,
const Vector2* points1,
const size_t numberPoints,
Frame& result,
const uint8_t* foregroundColor =
nullptr,
const uint8_t* backgroundColor =
nullptr,
const uint8_t* startColor =
nullptr,
Worker* worker =
nullptr);
377 static void paintPoints(
Frame& frame,
const Vector2* imagePoints,
const size_t number,
const unsigned int radius,
const uint8_t* colorInner =
nullptr,
const uint8_t* colorOuter =
nullptr);
394 static inline void paintPoints(
Frame& frame,
const HomogenousMatrix4& world_T_camera,
const PinholeCamera& pinholeCamera,
const Vector3* objectPoints,
const size_t numberObjectPoints,
const Vector2* imagePoints,
const size_t numberImagePoints,
const bool distortProjectedObjectPoints,
const unsigned int radiusObjectPoints,
const unsigned int radiusImagePoints,
const uint8_t* colorObjectPoints =
nullptr,
const uint8_t* colorImagePoints =
nullptr);
411 static void paintPointsIF(
Frame& frame,
const HomogenousMatrix4& flippedCamera_T_world,
const PinholeCamera& pinholeCamera,
const Vector3* objectPoints,
const size_t numberObjectPoints,
const Vector2* imagePoints,
const size_t numberImagePoints,
const bool distortProjectedObjectPoints,
const unsigned int radiusObjectPoints,
const unsigned int radiusImagePoints,
const uint8_t* colorObjectPoints =
nullptr,
const uint8_t* colorImagePoints =
nullptr);
464 template <
unsigned int tSize = 1u>
478 template <
unsigned int tSize = 1u>
492 template <
unsigned int tSize = 1u>
656 static bool alignFramesHomographyFullCoverage(
const Frame& fixedFrame,
const Frame& dynamicFrame,
const SquareMatrix3& dynamic_H_fixed,
Frame& result,
const bool blend,
Worker* worker =
nullptr,
unsigned int maximalWidth = 16384u,
const unsigned int maximalHeight = 16384u,
unsigned int* fixedFrameLeft =
nullptr,
unsigned int* fixedFrameTop =
nullptr,
Scalar* dynamicFrameLeft =
nullptr,
Scalar* dynamicFrameTop =
nullptr,
Frame* fullFixedFrame =
nullptr,
Frame* fullDynamicFrame =
nullptr);
671 static void visualizeDatabase(
const Database& database,
const Index32 poseId,
Frame& frame,
const uint8_t* colorImagePoints,
const uint8_t* colorImagePointsInstable,
const uint8_t* colorImagePointsStable,
const unsigned int maximalPathLength = 20u,
const unsigned int stablePathLength = 100u,
const SquareMatrix3& transformation =
SquareMatrix3(
true),
Worker* worker =
nullptr);
733 static inline void paintLinesSubset(
Frame* frame,
const Vector2* startPositions,
const Vector2* stopPositions,
const uint8_t* color,
const bool subPixel,
const Vector2* offsetStartPositions,
const Vector2* offsetStopPositions,
const unsigned int firstLine,
const unsigned int numberLines);
745 template <
unsigned int tSize>
746 static inline void paintLinesSubset(
Frame* frame,
const Vector2* startPositions,
const Vector2* stopPositions,
const uint8_t* color,
const unsigned int firstLine,
const unsigned int numberLines);
760 template <
unsigned int tSizeForeground,
unsigned int tSizeBackground>
761 static inline void paintLinesSubset(
Frame* frame,
const Vector2* startPositions,
const Vector2* stopPositions,
const uint8_t* colorForeground,
const uint8_t* colorBackground,
const unsigned int firstLine,
const unsigned int numberLines);
773 template <
unsigned int tSize>
774 static inline void paintPathsSubset(
Frame* frame,
const Vectors2* paths,
const uint8_t* color,
const unsigned int firstPath,
const unsigned int numberPaths);
789 template <
unsigned int tSize>
790 static inline void paintPathsAdvancedSubset(
Frame* frame,
const Vectors2* paths,
const uint8_t* color0,
const uint8_t* color1,
const Scalar* factors,
const unsigned int firstPath,
const unsigned int numberPaths);
801 template <
unsigned int tSize = 1u>
802 static inline void paintTrianglesSubset(
Frame* frame,
const Triangle2* triangles,
const uint8_t* color,
const unsigned int firstTriangle,
const unsigned int numberTriangles);
815 template <
unsigned int tSize = 1u>
827 template <
unsigned int tPo
intSize>
828 static inline void paintImagePointsSubset(
Frame* frame,
const Vector2* imagePoints,
const uint8_t* color,
const unsigned int firstImagePoint,
const unsigned int numberImagePoints);
841 template <
unsigned int tPo
intSize>
861 template <
unsigned int tChannels>
862 static inline void paintFeaturePoints8BitPerChannelSubset(uint8_t* frame,
const unsigned int width,
const unsigned int height,
const Vector2* positions,
const Scalar* radii,
const Scalar* orientations,
const uint8_t* color,
const uint8_t* shadowColor,
const Scalar offsetX,
const Scalar offsetY,
const unsigned int framePaddingElements,
const unsigned int firstFeaturePoint,
const unsigned int numberFeaturePoints);
887 template <
unsigned int tObjectPo
intSize,
unsigned int tImagePo
intSize>
888 static void paintCorrespondencesSubset(
Frame* frame,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_model,
const Vector3* objectPoints,
const Vector2* imagePoints,
const Scalar maxSqrError,
const uint8_t* colorValidObjectPoints,
const uint8_t* colorValidImagePoints,
const uint8_t* colorInvalidObjectPoints,
const uint8_t* colorInvalidImagePoints,
const bool drawObjectPoints,
const bool drawImagePoints,
const bool drawConnections,
const unsigned int firstCorrespondence,
const unsigned int numberCorrespondences);
897 template <
unsigned int tBlendChannel,
unsigned int tChannels>
898 static inline void blendPixel(uint8_t* pixel,
const uint8_t blendFactor);
915 if (numberLines == 0)
922 worker->
executeFunction(
Worker::Function::createStatic(&
paintLinesSubset, &frame, startPositions, stopPositions, color, subPixel, &offsetStartPositions, &offsetStopPositions, 0u, 0u), 0u, (
unsigned int)(numberLines));
926 paintLinesSubset(&frame, startPositions, stopPositions, color, subPixel, &offsetStartPositions, &offsetStopPositions, 0u, (
unsigned int)(numberLines));
930template <
unsigned int tSize>
933 if (numberLines == 0)
948template <
unsigned int tSizeForeground,
unsigned int tSizeBackground>
951 if (numberLines == 0)
958 worker->
executeFunction(
Worker::Function::createStatic(&
paintLinesSubset<tSizeForeground, tSizeBackground>, &frame, startPositions, stopPositions, foregroundColor, backgroundColor, 0u, 0u), 0u, (
unsigned int)numberLines);
966template <
unsigned int tSize>
984template <
unsigned int tSize>
1002template <
unsigned int tSize>
1008template <
unsigned int tSize>
1011 if (triangles.empty())
1026template <
unsigned int tPo
intSize>
1029 static_assert(tPointSize % 2u == 1u,
"Invalid point size!");
1046template <
unsigned int tPo
intSize>
1049 static_assert(tPointSize % 2u == 1u,
"Invalid point size!");
1071template <
unsigned int tChannels>
1074 ocean_assert(frame && width != 0u && height != 0u && color);
1082 const Vector3 rightBottom = rotation *
Vector3(radius, radius, 0);
1083 const Vector3 leftBottom = rotation *
Vector3(-radius, radius, 0);
1103template <
unsigned int tChannels>
1104inline void Utilities::paintFeaturePoints8BitPerChannel(uint8_t* frame,
const unsigned int width,
const unsigned int height,
const Vector2* positions,
const Scalar* radii,
const Scalar* orientations,
const size_t size,
const uint8_t* color,
const uint8_t* shadowColor,
const Vector2& explicitOffset,
const unsigned int framePaddingElements,
Worker* worker)
1106 static_assert(tChannels != 0u,
"Invalid channel number!");
1108 ocean_assert(frame && width != 0u && height != 0u);
1117 worker->
executeFunction(
Worker::Function::createStatic(&
paintFeaturePoints8BitPerChannelSubset<tChannels>, frame, width, height, positions, radii, orientations, color, shadowColor, explicitOffset.
x(), explicitOffset.
y(), framePaddingElements, 0u, 0u), 0u, (
unsigned int)(size), 11u, 12u, 20u);
1121 paintFeaturePoints8BitPerChannelSubset<tChannels>(frame, width, height, positions, radii, orientations, color, shadowColor, explicitOffset.
x(), explicitOffset.
y(), framePaddingElements, 0u, (
unsigned int)(size));
1125template <
unsigned int tObjectPo
intSize,
unsigned int tImagePo
intSize>
1126inline void Utilities::paintCorrespondences(
Frame& frame,
const AnyCamera& camera,
const HomogenousMatrix4& model_T_camera,
const Vector3* objectPoints,
const Vector2* imagePoints,
const size_t correspondences,
const Scalar maxSqrError,
const uint8_t* colorValidObjectPoints,
const uint8_t* colorValidImagePoints,
const uint8_t* colorInvalidObjectPoints,
const uint8_t* colorInvalidImagePoints,
const bool drawObjectPoints,
const bool drawImagePoints,
const bool drawConnections,
Worker* worker)
1128 static_assert(tObjectPointSize >= tImagePointSize,
"Invalid point size!");
1129 static_assert(tObjectPointSize % 2u == 1u,
"Invalid point size!");
1130 static_assert(tImagePointSize % 2u == 1u,
"Invalid point size!");
1132 if (correspondences == 0)
1141 worker->
executeFunction(
Worker::Function::createStatic(&
paintCorrespondencesSubset<tObjectPointSize, tImagePointSize>, &frame, &camera, &flippedCamera_T_model, objectPoints, imagePoints, maxSqrError, colorValidObjectPoints, colorValidImagePoints, colorInvalidObjectPoints, colorInvalidImagePoints, drawObjectPoints, drawImagePoints, drawConnections, 0u, 0u), 0u, (
unsigned int)correspondences);
1145 paintCorrespondencesSubset<tObjectPointSize, tImagePointSize>(&frame, &camera, &flippedCamera_T_model, objectPoints, imagePoints, maxSqrError, colorValidObjectPoints, colorValidImagePoints, colorInvalidObjectPoints, colorInvalidImagePoints, drawObjectPoints, drawImagePoints, drawConnections, 0u, (
unsigned int)correspondences);
1149inline void Utilities::paintPoints(
Frame& frame,
const HomogenousMatrix4& world_T_camera,
const PinholeCamera& pinholeCamera,
const Vector3* objectPoints,
const size_t numberObjectPoints,
const Vector2* imagePoints,
const size_t numberImagePoints,
const bool distortProjectedObjectPoints,
const unsigned int radiusObjectPoints,
const unsigned int radiusImagePoints,
const uint8_t* colorObjectPoints,
const uint8_t* colorImagePoints)
1151 paintPointsIF(frame,
PinholeCamera::standard2InvertedFlipped(world_T_camera), pinholeCamera, objectPoints, numberObjectPoints, imagePoints, numberImagePoints, distortProjectedObjectPoints, radiusObjectPoints, radiusImagePoints, colorObjectPoints, colorImagePoints);
1159template <
unsigned int tSize>
1165template <
unsigned int tSize>
1168 if (numberTriangles == 0)
1183template <
unsigned int tSize>
1186 ocean_assert(frame.
isValid());
1187 ocean_assert(flippedCamera_T_world.
isValid());
1188 ocean_assert(cameraClipper.
isValid());
1189 ocean_assert(triangle.
isValid());
1190 ocean_assert(segments >= 1);
1192 for (
unsigned int nSide = 0u; nSide < 3u; ++nSide)
1194 const Vector3& point0 = triangle[nSide];
1195 const Vector3& point1 = triangle[(nSide + 1u) % 3u];
1199 if (!cameraClipper.
projectToImageIF(flippedCamera_T_world, point0, &previousImagePoint))
1204 for (
size_t nSegment = 0; nSegment < segments; ++nSegment)
1208 const Vector3 currentPoint = point0 * (
Scalar(1) - factor) + point1 * factor;
1211 if (cameraClipper.
projectToImageIF(flippedCamera_T_world, currentPoint, ¤tImagePoint))
1219 previousImagePoint = currentImagePoint;
1226 ocean_assert(frame !=
nullptr);
1227 ocean_assert(startPositions !=
nullptr && stopPositions !=
nullptr);
1228 ocean_assert(offsetStartPositions !=
nullptr && offsetStopPositions !=
nullptr);
1230 for (
unsigned int n = firstLine; n < firstLine + numberLines; ++n)
1232 paintLine(*frame, startPositions[n] + *offsetStartPositions, stopPositions[n] + *offsetStopPositions, color, subPixel);
1236template <
unsigned int tSize>
1239 ocean_assert(frame && startPositions && stopPositions);
1241 for (
unsigned int n = firstLine; n < firstLine + numberLines; ++n)
1243 CV::Canvas::line<tSize>(*frame, startPositions[n].x(), startPositions[n].y(), stopPositions[n].x(), stopPositions[n].y(), color);
1247template <
unsigned int tSizeForeground,
unsigned int tSizeBackground>
1250 static_assert(tSizeForeground < tSizeBackground,
"Invalid line size");
1251 ocean_assert(frame && startPositions && stopPositions);
1253 for (
unsigned int n = firstLine; n < firstLine + numberLines; ++n)
1260template <
unsigned int tSize>
1263 static_assert(tSize % 2u == 1u,
"Invalid size parameter.");
1265 ocean_assert(frame !=
nullptr);
1267 for (
unsigned int n = firstPath; n < firstPath + numberPaths; ++n)
1271 for (
size_t i = 1; i < path.size(); ++i)
1278template <
unsigned int tSize>
1281 static_assert(tSize % 2u == 1u,
"Invalid size parameter.");
1283 ocean_assert(frame !=
nullptr);
1285 std::vector<uint8_t> color(frame->
channels());
1287 for (
unsigned int n = firstPath; n < firstPath + numberPaths; ++n)
1291 for (
unsigned int c = 0u; c < frame->
channels(); ++c)
1293 color[c] = uint8_t(
Scalar(color0[c]) * (1 - factors[n]) +
Scalar(color1[c]) * factors[n]);
1298 for (
size_t i = 1; i < path.size(); ++i)
1305template <
unsigned int tSize>
1308 static_assert(tSize % 2u == 1u,
"Invalid line width!");
1310 ocean_assert(frame && triangles);
1312 for (
unsigned int n = firstTriangle; n < firstTriangle + numberTriangles; ++n)
1314 const Triangle2& triangle = triangles[n];
1315 ocean_assert(triangle.
isValid());
1323template <
unsigned int tSize>
1326 static_assert(tSize % 2u == 1u,
"Invalid line width!");
1328 ocean_assert(frame !=
nullptr && flippedCamera_T_world !=
nullptr && anyCamera !=
nullptr && triangles !=
nullptr);
1330 for (
unsigned int n = firstTriangle; n < firstTriangle + numberTriangles; ++n)
1345template <
unsigned int tPo
intSize>
1348 static_assert(tPointSize % 2u == 1u,
"Invalid point size!");
1350 ocean_assert(frame !=
nullptr && imagePoints !=
nullptr);
1352 for (
unsigned int n = firstImagePoint; n < firstImagePoint + numberImagePoints; ++n)
1358template <
unsigned int tPo
intSize>
1361 static_assert(tPointSize % 2u == 1u,
"Invalid point size!");
1363 ocean_assert(frame !=
nullptr && anyCamera !=
nullptr && flippedCamera_T_world !=
nullptr && objectPoints !=
nullptr);
1365 for (
unsigned int n = firstObjectPoint; n < firstObjectPoint + numberObjectPoints; ++n)
1376template <
unsigned int tChannels>
1377inline void Utilities::paintFeaturePoints8BitPerChannelSubset(uint8_t* frame,
const unsigned int width,
const unsigned int height,
const Vector2* positions,
const Scalar* radii,
const Scalar* orientations,
const uint8_t* color,
const uint8_t* shadowColor,
const Scalar offsetX,
const Scalar offsetY,
const unsigned int framePaddingElements,
const unsigned int firstFeaturePoint,
const unsigned int numberFeaturePoints)
1379 ocean_assert(frame && width != 0u && height != 0u);
1380 ocean_assert(positions && radii && orientations && color);
1382 for (
unsigned int n = firstFeaturePoint; n < firstFeaturePoint + numberFeaturePoints; ++n)
1388template <
unsigned int tObjectPo
intSize,
unsigned int tImagePo
intSize>
1389void Utilities::paintCorrespondencesSubset(
Frame* frame,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_model,
const Vector3* objectPoints,
const Vector2* imagePoints,
const Scalar maxSqrError,
const uint8_t* colorValidObjectPoints,
const uint8_t* colorValidImagePoints,
const uint8_t* colorInvalidObjectPoints,
const uint8_t* colorInvalidImagePoints,
const bool drawObjectPoints,
const bool drawImagePoints,
const bool drawConnections,
const unsigned int firstCorrespondence,
const unsigned int numberCorrespondences)
1391 static_assert(tObjectPointSize >= tImagePointSize,
"Invalid point size!");
1392 static_assert(tObjectPointSize % 2u == 1u,
"Invalid point size!");
1393 static_assert(tImagePointSize % 2u == 1u,
"Invalid point size!");
1395 ocean_assert(frame !=
nullptr && camera !=
nullptr && flippedCamera_T_model !=
nullptr && objectPoints !=
nullptr && imagePoints !=
nullptr );
1397 for (
unsigned int n = firstCorrespondence; n < firstCorrespondence + numberCorrespondences; ++n)
1403 const uint8_t* colorObjectPoint = (
sqrDistance <= maxSqrError) ? colorValidObjectPoints : colorInvalidObjectPoints;
1404 const uint8_t* colorImagePoint = (
sqrDistance <= maxSqrError) ? colorValidImagePoints : colorInvalidImagePoints;
1406 if (drawObjectPoints)
1416 if (drawImagePoints)
1423template <
unsigned int tBlendChannel,
unsigned int tChannels>
1426 static_assert(tBlendChannel < tChannels,
"Invalid blend channel!");
1428 ocean_assert(pixel);
1430 if (blendFactor == 0xFF)
1432 for (
unsigned int n = 0u; n < tChannels; ++n)
1434 if (n == tBlendChannel)
bool projectToImageIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint, VectorT2< T > *imagePoint=nullptr) const
Returns whether a 3D object point is located in front of the camera and projects into the camera imag...
Definition AnyCamera.h:1733
bool isValid() const
Returns whether this clipper holds a valid camera model and is ready to be used.
Definition AnyCamera.h:1860
virtual unsigned int width() const =0
Returns the width of the camera image.
virtual unsigned int height() const =0
Returns the height of the camera image.
virtual VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual bool isValid() const =0
Returns whether this camera is valid.
static bool line(Frame &frame, const int xStart, const int yStart, const int xEnd, const int yEnd, const uint8_t *value=nullptr)
Paints a line with specified start and end position with pixel accuracy.
static const uint8_t * yellow(const FrameType::PixelFormat pixelFormat=FrameType::FORMAT_RGB24)
Returns the color values for a yellow color.
static void line8BitPerChannel(uint8_t *frame, const unsigned int width, const unsigned int height, const int xStart, const int yStart, const int xEnd, const int yEnd, const uint8_t *value=nullptr, const unsigned int framePaddingElements=0u)
Paints a line with specified start and end position with pixel accuracy.
Definition Canvas.h:839
static bool point(Frame &frame, const Vector2 &position, const uint8_t *value=nullptr)
Paints a point with sub-pixel accuracy.
Definition Canvas.h:1220
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
static HomogenousMatrixT4< U > standard2InvertedFlipped(const HomogenousMatrixT4< U > &world_T_camera)
static bool isObjectPointInFrontIF(const HomogenousMatrixT4< Scalar > &flippedCamera_T_world, const VectorT3< Scalar > &objectPoint, const Scalar epsilon=NumericT< Scalar >::eps())
This class implements Ocean's image class.
Definition Frame.h:1969
bool isValid() const
Returns whether this frame is valid.
Definition Frame.h:4705
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
@ FORMAT_UNDEFINED
Undefined pixel format.
Definition Frame.h:187
unsigned int width() const
Returns the width of the frame format in pixel.
Definition Frame.h:3334
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3339
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition Frame.h:3364
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1800
This class implements an output bitstream.
Definition Bitstream.h:215
std::vector< uint8_t > Buffer
Definition of a vector holding bytes.
Definition Maintenance.h:41
static constexpr Scalar pi2()
static constexpr bool isInsideRange(const Scalar lower, const Scalar value, const Scalar upper, const Scalar epsilon=NumericT< Scalar >::eps())
static constexpr int32_t round32(const Scalar value)
static constexpr Scalar eps()
This class implements a database for 3D object points, 2D image points and 6DOF camera poses.
Definition Database.h:67
This class implements utility functions for convenient visualization of tracking data.
Definition tracking/Utilities.h:46
static bool readCamera(IO::InputBitstream &inputStream, PinholeCamera &pinholeCamera)
Reads a camera profile from a binary input stream.
static void paintTriangles(Frame &frame, const Triangles2 &triangles, const uint8_t *color=nullptr, Worker *worker=nullptr)
Paints a set of 2D triangles into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1009
static void paintLineIF(Frame &frame, const AnyCameraClipper &cameraClipper, const HomogenousMatrix4 &flippedCamera_T_world, const Vector3 &objectPoint0, const Vector3 &objectPoint1, const unsigned int segments, const uint8_t *foregroundColor, const uint8_t *backgroundColor)
Paints a (projected) 3D line into a given frame.
static void paintPaths(Frame &frame, const Vectors2 *paths, const size_t size, const uint8_t *color=nullptr, Worker *worker=nullptr)
Paints several paths into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:967
static void paintTrianglesIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const AnyCamera &anyCamera, const Triangle3 *triangles, const size_t numberTriangles, const uint8_t *color=nullptr, Worker *worker=nullptr)
Paints (projected) 3D triangles into a given frame.
Definition tracking/Utilities.h:1166
static void paintPathsAdvancedSubset(Frame *frame, const Vectors2 *paths, const uint8_t *color0, const uint8_t *color1, const Scalar *factors, const unsigned int firstPath, const unsigned int numberPaths)
Paints a subset of several paths into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1279
static void paintObjectPoints(Frame &frame, const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_camera, const Vector3 *objectPoints, const size_t size, const uint8_t *color, Worker *worker=nullptr)
Paints a set of projected 3D object points into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1047
static bool paintPlane(Frame &frame, const HomogenousMatrix4 &world_T_camera, const AnyCamera &camera, const HomogenousMatrix4 &planeTransformation, const unsigned int bins, const uint8_t *foregroundColor, const uint8_t *backgroundColor, Scalar *expansion=nullptr)
Paints a 3D plane into the frame, further the origin of the plane is painted.
static void paintImagePointsSubset(Frame *frame, const Vector2 *imagePoints, const uint8_t *color, const unsigned int firstImagePoint, const unsigned int numberImagePoints)
Paints subset of a set of 2D image points into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1346
static void paintLinesSubset(Frame *frame, const Vector2 *startPositions, const Vector2 *stopPositions, const uint8_t *color, const bool subPixel, const Vector2 *offsetStartPositions, const Vector2 *offsetStopPositions, const unsigned int firstLine, const unsigned int numberLines)
Paints a subset of a set of lines into a given frame.
Definition tracking/Utilities.h:1224
static void paintCoordinateSystemIF(Frame &frame, const AnyCameraClipper &cameraClipper, const HomogenousMatrix4 &flippedCamera_T_world, const HomogenousMatrix4 &world_T_coordinateSystem, const Scalar length, const unsigned int segments=10u)
Paints a 3D coordinate system (projected) into a frame.
static void paintWireframeConeIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_cone, const PinholeCamera &pinholeCamera, const Cone3 &cone, const bool distortProjectedObjectPoints=true, Worker *worker=nullptr, const uint8_t *color=CV::Canvas::yellow(), const unsigned int numCircles=6u, const unsigned int numVerticalLines=4u, const unsigned int numSamples=72u)
Paints a (projected) wire-frame cone into a given frame.
static bool alignFramesHomography(const Frame &fixedFrame, const Frame &dynamicFrame, const SquareMatrix3 &dynamic_H_fixed, Frame &result, const bool blend, Worker *worker=nullptr)
Aligns two frames connected by a given homography into one frame while the resulting frame covers the...
static void paintLineIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const AnyCamera &anyCamera, const Vector3 &objectPoint0, const Vector3 &objectPoint1, const unsigned int segments, const uint8_t *foregroundColor, const uint8_t *backgroundColor)
Paints a (projected) 3D line into a given frame.
static void paintLines(Frame &frame, const Vector2 *startPositions, const Vector2 *stopPositions, const size_t numberLines, const uint8_t *color=nullptr, Worker *worker=nullptr, const bool subPixel=true, const Vector2 &offsetStartPositions=Vector2(0, 0), const Vector2 &offsetStopPositions=Vector2(0, 0))
Paints a set of lines into a given frame.
Definition tracking/Utilities.h:913
static Frame blendFrames(const Frame &frame0, const Frame &frame1, Worker *worker=nullptr)
Blends two given frames with the same frame type.
static Frame blendFrames(const Frame &frame0, const Frame &frame1, Vector2 &offset0, Vector2 &offset1, const FrameType::PixelFormat pixelFormat=FrameType::FORMAT_UNDEFINED, Worker *worker=nullptr)
Blends two given frames with the same pixel origin.
static void paintObjectPointsSubset(Frame *frame, const AnyCamera *anyCamera, const HomogenousMatrix4 *flippedCamera_T_world, const Vector3 *objectPoints, const uint8_t *color, const unsigned int firstObjectPoint, const unsigned int numberObjectPoints)
Paints a subset of a set of projected 3D object points into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1359
static bool readDatabase(IO::InputBitstream &inputStream, Database &database)
Reads a database information from a binary input stream.
static void blendPixel(uint8_t *pixel, const uint8_t blendFactor)
Paints / blends a binary 8 bit mask pixel into a given pixel with 8 bit per channel.
Definition tracking/Utilities.h:1424
static void paintFeaturePoint8BitPerChannel(uint8_t *frame, const unsigned int width, const unsigned int height, const Vector2 &position, const Scalar radius, const Scalar orientation, const uint8_t *color, const uint8_t *shadowColor, const unsigned int framePaddingElements=0u)
Paints a feature point with a radius (scale) and orientation.
Definition tracking/Utilities.h:1072
static bool paintPlaneIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const AnyCamera &camera, const HomogenousMatrix4 &planeTransformation, const Scalar expansion, const unsigned int bins, const uint8_t *foregroundColor, const uint8_t *backgroundColor)
Paints a 3D plane into the frame, further the origin of the plane is painted.
static void paintPathsSubset(Frame *frame, const Vectors2 *paths, const uint8_t *color, const unsigned int firstPath, const unsigned int numberPaths)
Paints a subset of several paths into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1261
static Frame paintBoundingBox(const Frame &frame, const CV::PixelBoundingBox &boundingBox, Worker *worker=nullptr)
Paints / blends a bounding box into a given frame.
static void paintFeaturePoint(Frame &frame, const Vector2 &position, const Scalar radius, const Scalar orientation, const uint8_t *color, const uint8_t *shadowColor)
Paints a feature point with a radius (scale) and orientation.
static void paintQuads(Frame &frame, const HomogenousMatrix4 &world_T_camera, const AnyCamera &camera, const Vector3 &quadOrigin, const Vector3 &quadHorizontal, const Vector3 &quadVertical, const unsigned int horizontalBins, const unsigned int verticalBins, const uint8_t *color=nullptr)
Paints quads that are located on a 3D plane into a given frame.
Definition tracking/Utilities.h:1154
static void paintFeaturePoints8BitPerChannel(uint8_t *frame, const unsigned int width, const unsigned int height, const Vector2 *positions, const Scalar *radii, const Scalar *orientations, const size_t size, const uint8_t *color, const uint8_t *shadowColor, const Vector2 &explicitOffset, const unsigned int framePaddingElements, Worker *worker=nullptr)
Paints feature points with radius (scale) and orientation.
Definition tracking/Utilities.h:1104
static void visualizeDatabase(const Database &database, const Index32 poseId, Frame &frame, const uint8_t *colorImagePoints, const uint8_t *colorImagePointsInstable, const uint8_t *colorImagePointsStable, const unsigned int maximalPathLength=20u, const unsigned int stablePathLength=100u, const SquareMatrix3 &transformation=SquareMatrix3(true), Worker *worker=nullptr)
Visualizes image point information of a tracking database for a specific pose id.
static void paintPoints(Frame &frame, const Vector2 *imagePoints, const size_t number, const unsigned int radius, const uint8_t *colorInner=nullptr, const uint8_t *colorOuter=nullptr)
Paints a set of image points into a given frame.
static void paintQuadsIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const AnyCamera &camera, const Vector3 &quadOrigin, const Vector3 &quadHorizontal, const Vector3 &quadVertical, const unsigned int horizontalBins, const unsigned int verticalBins, const uint8_t *color=nullptr)
Paints quads that are located on a 3D plane into a given frame.
static void paintLine(Frame &frame, const Vector2 &startPosition, const Vector2 &stopPosition, const uint8_t *color=nullptr, const bool subPixel=true)
Paints a line into a given frame.
Definition tracking/Utilities.h:901
static Frame paintMask(const Frame &frame, const Frame &mask, const uint8_t maskValue=uint8_t(0xFFu), Worker *worker=nullptr)
Paints / blends a binary 8 bit mask into a given frame with identical frame dimension.
static bool alignFramesHomographyFullCoverage(const Frame &fixedFrame, const Frame &dynamicFrame, const SquareMatrix3 &dynamic_H_fixed, Frame &result, const bool blend, Worker *worker=nullptr, unsigned int maximalWidth=16384u, const unsigned int maximalHeight=16384u, unsigned int *fixedFrameLeft=nullptr, unsigned int *fixedFrameTop=nullptr, Scalar *dynamicFrameLeft=nullptr, Scalar *dynamicFrameTop=nullptr, Frame *fullFixedFrame=nullptr, Frame *fullDynamicFrame=nullptr)
Aligns two frames connected by a given homography into one frame entirely covering the frame content ...
static void paintCorrespondences(Frame &frame, const AnyCamera &camera, const HomogenousMatrix4 &model_T_camera, const Vector3 *objectPoints, const Vector2 *imagePoints, const size_t correspondences, const Scalar maxSqrError, const uint8_t *colorValidObjectPoints, const uint8_t *colorValidImagePoints, const uint8_t *colorInvalidObjectPoints, const uint8_t *colorInvalidImagePoints, const bool drawObjectPoints=true, const bool drawImagePoints=true, const bool drawConnections=true, Worker *worker=nullptr)
Paints a set of correspondences between 2D image points and 3D object points (or their projected 2D c...
Definition tracking/Utilities.h:1126
static void paintTrianglesIFSubset(Frame *frame, const HomogenousMatrix4 *flippedCamera_T_world, const AnyCamera *anyCamera, const Triangle3 *triangles, const uint8_t *color, const unsigned int firstTriangle, const unsigned int numberTriangles)
Projects and paints a subset of 3D triangles into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1324
static bool paintGravity(const AnyCamera &camera, Frame &frame, const Vector3 &gravity, const unsigned int thickness=3u, const uint8_t *color=nullptr, const unsigned int segments=20u, const Vector3 &position=Vector3(0, 0, -1), const Scalar length=Scalar(1))
Paints a gravity vector into a given frame.
static void paintImagePoints(Frame &frame, const Vector2 *imagePoints, const size_t size, const uint8_t *color, Worker *worker=nullptr)
Paints a set of 2D image points into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1027
static bool writeDatabase(const Database &database, IO::OutputBitstream &outputStream)
Writes the information of a database to a given output stream as binary information.
static bool paintCorrespondencesHomography(const Frame &frame0, const Frame &frame1, const SquareMatrix3 &points1_H_points0, const Vector2 *points0, const Vector2 *points1, const size_t numberPoints, const bool fullCoverage, Frame &result, const uint8_t *foregroundColor=nullptr, const uint8_t *backgroundColor=nullptr, const uint8_t *startColor=nullptr, Worker *worker=nullptr)
Joins two corresponding frames by application of a homography and paints a set of given feature corre...
static void paintBoundingBoxIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const AnyCamera &anyCamera, const Box3 &boundingBox, const uint8_t *foregroundColor, const uint8_t *backgroundColor, const bool edgesOnly=true)
Paints a (projected) 3D axis aligned bounding box into a given frame.
static void paintCoordinateSystemIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_coordinateSystem, const Scalar length)
Paints a 3D coordinate system (projected) into a frame.
static void paintFeaturePoints(Frame &frame, const Vector2 *positions, const Scalar *radii, const Scalar *orientations, const size_t size, const uint8_t *color, const uint8_t *shadowColor, const Vector2 &explicitOffset=Vector2(0, 0), Worker *worker=nullptr)
Paints feature points with radius (scale) and orientation.
static Frame paintCorrespondencesBlend(const Frame &frame0, const Frame &frame1, const Vector2 *points0, const Vector2 *points1, const size_t numberPoints, const uint8_t *color=nullptr, Worker *worker=nullptr)
Blends two corresponding frames each with a ratio of fifty percent and paints a set of given feature ...
static Frame paintCorrespondencesHorizontal(const Frame &frame0, const Frame &frame1, const Vector2 *points0, const Vector2 *points1, const size_t numberPoints, const uint8_t *color=nullptr, Worker *worker=nullptr)
Joins two corresponding frames horizontally and paints a set of given feature correspondences.
static bool paintCorrespondencesOrientations(const PinholeCamera &pinholeCamera, const Frame &frame0, const Frame &frame1, const SquareMatrix3 &orientation0, const SquareMatrix3 &orientation1, const Vector2 *points0, const Vector2 *points1, const size_t numberPoints, Frame &result, const uint8_t *foregroundColor=nullptr, const uint8_t *backgroundColor=nullptr, const uint8_t *startColor=nullptr, Worker *worker=nullptr)
Joins two corresponding frames by application of their orientations and paints a set of given feature...
static void paintTriangle(Frame &frame, const Triangle2 &triangle, const uint8_t *color=nullptr)
Paints a 2D triangle into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1003
static Frame paintCorrespondencesVertical(const Frame &frame0, const Frame &frame1, const Vector2 *points0, const Vector2 *points1, const size_t numberPoints, const uint8_t *color=nullptr, Worker *worker=nullptr)
Joins two corresponding frames vertically and paints a set of given feature correspondences.
static void paintTrianglesSubset(Frame *frame, const Triangle2 *triangles, const uint8_t *color, const unsigned int firstTriangle, const unsigned int numberTriangles)
Paints a subset of 2D triangles into a given frame with sub-pixel accuracy.
Definition tracking/Utilities.h:1306
static bool writeCamera(const PinholeCamera &pinholeCamera, IO::OutputBitstream &outputStream)
Writes a camera profile to a binary output stream.
static void paintWireframeCylinderIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_cylinder, const PinholeCamera &pinholeCamera, const Cylinder3 &cylinder, const bool distortProjectedObjectPoints=true, Worker *worker=nullptr, const uint8_t *color=CV::Canvas::yellow(), const unsigned int numCircles=6u, const unsigned int numVerticalLines=4u, const unsigned int numSamples=72u)
Paints a (projected) wire-frame cylinder into a given frame.
static void paintFeaturePoints8BitPerChannelSubset(uint8_t *frame, const unsigned int width, const unsigned int height, const Vector2 *positions, const Scalar *radii, const Scalar *orientations, const uint8_t *color, const uint8_t *shadowColor, const Scalar offsetX, const Scalar offsetY, const unsigned int framePaddingElements, const unsigned int firstFeaturePoint, const unsigned int numberFeaturePoints)
Paints a subset of feature points with radius (scale) and orientation.
Definition tracking/Utilities.h:1377
static void paintTriangleIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const AnyCamera &anyCamera, const Triangle3 &triangle, const uint8_t *color=nullptr)
Paints a (projected) 3D triangle into a given frame.
Definition tracking/Utilities.h:1160
static void paintCorrespondencesSubset(Frame *frame, const AnyCamera *camera, const HomogenousMatrix4 *flippedCamera_T_model, const Vector3 *objectPoints, const Vector2 *imagePoints, const Scalar maxSqrError, const uint8_t *colorValidObjectPoints, const uint8_t *colorValidImagePoints, const uint8_t *colorInvalidObjectPoints, const uint8_t *colorInvalidImagePoints, const bool drawObjectPoints, const bool drawImagePoints, const bool drawConnections, const unsigned int firstCorrespondence, const unsigned int numberCorrespondences)
Paints a subset of a set of correspondences between 2D image points and 3D object points (or their pr...
Definition tracking/Utilities.h:1389
static void paintPointsIF(Frame &frame, const HomogenousMatrix4 &flippedCamera_T_world, const PinholeCamera &pinholeCamera, const Vector3 *objectPoints, const size_t numberObjectPoints, const Vector2 *imagePoints, const size_t numberImagePoints, const bool distortProjectedObjectPoints, const unsigned int radiusObjectPoints, const unsigned int radiusImagePoints, const uint8_t *colorObjectPoints=nullptr, const uint8_t *colorImagePoints=nullptr)
Paints (projected) object points and image points into a given frame.
static Maintenance::Buffer encodeEnvironment(const Frame &frame, const Vectors2 &frameImagePoints, const Vectors3 &frameObjectPoints, const HomogenousMatrix4 &framePose, const Vectors3 &objectPoints)
Encodes the tracking environment composed of a frame mesh (a frame with correspondences of 2D image p...
const VectorT2< T > & point2() const
Returns the third triangle corner.
Definition Triangle2.h:416
const VectorT2< T > & point0() const
Returns the first triangle corner.
Definition Triangle2.h:404
const VectorT2< T > & point1() const
Returns the second triangle corner.
Definition Triangle2.h:410
bool isValid() const
Returns whether this triangle can provide valid barycentric coordinates (for 64 bit floating point va...
Definition Triangle2.h:798
bool isValid() const
Returns whether this triangle is valid.
Definition Triangle3.h:579
const T & x() const noexcept
Returns the x value.
Definition Vector2.h:703
const T & y() const noexcept
Returns the y value.
Definition Vector2.h:715
static VectorT2< Scalar > minValue()
T sqrDistance(const VectorT2< T > &right) const
Returns the square distance between this 2D position and a second 2D position.
Definition Vector2.h:638
const T & y() const noexcept
Returns the y value.
Definition Vector3.h:816
const T & x() const noexcept
Returns the x value.
Definition Vector3.h:804
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition base/Utilities.h:1159
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
PixelBoundingBoxT< unsigned int > PixelBoundingBox
Definition of the default PixelBoundingBox object with data type allowing only positive coordinate va...
Definition PixelBoundingBox.h:28
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
QuaternionT< Scalar > Quaternion
Definition of the Quaternion object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sin...
Definition Quaternion.h:40
PinholeCameraT< Scalar > PinholeCamera
Definition of an pinhole camera object with Scalar precision.
Definition PinholeCamera.h:39
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
AnyCameraT< Scalar > AnyCamera
Definition of an AnyCamera object with Scalar precision.
Definition AnyCamera.h:31
AnyCameraClipperT< Scalar > AnyCameraClipper
Definition of an AnyCamera clipper object with Scalar precision.
Definition AnyCamera.h:493
CylinderT3< Scalar > Cylinder3
Definition of the Cylinder3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition Cylinder3.h:30
TriangleT3< Scalar > Triangle3
Definition of the Triangle3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition Triangle3.h:28
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition Vector3.h:29
ConeT3< Scalar > Cone3
Definition of the Cone3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single o...
Definition Cone3.h:30
SquareMatrixT3< Scalar > SquareMatrix3
Definition of the SquareMatrix3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition SquareMatrix3.h:43
BoxT3< Scalar > Box3
Definition of the Box3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single or...
Definition Box3.h:28
std::vector< Triangle2 > Triangles2
Definition of a vector holding 2D triangles.
Definition Triangle2.h:57
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
TriangleT2< Scalar > Triangle2
Definition of the Triangle2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition Triangle2.h:28
float Scalar
Definition of a scalar type.
Definition Math.h:129
Namespace of the Tracker library.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15