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>
162 static void paintTriangle(
Frame& frame,
const Triangle2& triangle,
const uint8_t* color =
nullptr);
172 template <
unsigned int tSize = 1u>
173 static void paintTriangles(
Frame& frame,
const Triangles2& triangles,
const uint8_t* color =
nullptr,
Worker* worker =
nullptr);
184 template <
unsigned int tPo
intSize>
185 static inline void paintImagePoints(
Frame& frame,
const Vector2* imagePoints,
const size_t size,
const uint8_t* color,
Worker* worker =
nullptr);
198 template <
unsigned int tPo
intSize>
199 static inline 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);
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);
438 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);
453 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);
464 template <
unsigned int tSize = 1u>
478 template <
unsigned int tSize = 1u>
479 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);
492 template <
unsigned int tSize = 1u>
585 static inline 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);
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>
816 static inline 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);
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>
842 static inline 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);
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);
905 CV::Canvas::line<1u>(frame, startPosition.
x(), startPosition.
y(), stopPosition.
x(), stopPosition.
y(), color);
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)
944 paintLinesSubset<tSize>(&frame, startPositions, stopPositions, color, 0u, (
unsigned int)numberLines);
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);
962 paintLinesSubset<tSizeForeground, tSizeBackground>(&frame, startPositions, stopPositions, foregroundColor, backgroundColor, 0u, (
unsigned int)numberLines);
966template <
unsigned int tSize>
980 paintPathsSubset<tSize>(&frame, paths, color, 0u, (
unsigned int)size);
984template <
unsigned int tSize>
998 paintPathsAdvancedSubset<tSize>(&frame, paths, color0, color1, factors, 0u, (
unsigned int)size);
1002template <
unsigned int tSize>
1005 paintTrianglesSubset<tSize>(&frame, &triangle, color, 0u, 1u);
1008template <
unsigned int tSize>
1011 if (triangles.empty())
1022 paintTrianglesSubset<tSize>(&frame, triangles.
data(), color, 0u, (
unsigned int)triangles.size());
1026template <
unsigned int tPo
intSize>
1029 static_assert(tPointSize % 2u == 1u,
"Invalid point size!");
1042 paintImagePointsSubset<tPointSize>(&frame, imagePoints, color, 0u, (
unsigned int)size);
1046template <
unsigned int tPo
intSize>
1049 static_assert(tPointSize % 2u == 1u,
"Invalid point size!");
1067 paintObjectPointsSubset<tPointSize>(&frame, &anyCamera, &flippedCamera_T_world, objectPoints, color, 0u, (
unsigned int)(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);
1087 CV::Canvas::line8BitPerChannel<tChannels, 3u>(frame, width, height, position.
x(), position.
y(), position.
x() + direction.
x(), position.
y() + direction.
y(), shadowColor, framePaddingElements);
1089 CV::Canvas::line8BitPerChannel<tChannels, 3u>(frame, width, height, position.
x() + leftTop.
x(), position.
y() + leftTop.
y(), position.
x() + leftBottom.
x(), position.
y() + leftBottom.
y(), shadowColor, framePaddingElements);
1090 CV::Canvas::line8BitPerChannel<tChannels, 3u>(frame, width, height, position.
x() + leftBottom.
x(), position.
y() + leftBottom.
y(), position.
x() + rightBottom.
x(), position.
y() + rightBottom.
y(), shadowColor, framePaddingElements);
1091 CV::Canvas::line8BitPerChannel<tChannels, 3u>(frame, width, height, position.
x() + rightBottom.
x(), position.
y() + rightBottom.
y(), position.
x() + rightTop.
x(), position.
y() + rightTop.
y(), shadowColor, framePaddingElements);
1092 CV::Canvas::line8BitPerChannel<tChannels, 3u>(frame, width, height, position.
x() + rightTop.
x(), position.
y() + rightTop.
y(), position.
x() + leftTop.
x(), position.
y() + leftTop.
y(), shadowColor, framePaddingElements);
1095 CV::Canvas::line8BitPerChannel<tChannels, 1u>(frame, width, height, position.
x(), position.
y(), position.
x() + direction.
x(), position.
y() + direction.
y(), color, framePaddingElements);
1097 CV::Canvas::line8BitPerChannel<tChannels, 1u>(frame, width, height, position.
x() + leftTop.
x(), position.
y() + leftTop.
y(), position.
x() + leftBottom.
x(), position.
y() + leftBottom.
y(), color, framePaddingElements);
1098 CV::Canvas::line8BitPerChannel<tChannels, 1u>(frame, width, height, position.
x() + leftBottom.
x(), position.
y() + leftBottom.
y(), position.
x() + rightBottom.
x(), position.
y() + rightBottom.
y(), color, framePaddingElements);
1099 CV::Canvas::line8BitPerChannel<tChannels, 1u>(frame, width, height, position.
x() + rightBottom.
x(), position.
y() + rightBottom.
y(), position.
x() + rightTop.
x(), position.
y() + rightTop.
y(), color, framePaddingElements);
1100 CV::Canvas::line8BitPerChannel<tChannels, 1u>(frame, width, height, position.
x() + rightTop.
x(), position.
y() + rightTop.
y(), position.
x() + leftTop.
x(), position.
y() + leftTop.
y(), color, framePaddingElements);
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>
1162 paintTrianglesIFSubset<tSize>(&frame, &flippedCamera_T_world, &anyCamera, &triangle, color, 0u, 1u);
1165template <
unsigned int tSize>
1168 if (numberTriangles == 0)
1179 paintTrianglesIFSubset<tSize>(&frame, &flippedCamera_T_world, &anyCamera, triangles, color, 0u, (
unsigned int)(numberTriangles));
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))
1215 CV::Canvas::line<tSize>(frame, previousImagePoint, currentImagePoint, color);
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)
1255 CV::Canvas::line<tSizeBackground>(*frame, startPositions[n].x(), startPositions[n].y(), stopPositions[n].x(), stopPositions[n].y(), colorBackground);
1256 CV::Canvas::line<tSizeForeground>(*frame, startPositions[n].x(), startPositions[n].y(), stopPositions[n].x(), stopPositions[n].y(), colorForeground);
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)
1273 CV::Canvas::line<tSize>(*frame, path[i - 1], path[i], color);
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)
1300 CV::Canvas::line<tSize>(*frame, path[i - 1], path[i], color.
data());
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());
1317 CV::Canvas::line<tSize>(*frame, triangle.
point0().x(), triangle.
point0().y(), triangle.
point1().x(), triangle.
point1().y(), color);
1318 CV::Canvas::line<tSize>(*frame, triangle.
point1().x(), triangle.
point1().y(), triangle.
point2().x(), triangle.
point2().y(), color);
1319 CV::Canvas::line<tSize>(*frame, triangle.
point2().x(), triangle.
point2().y(), triangle.
point0().x(), triangle.
point0().y(), color);
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)
1338 CV::Canvas::line<tSize>(*frame, imagePoint0.
x(), imagePoint0.
y(), imagePoint1.
x(), imagePoint1.
y(), color);
1339 CV::Canvas::line<tSize>(*frame, imagePoint1.
x(), imagePoint1.
y(), imagePoint2.
x(), imagePoint2.
y(), color);
1340 CV::Canvas::line<tSize>(*frame, imagePoint2.
x(), imagePoint2.
y(), imagePoint0.
x(), imagePoint0.
y(), color);
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)
1354 CV::Canvas::point<tPointSize>(*frame, imagePoints[n], color);
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)
1371 CV::Canvas::point<tPointSize>(*frame, projectedObjectPoint, color);
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)
1384 paintFeaturePoint8BitPerChannel<tChannels>(frame, width, height, positions[n] +
Vector2(offsetX, offsetY), radii[n], orientations[n], color, shadowColor, framePaddingElements);
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)
1408 CV::Canvas::point<tObjectPointSize>(*frame, projectedObjectPoint, colorObjectPoint);
1413 CV::Canvas::line<1u>(*frame, projectedObjectPoint, imagePoints[n], colorImagePoint);
1416 if (drawImagePoints)
1418 CV::Canvas::point<tImagePointSize>(*frame, imagePoints[n], colorImagePoint);
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)
This class implements a helper class allowing to check whether a 3D object point projects into the ca...
Definition AnyCamera.h:518
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:1725
bool isValid() const
Returns whether this clipper holds a valid camera model and is ready to be used.
Definition AnyCamera.h:1822
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:131
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 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)
Creates a new caller container for a static function with no function parameter.
Definition Caller.h:2877
static HomogenousMatrixT4< U > standard2InvertedFlipped(const HomogenousMatrixT4< U > &world_T_camera)
Transforms a standard homogenous 4x4 viewing (extrinsic camera) matrix into an inverted and flipped c...
Definition Camera.h:778
static bool isObjectPointInFrontIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint, const T epsilon=NumericT< T >::eps())
Determines whether a given 3D object point lies in front of a camera while the location of the camera...
Definition Camera.h:855
This class implements a (possibly truncated) 3D cone.
Definition Cone3.h:59
This class implements a 3D cylinder defined by its origin, axis, radius, and (signed) starting and st...
Definition Cylinder3.h:80
This class implements Ocean's image class.
Definition Frame.h:1879
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition Frame.h:4323
bool isValid() const
Returns whether this frame is valid.
Definition Frame.h:4612
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
unsigned int width() const
Returns the width of the frame format in pixel.
Definition Frame.h:3241
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3246
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition Frame.h:3271
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1806
This class implements an output bitstream.
Definition Bitstream.h:215
std::vector< unsigned char > Buffer
Definition of a vector holding bytes.
Definition Maintenance.h:41
static constexpr T pi2()
Returns 2*PI which is equivalent to 360 degree.
Definition Numeric.h:932
static constexpr bool isInsideRange(const T lower, const T value, const T upper, const T epsilon=NumericT< T >::eps())
Returns whether a value lies between a given range up to a provided epsilon border.
Definition Numeric.h:2881
static constexpr int32_t round32(const T value)
Returns the rounded 32 bit integer value of a given value.
Definition Numeric.h:2073
static constexpr T eps()
Returns a small epsilon.
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...
This class implements a 2D triangle with Cartesian coordinates.
Definition Triangle2.h:81
const VectorT2< T > & point2() const
Returns the third triangle corner.
Definition Triangle2.h:415
const VectorT2< T > & point0() const
Returns the first triangle corner.
Definition Triangle2.h:403
const VectorT2< T > & point1() const
Returns the second triangle corner.
Definition Triangle2.h:409
bool isValid() const
Returns whether this triangle can provide valid barycentric coordinates (for 64 bit floating point va...
Definition Triangle2.h:806
This class implements a 3D triangle.
Definition Triangle3.h:80
bool isValid() const
Returns whether this triangle is valid.
Definition Triangle3.h:580
const T & x() const noexcept
Returns the x value.
Definition Vector2.h:710
const T & y() const noexcept
Returns the y value.
Definition Vector2.h:722
static VectorT2< Scalar > minValue()
Returns a 2D vector with all elements set to NumericT::minValue().
Definition Vector2.h:926
T sqrDistance(const VectorT2< T > &right) const
Returns the square distance between this 2D position and a second 2D position.
Definition Vector2.h:645
const T & y() const noexcept
Returns the y value.
Definition Vector3.h:824
const T & x() const noexcept
Returns the x value.
Definition Vector3.h:812
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
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
float Scalar
Definition of a scalar type.
Definition Math.h:129
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
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition Vector3.h:29
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
The namespace covering the entire Ocean framework.
Definition Accessor.h:15