8 #ifndef META_OCEAN_CV_ADVANCED_ADVANCED_MOTION_H
9 #define META_OCEAN_CV_ADVANCED_ADVANCED_MOTION_H
44 template <
typename TMetricInteger,
typename TMetricFloat>
class AdvancedMotion;
67 template <
typename TMetricInteger = SumSquareDifferences,
typename TMetricFloat = AdvancedSumSquareDifferences>
101 template <
unsigned int tSize>
102 static bool trackPointsSubPixelMirroredBorder(
const Frame& previousFrame,
const Frame& currentFrame,
const Vectors2& previousPoints,
const Vectors2& roughPoints,
Vectors2& currentPoints,
const unsigned int maximalOffset,
const unsigned int coarsestLayerRadius,
const FramePyramid::DownsamplingMode downsamplingMode =
FramePyramid::DM_FILTER_14641,
const unsigned int subPixelIterations = 4u,
Worker* worker =
nullptr,
MetricResults* metricResults =
nullptr,
MetricResults* metricIdentityResults =
nullptr);
125 template <
unsigned int tSize>
151 template <
unsigned int tChannels,
unsigned int tSize>
172 template <
unsigned int tSize>
194 template <
unsigned int tSize>
220 template <
unsigned int tSize>
221 static bool trackArbitraryPointsBidirectionalSubPixelMirroredBorder(
const CV::FramePyramid& previousPyramid,
const CV::FramePyramid& nextPyramid,
const unsigned int coarsestLayerRadius,
Vectors2& previousImagePoints,
Vectors2& nextImagePoints,
const Scalar maximalSqrError =
Scalar(0.9 * 0.9),
const SubRegion& previousSubRegion =
SubRegion(),
const unsigned int horizontalBins = 0u,
const unsigned int verticalBins = 0u,
const unsigned int strength = 30u,
Worker* worker =
nullptr,
const unsigned int trackingLayers = 1u);
248 template <
unsigned int tSize>
249 static bool trackArbitraryPointsBidirectionalSubPixelMirroredBorder(
const Frame& previousFrame,
const Frame& nextFrame,
const unsigned int maximalOffset,
const unsigned int coarsestLayerRadius,
Vectors2& previousImagePoints,
Vectors2& nextImagePoints,
const Scalar maximalSqrError =
Scalar(0.9 * 0.9),
const SubRegion& previousSubRegion =
SubRegion(),
const unsigned int horizontalBins = 0u,
const unsigned int verticalBins = 0u,
const unsigned int strength = 30u,
const FramePyramid::DownsamplingMode downsamplingMode =
FramePyramid::DM_FILTER_14641,
Worker* worker =
nullptr,
const unsigned int trackingLayers = 1u);
269 template <
unsigned int tSize>
292 template <
unsigned int tChannels,
unsigned int tSize>
315 template <
unsigned int tSize>
340 template <
unsigned int tChannels,
unsigned int tSize>
362 template <
unsigned int tSize>
363 static bool trackPointsBidirectionalSubPixelMirroredBorder(
const Frame& previousFrame,
const Frame& nextFrame,
const unsigned int maximalOffset,
const unsigned int coarsestLayerRadius,
Vectors2& previousImagePoints,
Vectors2& nextImagePoints,
const Scalar maximalSqrError =
Scalar(0.9 * 0.9),
const FramePyramid::DownsamplingMode downsamplingMode =
FramePyramid::DM_FILTER_14641,
Worker* worker =
nullptr,
Indices32* validIndices =
nullptr,
const unsigned int subPixelIterations = 4u);
380 template <
unsigned int tSize>
405 template <
unsigned int tChannels,
unsigned int tPatchSize>
406 static Vector2 trackPointSubPixelMirroredBorder(
const uint8_t* frame0,
const uint8_t* frame1,
const unsigned int width0,
const unsigned int height0,
const unsigned int width1,
const unsigned int height1,
const unsigned int frame0PaddingElements,
const unsigned int frame1PaddingElements,
const Vector2& position0,
const unsigned int radiusX,
const unsigned int radiusY,
const Vector2& rough1 =
Vector2(
Numeric::maxValue(),
Numeric::maxValue()),
const unsigned int subPixelIterations = 4u, uint32_t* metricResult =
nullptr, uint32_t* metricIdentityResult =
nullptr);
430 template <
unsigned int tPatchSize>
431 static inline Vector2 trackPointSubPixelMirroredBorder(
const uint8_t* frame0,
const uint8_t* frame1,
const unsigned int channels,
const unsigned int width0,
const unsigned int height0,
const unsigned int width1,
const unsigned int height1,
const unsigned int frame0PaddingElements,
const unsigned int frame1PaddingElements,
const Vector2& position0,
const unsigned int radiusX,
const unsigned int radiusY,
const Vector2& rough1 =
Vector2(
Numeric::maxValue(),
Numeric::maxValue()),
const unsigned int subPixelIterations = 4u, uint32_t* metricResult =
nullptr, uint32_t* metricIdentityResult =
nullptr);
450 template <
unsigned int tChannels,
unsigned int tPatchSize>
451 static Vector2 trackPointBufferSubPixelMirroredBorder(
const uint8_t* buffer0,
const uint8_t* frame1,
const unsigned int width1,
const unsigned int height1,
const unsigned int frame1PaddingElements,
const Vector2& roughPosition1,
const unsigned int subPixelIterations, uint32_t* metricResult =
nullptr);
471 template <
unsigned int tSize>
472 static void trackPointsSubPixelMirroredBorderSubset(
const FramePyramid* previousPyramid,
const FramePyramid* nextPyramid,
const unsigned int numberLayers,
const Vectors2* previousPoints,
const Vectors2* roughNextPoints,
Vectors2* nextPoints,
const unsigned int coarsestLayerRadius,
const unsigned int subPixelIterations,
unsigned int* metricResults,
unsigned int* metricIdentityResults,
const unsigned int firstPoint,
const unsigned int numberPoints);
494 template <
unsigned int tChannels,
unsigned int tSize>
495 static void trackPointsSubPixelMirroredBorderSubset(
const FramePyramid* previousPyramid,
const FramePyramid* currentPyramid,
const unsigned int numberLayers,
const Vectors2* previousPoints,
const Vectors2* roughPoints,
Vectors2* currentPoints,
const unsigned int coarsestLayerRadius,
const unsigned int subPixelIterations,
unsigned int* metricResults,
unsigned int* metricIdentityResults,
const unsigned int firstPoint,
const unsigned int numberPoints);
498 template <
typename TMetricInteger,
typename TMetricFloat>
499 template <
unsigned int tSize>
500 bool AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointsSubPixelMirroredBorder(
const Frame& previousFrame,
const Frame& currentFrame,
const Vectors2& previousPoints,
const Vectors2& roughPoints,
Vectors2& currentPoints,
const unsigned int maximalOffset,
const unsigned int coarsestLayerRadius,
const FramePyramid::DownsamplingMode downsamplingMode,
const unsigned int subPixelIterations,
Worker* worker,
MetricResults* metricResults,
MetricResults* metricIdentityResults)
502 static_assert(tSize % 2u == 1u,
"Invalid image patch size, must be odd!");
503 static_assert(tSize >= 3u,
"Invalid image patch size, must be larger than 2!");
505 ocean_assert(previousFrame && currentFrame);
510 ocean_assert(previousPoints.size() == roughPoints.size());
512 ocean_assert(maximalOffset >= 1u);
513 ocean_assert(subPixelIterations >= 1u);
515 const unsigned int idealLayers =
FramePyramid::idealLayers(previousFrame.
width(), previousFrame.
height(), (tSize / 2u) * 4u, (tSize / 2u) * 4u, 2u, maximalOffset, coarsestLayerRadius);
516 ocean_assert(idealLayers >= 1u);
518 if (idealLayers == 0u)
523 const FramePyramid previousPyramid(previousFrame, downsamplingMode, idealLayers,
false , worker);
524 const FramePyramid currentPyramid(currentFrame, downsamplingMode, idealLayers,
false , worker);
526 return trackPointsSubPixelMirroredBorder<tSize>(previousPyramid, currentPyramid, previousPoints, roughPoints, currentPoints, coarsestLayerRadius, subPixelIterations, worker, metricResults, metricIdentityResults);
529 template <
typename TMetricInteger,
typename TMetricFloat>
530 template <
unsigned int tSize>
531 inline bool AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointsSubPixelMirroredBorder(
const FramePyramid& previousPyramid,
const FramePyramid& currentPyramid,
const Vectors2& previousPoints,
const Vectors2& roughPoints,
Vectors2& currentPoints,
const unsigned int coarsestLayerRadius,
const unsigned int subPixelIterations,
Worker* worker,
MetricResults* metricResults,
MetricResults* metricIdentityResults)
533 static_assert(tSize % 2u == 1u,
"Invalid image patch size, must be odd!");
534 static_assert(tSize >= 3u,
"Invalid image patch size, must be larger than 2!");
539 ocean_assert(previousPoints.size() == roughPoints.size());
541 ocean_assert(subPixelIterations >= 1u);
544 const unsigned int numberLayers = min(min(previousPyramid.
layers(), currentPyramid.
layers()), idealLayers);
546 if (numberLayers == 0u)
551 currentPoints.resize(previousPoints.size());
555 metricResults->resize(previousPoints.size());
558 if (metricIdentityResults)
560 metricIdentityResults->resize(previousPoints.size());
565 worker->
executeFunction(
Worker::Function::createStatic(&AdvancedMotion::trackPointsSubPixelMirroredBorderSubset<tSize>, &previousPyramid, ¤tPyramid, numberLayers, &previousPoints, &roughPoints, ¤tPoints, coarsestLayerRadius, subPixelIterations, metricResults ? metricResults->data() :
nullptr, metricIdentityResults ? metricIdentityResults->data() :
nullptr, 0u, 0u), 0u, (
unsigned int)(previousPoints.size()));
569 trackPointsSubPixelMirroredBorderSubset<tSize>(&previousPyramid, ¤tPyramid, numberLayers, &previousPoints, &roughPoints, ¤tPoints, coarsestLayerRadius, subPixelIterations, metricResults ? metricResults->data() :
nullptr, metricIdentityResults ? metricIdentityResults->data() :
nullptr, 0u, (
unsigned int)(previousPoints.size()));
575 template <
typename TMetricInteger,
typename TMetricFloat>
576 template <
unsigned int tChannels,
unsigned int tSize>
577 inline bool AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointsSubPixelMirroredBorder(
const FramePyramid& previousPyramid,
const FramePyramid& currentPyramid,
const Vectors2& previousPoints,
const Vectors2& roughPoints,
Vectors2& currentPoints,
const unsigned int coarsestLayerRadius,
const unsigned int subPixelIterations,
Worker* worker,
MetricResults* metricResults,
MetricResults* metricIdentityResults)
579 static_assert(tSize % 2u == 1u,
"Invalid image patch size, must be odd!");
580 static_assert(tSize >= 3u,
"Invalid image patch size, must be larger than 2!");
588 ocean_assert(previousPoints.size() == roughPoints.size());
590 ocean_assert(subPixelIterations >= 1u);
593 const unsigned int numberLayers = min(min(previousPyramid.
layers(), currentPyramid.
layers()), idealLayers);
595 if (numberLayers == 0u)
600 currentPoints.resize(previousPoints.size());
604 metricResults->resize(previousPoints.size());
607 if (metricIdentityResults)
609 metricIdentityResults->resize(previousPoints.size());
614 worker->
executeFunction(
Worker::Function::createStatic(&AdvancedMotion::trackPointsSubPixelMirroredBorderSubset<tChannels, tSize>, &previousPyramid, ¤tPyramid, numberLayers, &previousPoints, &roughPoints, ¤tPoints, coarsestLayerRadius, subPixelIterations, metricResults ? metricResults->data() :
nullptr, metricIdentityResults ? metricIdentityResults->data() :
nullptr, 0u, 0u), 0u, (
unsigned int)(previousPoints.size()));
618 trackPointsSubPixelMirroredBorderSubset<tChannels, tSize>(&previousPyramid, ¤tPyramid, numberLayers, &previousPoints, &roughPoints, ¤tPoints, coarsestLayerRadius, subPixelIterations, metricResults ? metricResults->data() :
nullptr, metricIdentityResults ? metricIdentityResults->data() :
nullptr, 0u, (
unsigned int)(previousPoints.size()));
624 template <
typename TMetricInteger,
typename TMetricFloat>
625 template <
unsigned int tSize>
626 bool AdvancedMotion<TMetricInteger, TMetricFloat>::trackArbitraryPointsBidirectionalSubPixelMirroredBorder(
const CV::FramePyramid& previousPyramid,
const CV::FramePyramid& nextPyramid,
const unsigned int coarsestLayerRadius,
Vectors2& previousImagePoints,
Vectors2& nextImagePoints,
const Scalar maximalSqrError,
const SubRegion& previousSubRegion,
const unsigned int horizontalBins,
const unsigned int verticalBins,
const unsigned int strength,
Worker* worker,
const unsigned int trackingLayers)
628 ocean_assert(previousPyramid && nextPyramid);
630 ocean_assert(previousImagePoints.empty() && nextImagePoints.empty());
637 const unsigned int maximalTrackingLayers = min(trackingLayers, min(previousPyramid.
layers(), nextPyramid.
layers()));
639 for (
unsigned int n = 0u; n < maximalTrackingLayers; ++n)
641 const Frame& previousLayer = previousPyramid[n];
643 if (previousLayer.
width() < tSize || previousLayer.
height() < tSize)
659 const Scalar layerFactor =
Scalar((
unsigned int)(1 << n));
670 unsigned int windowLeft, windowTop, windowWidth, windowHeight;
671 if (!boundingBox.
box2integer(yFrame.
width(), yFrame.
height(), windowLeft, windowTop, windowWidth, windowHeight))
676 ocean_assert(windowWidth >= 1u && windowWidth <= yFrame.
width());
677 ocean_assert(windowHeight >= 1u && windowHeight <= yFrame.
height());
686 if (n == 0u && corners.size() < 50)
696 if (n == 0u && corners.size() < 20)
714 if (previousSubRegion.
isEmpty())
716 cornersSubRegion = std::move(corners);
720 cornersSubRegion.reserve(corners.size());
722 for (Detector::HarrisCorners::const_iterator i = corners.begin(); i != corners.end(); ++i)
724 if (previousSubRegion.
isInside(i->observation() * layerFactor))
726 cornersSubRegion.push_back(*i);
731 if (cornersSubRegion.empty())
736 std::sort(cornersSubRegion.begin(), cornersSubRegion.end());
739 if (!smallPreviousImagePoints.empty() && horizontalBins != 0u && verticalBins != 0u)
744 if (smallPreviousImagePoints.empty())
756 if (trackPointsBidirectionalSubPixelMirroredBorder<tSize>(previousSmall, nextSmall, coarsestLayerRadius, smallPreviousImagePoints, smallNextImagePoints, maximalSqrError, worker))
758 for (
unsigned int i = 0u; i < smallPreviousImagePoints.size(); ++i)
760 previousImagePoints.push_back(smallPreviousImagePoints[i] * layerFactor);
761 nextImagePoints.push_back(smallNextImagePoints[i] * layerFactor);
769 template <
typename TMetricInteger,
typename TMetricFloat>
770 template <
unsigned int tSize>
771 bool AdvancedMotion<TMetricInteger, TMetricFloat>::trackArbitraryPointsBidirectionalSubPixelMirroredBorder(
const Frame& previousFrame,
const Frame& nextFrame,
const unsigned int maximalOffset,
const unsigned int coarsestLayerRadius,
Vectors2& previousImagePoints,
Vectors2& nextImagePoints,
const Scalar maximalSqrError,
const SubRegion& previousSubRegion,
const unsigned int horizontalBins,
const unsigned int verticalBins,
const unsigned int strength,
const FramePyramid::DownsamplingMode downsamplingMode,
Worker* worker,
const unsigned int trackingLayers)
773 ocean_assert(previousFrame && nextFrame);
780 const unsigned int layers = min(trackingLayers,
FramePyramid::idealLayers(previousFrame.
width(), previousFrame.
height(), (tSize / 2u) * 4u, (tSize / 2u) * 4u, 2u, maximalOffset, coarsestLayerRadius));
787 const FramePyramid previousPyramid(previousFrame, downsamplingMode, layers,
false , worker);
788 const FramePyramid nextPyramid(nextFrame, downsamplingMode, layers,
false , worker);
790 return trackArbitraryPointsBidirectionalSubPixelMirroredBorder<tSize>(previousPyramid, nextPyramid, coarsestLayerRadius, previousImagePoints, nextImagePoints, maximalSqrError, previousSubRegion, horizontalBins, verticalBins, strength, worker, trackingLayers);
793 template <
typename TMetricInteger,
typename TMetricFloat>
794 template <
unsigned int tSize>
797 ocean_assert(previousPyramid && nextPyramid);
799 ocean_assert(!previousImagePoints.empty() && nextImagePoints.empty());
800 ocean_assert(!validIndices || validIndices->empty());
802 if (previousImagePoints.empty())
812 Vectors2 previousPointCandidates(std::move(previousImagePoints));
813 ocean_assert(previousImagePoints.empty());
816 Vectors2 nextPointCandidates(previousPointCandidates.size());
817 if (!trackPointsSubPixelMirroredBorder<tSize>(previousPyramid, nextPyramid, previousPointCandidates, previousPointCandidates, nextPointCandidates, coarsestLayerRadius, subPixelIterations, worker))
823 Vectors2 backwardsPreviousPointCandidates(previousPointCandidates.size());
824 if (!trackPointsSubPixelMirroredBorder<tSize>(nextPyramid, previousPyramid, nextPointCandidates, nextPointCandidates, backwardsPreviousPointCandidates, coarsestLayerRadius, subPixelIterations, worker))
829 ocean_assert(previousPointCandidates.size() == nextPointCandidates.size());
830 ocean_assert(previousPointCandidates.size() == backwardsPreviousPointCandidates.size());
833 previousImagePoints.reserve(previousPointCandidates.size());
835 nextImagePoints.clear();
836 nextImagePoints.reserve(previousPointCandidates.size());
838 if (validIndices !=
nullptr)
840 validIndices->clear();
841 validIndices->reserve(previousPointCandidates.size());
843 for (
size_t n = 0; n < previousPointCandidates.size(); ++n)
846 const Vector2 nextImagePoint(nextPointCandidates[n] + (previousPointCandidates[n] - backwardsPreviousPointCandidates[n]) *
Scalar(0.5));
848 previousImagePoints.push_back(previousPointCandidates[n]);
849 nextImagePoints.push_back(nextImagePoint);
854 validIndices->emplace_back(
Index32(n));
861 for (
size_t n = 0; n < previousPointCandidates.size(); ++n)
867 const Vector2 nextImagePoint(nextPointCandidates[n] + (previousPointCandidates[n] - backwardsPreviousPointCandidates[n]) *
Scalar(0.5));
871 previousImagePoints.push_back(previousPointCandidates[n]);
872 nextImagePoints.push_back(nextImagePoint);
878 ocean_assert(previousImagePoints.size() == nextImagePoints.size());
883 template <
typename TMetricInteger,
typename TMetricFloat>
884 template <
unsigned int tChannels,
unsigned int tSize>
887 ocean_assert(previousPyramid && nextPyramid);
891 ocean_assert(!previousImagePoints.empty() && nextImagePoints.empty());
892 ocean_assert(!validIndices || validIndices->empty());
894 if (previousImagePoints.empty())
904 Vectors2 previousPointCandidates(std::move(previousImagePoints));
905 ocean_assert(previousImagePoints.empty());
908 Vectors2 nextPointCandidates(previousPointCandidates.size());
909 if (!trackPointsSubPixelMirroredBorder<tChannels, tSize>(previousPyramid, nextPyramid, previousPointCandidates, previousPointCandidates, nextPointCandidates, coarsestLayerRadius, subPixelIterations, worker))
915 Vectors2 backwardsPreviousPointCandidates(previousPointCandidates.size());
916 if (!trackPointsSubPixelMirroredBorder<tChannels, tSize>(nextPyramid, previousPyramid, nextPointCandidates, nextPointCandidates, backwardsPreviousPointCandidates, coarsestLayerRadius, subPixelIterations, worker))
921 ocean_assert(previousPointCandidates.size() == nextPointCandidates.size());
922 ocean_assert(previousPointCandidates.size() == backwardsPreviousPointCandidates.size());
925 previousImagePoints.reserve(previousPointCandidates.size());
927 nextImagePoints.clear();
928 nextImagePoints.reserve(previousPointCandidates.size());
932 validIndices->clear();
933 validIndices->reserve(previousPointCandidates.size());
935 for (
size_t n = 0; n < previousPointCandidates.size(); ++n)
938 const Vector2 nextImagePoint(nextPointCandidates[n] + (previousPointCandidates[n] - backwardsPreviousPointCandidates[n]) *
Scalar(0.5));
940 previousImagePoints.push_back(previousPointCandidates[n]);
941 nextImagePoints.push_back(nextImagePoint);
946 validIndices->push_back((
unsigned int)(n));
953 for (
size_t n = 0; n < previousPointCandidates.size(); ++n)
959 const Vector2 nextImagePoint(nextPointCandidates[n] + (previousPointCandidates[n] - backwardsPreviousPointCandidates[n]) *
Scalar(0.5));
963 previousImagePoints.push_back(previousPointCandidates[n]);
964 nextImagePoints.push_back(nextImagePoint);
970 ocean_assert(previousImagePoints.size() == nextImagePoints.size());
975 template <
typename TMetricInteger,
typename TMetricFloat>
976 template <
unsigned int tSize>
977 bool AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointsBidirectionalSubPixelMirroredBorderWithRoughLocations(
const CV::FramePyramid& previousPyramid,
const CV::FramePyramid& nextPyramid,
const unsigned int coarsestLayerRadius,
Vectors2& previousImagePoints,
const Vectors2& roughNextImagePoints,
Vectors2& nextImagePoints,
const Scalar maximalSqrError,
Worker* worker,
Indices32* validIndices,
const unsigned int subPixelIterations)
979 ocean_assert(previousPyramid && nextPyramid);
982 ocean_assert(!previousImagePoints.empty() && nextImagePoints.empty());
983 ocean_assert(!validIndices || validIndices->empty());
985 ocean_assert(&previousImagePoints != &roughNextImagePoints);
987 if (previousImagePoints.empty())
997 Vectors2 previousPointCandidates(std::move(previousImagePoints));
998 ocean_assert(previousImagePoints.empty());
1001 Vectors2 nextPointCandidates(previousPointCandidates.size());
1002 if (!trackPointsSubPixelMirroredBorder<tSize>(previousPyramid, nextPyramid, previousPointCandidates, roughNextImagePoints, nextPointCandidates, coarsestLayerRadius, subPixelIterations, worker))
1008 Vectors2 backwardsPreviousPointCandidates(previousPointCandidates.size());
1009 if (!trackPointsSubPixelMirroredBorder<tSize>(nextPyramid, previousPyramid, nextPointCandidates, previousPointCandidates, backwardsPreviousPointCandidates, coarsestLayerRadius, subPixelIterations, worker))
1015 previousImagePoints.reserve(previousPointCandidates.size());
1017 nextImagePoints.clear();
1018 nextImagePoints.reserve(previousPointCandidates.size());
1022 validIndices->clear();
1023 validIndices->reserve(previousPointCandidates.size());
1026 for (
size_t n = 0; n < previousPointCandidates.size(); ++n)
1029 const Vector2 nextImagePoint(nextPointCandidates[n] + (previousPointCandidates[n] - backwardsPreviousPointCandidates[n]) *
Scalar(0.5));
1031 previousImagePoints.push_back(previousPointCandidates[n]);
1032 nextImagePoints.push_back(nextImagePoint);
1036 validIndices->push_back((
unsigned int)(n));
1043 for (
size_t n = 0; n < previousPointCandidates.size(); ++n)
1049 const Vector2 nextImagePoint(nextPointCandidates[n] + (previousPointCandidates[n] - backwardsPreviousPointCandidates[n]) *
Scalar(0.5));
1053 previousImagePoints.push_back(previousPointCandidates[n]);
1054 nextImagePoints.push_back(nextImagePoint);
1060 ocean_assert(previousImagePoints.size() == nextImagePoints.size());
1065 template <
typename TMetricInteger,
typename TMetricFloat>
1066 template <
unsigned int tChannels,
unsigned int tSize>
1067 bool AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointsBidirectionalSubPixelMirroredBorderWithRoughLocations(
const CV::FramePyramid& previousPyramid,
const CV::FramePyramid& nextPyramid,
const unsigned int coarsestLayerRadius,
Vectors2& previousImagePoints,
const Vectors2& roughNextImagePoints,
Vectors2& nextImagePoints,
const Scalar maximalSqrError,
Worker* worker,
Indices32* validIndices,
const unsigned int subPixelIterations)
1069 ocean_assert(previousPyramid && nextPyramid);
1075 ocean_assert(!previousImagePoints.empty() && nextImagePoints.empty());
1076 ocean_assert(!validIndices || validIndices->empty());
1078 ocean_assert(&previousImagePoints != &roughNextImagePoints);
1080 if (previousImagePoints.empty())
1085 if (!previousPyramid
1094 Vectors2 previousPointCandidates(std::move(previousImagePoints));
1095 ocean_assert(previousImagePoints.empty());
1098 Vectors2 nextPointCandidates(previousPointCandidates.size());
1099 if (!trackPointsSubPixelMirroredBorder<tChannels, tSize>(previousPyramid, nextPyramid, previousPointCandidates, roughNextImagePoints, nextPointCandidates, coarsestLayerRadius, subPixelIterations, worker))
1105 Vectors2 backwardsPreviousPointCandidates(previousPointCandidates.size());
1106 if (!trackPointsSubPixelMirroredBorder<tChannels, tSize>(nextPyramid, previousPyramid, nextPointCandidates, previousPointCandidates, backwardsPreviousPointCandidates, coarsestLayerRadius, subPixelIterations, worker))
1112 previousImagePoints.reserve(previousPointCandidates.size());
1114 nextImagePoints.clear();
1115 nextImagePoints.reserve(previousPointCandidates.size());
1119 validIndices->clear();
1120 validIndices->reserve(previousPointCandidates.size());
1123 for (
size_t n = 0; n < previousPointCandidates.size(); ++n)
1126 const Vector2 nextImagePoint(nextPointCandidates[n] + (previousPointCandidates[n] - backwardsPreviousPointCandidates[n]) *
Scalar(0.5));
1128 previousImagePoints.push_back(previousPointCandidates[n]);
1129 nextImagePoints.push_back(nextImagePoint);
1133 validIndices->push_back((
unsigned int)(n));
1140 for (
size_t n = 0; n < previousPointCandidates.size(); ++n)
1146 const Vector2 nextImagePoint(nextPointCandidates[n] + (previousPointCandidates[n] - backwardsPreviousPointCandidates[n]) *
Scalar(0.5));
1150 previousImagePoints.push_back(previousPointCandidates[n]);
1151 nextImagePoints.push_back(nextImagePoint);
1157 ocean_assert(previousImagePoints.size() == nextImagePoints.size());
1162 template <
typename TMetricInteger,
typename TMetricFloat>
1163 template <
unsigned int tSize>
1164 bool AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointsBidirectionalSubPixelMirroredBorder(
const Frame& previousFrame,
const Frame& nextFrame,
const unsigned int maximalOffset,
const unsigned int coarsestLayerRadius,
Vectors2& previousImagePoints,
Vectors2& nextImagePoints,
const Scalar maximalSqrError,
const FramePyramid::DownsamplingMode downsamplingMode,
Worker* worker,
Indices32* validIndices,
const unsigned int subPixelIterations)
1173 const unsigned int previousLayers =
FramePyramid::idealLayers(previousFrame.
width(), previousFrame.
height(), (tSize / 2u) * 4u, (tSize / 2u) * 4u, 2u, maximalOffset, coarsestLayerRadius);
1174 const unsigned int nextLayers =
FramePyramid::idealLayers(nextFrame.
width(), nextFrame.
height(), (tSize / 2u) * 4u, (tSize / 2u) * 4u, 2u, maximalOffset, coarsestLayerRadius);
1175 ocean_assert(previousLayers >= 1u && nextLayers >= 1u);
1177 const unsigned int layers = std::min(previousLayers, nextLayers);
1184 const FramePyramid previousPyramid(previousFrame, downsamplingMode, layers,
false , worker);
1185 const FramePyramid nextPyramid(nextFrame, downsamplingMode, layers,
false , worker);
1187 return trackPointsBidirectionalSubPixelMirroredBorder<tSize>(previousPyramid, nextPyramid, coarsestLayerRadius, previousImagePoints, nextImagePoints, maximalSqrError, worker, validIndices, subPixelIterations);
1190 template <
typename TMetricInteger,
typename TMetricFloat>
1191 template <
unsigned int tSize>
1194 ocean_assert(previousReferencePoints.empty());
1195 ocean_assert(currentReferencePoints.empty());
1197 ocean_assert(&previousReferencePoints != ¤tReferencePoints);
1199 ocean_assert(horizontalBins >= 1u);
1200 ocean_assert(verticalBins >= 1u);
1204 const unsigned int width = previousFrame.
width();
1205 const unsigned int height = previousFrame.
height();
1207 const unsigned int areaLeft = boundingBox ? boundingBox.
left() : 0u;
1208 const unsigned int areaTop = boundingBox ? boundingBox.
top() : 0u;
1209 const unsigned int areaWidth = boundingBox ? boundingBox.
width() : width;
1210 const unsigned int areaHeight = boundingBox ? boundingBox.
height() : height;
1212 ocean_assert(areaLeft + areaWidth <= width);
1213 ocean_assert(areaTop + areaHeight <= height);
1218 features.reserve(5000);
1220 ocean_assert(!features.empty());
1222 if (features.empty())
1227 std::sort(features.begin(), features.end());
1232 const uint8_t*
const maskData = maskFrame ? maskFrame.
constdata<uint8_t>() :
nullptr;
1233 const unsigned int maskStrideElements = maskFrame ? maskFrame.
strideElements() : 0u;
1235 previousReferencePoints.reserve(distribution.
bins());
1236 for (
unsigned int n = 0u; n < distribution.
bins(); ++n)
1238 const Indices32& indices = distribution[n];
1240 if (!indices.empty())
1242 ocean_assert(indices.front() < allPreviousReferencePoints.size());
1243 const Vector2& point = allPreviousReferencePoints[indices.front()];
1245 const unsigned int xPosition = (
unsigned int)(point.
x());
1246 const unsigned int yPosition = (
unsigned int)(point.
y());
1248 ocean_assert(xPosition < width);
1249 ocean_assert(yPosition < height);
1251 if (maskData ==
nullptr || maskData[yPosition * maskStrideElements + xPosition] == 0xFFu)
1253 previousReferencePoints.push_back(point);
1258 if (previousReferencePoints.empty())
1263 return trackPointsSubPixelMirroredBorder<tSize>(previousPyramid, currentPyramid, previousReferencePoints, previousReferencePoints, currentReferencePoints, 2u, 4u, worker);
1266 template <
typename TMetricInteger,
typename TMetricFloat>
1267 template <
unsigned int tChannels,
unsigned int tPatchSize>
1268 Vector2 AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointSubPixelMirroredBorder(
const uint8_t* frame0,
const uint8_t* frame1,
const unsigned int width0,
const unsigned int height0,
const unsigned int width1,
const unsigned int height1,
const unsigned int frame0PaddingElements,
const unsigned int frame1PaddingElements,
const Vector2& position0,
const unsigned int radiusX,
const unsigned int radiusY,
const Vector2& rough1,
const unsigned int subPixelIterations, uint32_t* metricResult, uint32_t* metricIdentityResult)
1270 static_assert(tChannels != 0u,
"Invalid number of data channels!");
1271 static_assert(tPatchSize % 2u == 1u,
"Invalid size of the image patch, must be odd!");
1273 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
1275 ocean_assert(frame0 !=
nullptr && frame1 !=
nullptr);
1277 ocean_assert(width0 >= tPatchSize && height0 >= tPatchSize);
1278 ocean_assert(width1 >= tPatchSize && height1 >= tPatchSize);
1280 ocean_assert(position0.
x() >=
Scalar(0) && position0.
x() <
Scalar(width0));
1281 ocean_assert(position0.
y() >=
Scalar(0) && position0.
y() <
Scalar(height0));
1285 const unsigned int leftCenter1 = (
unsigned int)(max(0,
int(position1.
x() - radiusX)));
1286 const unsigned int topCenter1 = (
unsigned int)(max(0,
int(position1.
y() - radiusY)));
1288 const unsigned int rightCenter1 = min(position1.
x() + radiusX, width1 - 1u);
1289 const unsigned int bottomCenter1 = min(position1.
y() + radiusY, height1 - 1u);
1293 uint8_t buffer0[tPatchSize * tPatchSize * tChannels];
1294 uint8_t buffer1[tPatchSize * tPatchSize * tChannels];
1296 const unsigned int x0 = (
unsigned int)(position0.
x());
1297 const unsigned int y0 = (
unsigned int)(position0.
y());
1299 if (x0 - tPatchSize_2 < width0 - tPatchSize && y0 - tPatchSize_2 < height0 - tPatchSize)
1301 ocean_assert(x0 >= tPatchSize_2 && x0 < width0 - (tPatchSize_2 + 1u) && y0 >= tPatchSize_2 && y0 < height0 - (tPatchSize_2 + 1u));
1302 AdvancedFrameInterpolatorBilinear::interpolateSquarePatch8BitPerChannel<tChannels, tPatchSize, PC_TOP_LEFT>(frame0, width0, frame0PaddingElements, buffer0, position0);
1306 ocean_assert(!(x0 >= tPatchSize_2 && x0 < width0 - (tPatchSize_2 + 1u) && y0 >= tPatchSize_2 && y0 < height0 - (tPatchSize_2 + 1u)));
1307 AdvancedFrameInterpolatorBilinear::interpolateSquareMirroredBorder8BitPerChannel<tChannels, tPatchSize>(frame0, width0, height0, frame0PaddingElements, buffer0, position0);
1311 uint32_t bestMetric = uint32_t(-1);
1312 unsigned int bestSqrDistance = (
unsigned int)(-1);
1314 for (
unsigned int y1 = topCenter1; y1 <= bottomCenter1; ++y1)
1316 for (
unsigned int x1 = leftCenter1; x1 <= rightCenter1; ++x1)
1318 uint32_t candidateMetric;
1320 if (x1 - tPatchSize_2 < width1 - tPatchSize && y1 - tPatchSize_2 < height1 - tPatchSize)
1322 candidateMetric = TMetricInteger::template patchBuffer8BitPerChannel<tChannels, tPatchSize>(frame1, width1, x1, y1, frame1PaddingElements, buffer0);
1326 constexpr
unsigned int buffer1PaddingElements = 0u;
1328 FrameConverter::patchFrameMirroredBorder<uint8_t, tChannels>(frame1, buffer1, width1, height1, x1, y1, tPatchSize, frame1PaddingElements, buffer1PaddingElements);
1330 candidateMetric = TMetricInteger::template buffer8BitPerChannel<tChannels, tPatchSize * tPatchSize>(buffer0, buffer1);
1335 if (candidateMetric < bestMetric || (candidateMetric == bestMetric && position1.
sqrDistance(position) < bestSqrDistance))
1337 bestMetric = candidateMetric;
1338 bestPosition = position;
1340 bestSqrDistance = position1.
sqrDistance(position);
1343 if (metricIdentityResult && x1 == position1.
x() && y1 == position1.
y())
1345 *metricIdentityResult = candidateMetric;
1350 ocean_assert(bestMetric != (
unsigned int)(-1) && bestPosition);
1352 ocean_assert(abs(
int(bestPosition.
x()) -
int(position1.
x())) <=
int(radiusX));
1353 ocean_assert(abs(
int(bestPosition.
y()) -
int(position1.
y())) <=
int(radiusY));
1357 *metricResult = bestMetric;
1360 return trackPointBufferSubPixelMirroredBorder<tChannels, tPatchSize>(buffer0, frame1, width1, height1, frame1PaddingElements,
Vector2(
Scalar(bestPosition.
x()),
Scalar(bestPosition.
y())), subPixelIterations, metricResult);
1363 template <
typename TMetricInteger,
typename TMetricFloat>
1364 template <
unsigned int tPatchSize>
1365 inline Vector2 AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointSubPixelMirroredBorder(
const uint8_t* frame0,
const uint8_t* frame1,
const unsigned int channels,
const unsigned int width0,
const unsigned int height0,
const unsigned int width1,
const unsigned int height1,
const unsigned int frame0PaddingElements,
const unsigned int frame1PaddingElements,
const Vector2& position0,
const unsigned int radiusX,
const unsigned int radiusY,
const Vector2& rough1,
const unsigned int subPixelIterations, uint32_t* metricResult, uint32_t* metricIdentityResult)
1367 ocean_assert(channels >= 1u);
1372 return trackPointSubPixelMirroredBorder<1u, tPatchSize>(frame0, frame1, width0, height0, width1, height1, frame0PaddingElements, frame1PaddingElements, position0, radiusX, radiusY, rough1, subPixelIterations, metricResult, metricIdentityResult);
1375 return trackPointSubPixelMirroredBorder<2u, tPatchSize>(frame0, frame1, width0, height0, width1, height1, frame0PaddingElements, frame1PaddingElements, position0, radiusX, radiusY, rough1, subPixelIterations, metricResult, metricIdentityResult);
1378 return trackPointSubPixelMirroredBorder<3u, tPatchSize>(frame0, frame1, width0, height0, width1, height1, frame0PaddingElements, frame1PaddingElements, position0, radiusX, radiusY, rough1, subPixelIterations, metricResult, metricIdentityResult);
1381 return trackPointSubPixelMirroredBorder<4u, tPatchSize>(frame0, frame1, width0, height0, width1, height1, frame0PaddingElements, frame1PaddingElements, position0, radiusX, radiusY, rough1, subPixelIterations, metricResult, metricIdentityResult);
1384 ocean_assert(
false &&
"Invalid pixel format!");
1388 template <
typename TMetricInteger,
typename TMetricFloat>
1389 template <
unsigned int tChannels,
unsigned int tPatchSize>
1392 static_assert(tChannels >= 1u,
"Invalid number of data channels!");
1393 static_assert(tPatchSize % 2u == 1u,
"Invalid size of the image patch, must be odd!");
1395 ocean_assert(buffer0 !=
nullptr && frame1 !=
nullptr);
1397 ocean_assert(width1 >= tPatchSize && height1 >= tPatchSize);
1399 ocean_assert(roughPosition1.
x() >=
Scalar(0) && roughPosition1.
x() <
Scalar(width1));
1400 ocean_assert(roughPosition1.
y() >=
Scalar(0) && roughPosition1.
y() <
Scalar(height1));
1402 uint32_t metricBest = uint32_t(-1);
1404 if (metricResult !=
nullptr)
1406 metricBest = *metricResult;
1409 const bool result = metricBest == TMetricFloat::template patchMirroredBorderBuffer8BitPerChannel<tChannels, tPatchSize>(frame1, width1, height1, roughPosition1.
x(), roughPosition1.
y(), frame1PaddingElements, buffer0);
1410 ocean_assert_and_suppress_unused(result, result);
1415 const unsigned int x1 = (
unsigned int)(roughPosition1.
x());
1416 const unsigned int y1 = (
unsigned int)(roughPosition1.
y());
1418 if (x1 - (tPatchSize / 2u) < width1 - tPatchSize && y1 - (tPatchSize / 2u) < height1 - tPatchSize)
1420 ocean_assert(x1 >= (tPatchSize / 2u) && y1 >= (tPatchSize / 2u) && x1 < width1 - (tPatchSize / 2u + 1u) && y1 < height1 - (tPatchSize / 2u + 1u));
1421 metricBest = TMetricFloat::template patchBuffer8BitPerChannel<tChannels, tPatchSize>(frame1, width1, roughPosition1.
x(), roughPosition1.
y(), frame1PaddingElements, buffer0);
1425 ocean_assert(!(x1 >= (tPatchSize / 2u) && y1 >= (tPatchSize / 2u) && x1 < width1 - (tPatchSize / 2u + 1u) && y1 < height1 - (tPatchSize / 2u + 1u)));
1426 metricBest = TMetricFloat::template patchMirroredBorderBuffer8BitPerChannel<tChannels, tPatchSize>(frame1, width1, height1, roughPosition1.
x(), roughPosition1.
y(), frame1PaddingElements, buffer0);
1430 constexpr
unsigned int numberSteps = 8u;
1432 const Vector2 steps[numberSteps] =
1445 Vector2 position1 = roughPosition1;
1447 for (
unsigned int n = 0u; n < subPixelIterations; ++n)
1449 Vector2 bestPosition1 = position1;
1453 for (
unsigned int i = 0u; i < numberSteps; ++i)
1455 const Vector2 candidatePosition1(position1.
x() + steps[i].
x() * offset, position1.
y() + steps[i].
y() * offset);
1457 if (candidatePosition1.
x() >=
Scalar(0) && candidatePosition1.
x() <
Scalar(width1) && candidatePosition1.
y() >=
Scalar(0) && candidatePosition1.
y() <
Scalar(height1))
1459 const unsigned int x1 = (
unsigned int)(candidatePosition1.
x());
1460 const unsigned int y1 = (
unsigned int)(candidatePosition1.
y());
1462 const uint32_t candidateMetric = (x1 - (tPatchSize / 2u) < width1 - tPatchSize && y1 - (tPatchSize / 2u) < height1 - tPatchSize) ?
1463 TMetricFloat::template patchBuffer8BitPerChannel<tChannels, tPatchSize>(frame1, width1, candidatePosition1.
x(), candidatePosition1.
y(), frame1PaddingElements, buffer0) :
1464 TMetricFloat::template patchMirroredBorderBuffer8BitPerChannel<tChannels, tPatchSize>(frame1, width1, height1, candidatePosition1.
x(), candidatePosition1.
y(), frame1PaddingElements, buffer0);
1466 if (candidateMetric < metricBest)
1468 metricBest = candidateMetric;
1469 bestPosition1 = candidatePosition1;
1475 position1 = bestPosition1;
1479 if (metricResult !=
nullptr)
1481 *metricResult = metricBest;
1484 ocean_assert(position1.
x() >= 0 && position1.
y() >= 0);
1485 ocean_assert(position1.
x() <
Scalar(width1) && position1.
y() <
Scalar(height1));
1490 template <
typename TMetricInteger,
typename TMetricFloat>
1491 template <
unsigned int tSize>
1492 void AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointsSubPixelMirroredBorderSubset(
const FramePyramid* previousPyramid,
const FramePyramid* nextPyramid,
const unsigned int numberLayers,
const Vectors2* previousPoints,
const Vectors2* roughNextPoints,
Vectors2* nextPoints,
const unsigned int coarsestLayerRadius,
const unsigned int subPixelIterations,
unsigned int* metricResults,
unsigned int* metricIdentityResults,
const unsigned int firstPoint,
const unsigned int numberPoints)
1494 static_assert(tSize % 2u == 1u,
"Invalid patch size, must be odd!");
1496 ocean_assert(previousPyramid !=
nullptr && nextPyramid !=
nullptr);
1497 ocean_assert(previousPoints !=
nullptr && nextPoints !=
nullptr);
1499 ocean_assert(previousPyramid->
isValid() && nextPyramid->
isValid());
1504 ocean_assert(roughNextPoints ==
nullptr || previousPoints->size() == roughNextPoints->size());
1505 ocean_assert(nextPoints->size() == previousPoints->size());
1507 ocean_assert(firstPoint + numberPoints <= previousPoints->size());
1509 ocean_assert(numberLayers >= 1u);
1510 ocean_assert(numberLayers <= previousPyramid->layers());
1511 ocean_assert(numberLayers <= nextPyramid->layers());
1513 ocean_assert(previousPyramid->
layer(numberLayers - 1u).
width() >= tSize / 2u);
1514 ocean_assert(previousPyramid->
layer(numberLayers - 1u).
height() >= tSize / 2u);
1521 ocean_assert(coarsetsWidthNextPyramid >= 1u && coarsetsHeightNextPyramid >= 1u);
1524 ocean_assert(channels >= 1u && channels <= 4u);
1526 for (
unsigned int n = firstPoint; n < firstPoint + numberPoints; ++n)
1528 const Vector2& roughNextPoint = roughNextPoints !=
nullptr ? (*roughNextPoints)[n] : (*previousPoints)[n];
1530 const Scalar x = min(roughNextPoint.
x() * coarsetsLayerFactorNextPyramid, coarsetsWidthNextPyramid -
Scalar(1));
1531 const Scalar y = min(roughNextPoint.
y() * coarsetsLayerFactorNextPyramid, coarsetsHeightNextPyramid -
Scalar(1));
1533 intermediateRoughNextPoints[n] =
Vector2(x, y);
1536 for (
unsigned int layerIndex = numberLayers - 1u; layerIndex < numberLayers; --layerIndex)
1538 const Frame& previousLayer = (*previousPyramid)[layerIndex];
1539 const Frame& nextLayer = (*nextPyramid)[layerIndex];
1541 const uint8_t*
const previousLayerData = previousLayer.
constdata<uint8_t>();
1542 const uint8_t*
const nextLayerData = nextLayer.
constdata<uint8_t>();
1544 const unsigned int previousLayerPaddingElements = previousLayer.
paddingElements();
1545 const unsigned int nextLayerPaddingElements = nextLayer.
paddingElements();
1547 const unsigned int previousLayerWidth = previousLayer.
width();
1548 const unsigned int previousLayerHeight = previousLayer.
height();
1550 const unsigned int nextLayerWidth = nextLayer.
width();
1551 const unsigned int nextLayerHeight = nextLayer.
height();
1553 if (layerIndex == 0u)
1557 const unsigned int layerRadiusX = numberLayers == 1u ? coarsestLayerRadius : 2u;
1558 const unsigned int layerRadiusY = numberLayers == 1u ? coarsestLayerRadius : 2u;
1560 for (
unsigned int pointIndex = firstPoint; pointIndex < firstPoint + numberPoints; ++pointIndex)
1562 const Vector2& previousPosition = (*previousPoints)[pointIndex];
1563 ocean_assert(previousPosition.
x() >=
Scalar(0) && previousPosition.
y() >=
Scalar(0));
1564 ocean_assert(previousPosition.
x() <
Scalar(previousLayerWidth) && previousPosition.
y() <
Scalar(previousLayerHeight));
1566 const Vector2& intermediateRoughNextPoint = intermediateRoughNextPoints[pointIndex];
1567 ocean_assert(intermediateRoughNextPoint.
x() >=
Scalar(0) && intermediateRoughNextPoint.
y() >=
Scalar(0));
1568 ocean_assert(intermediateRoughNextPoint.
x() <
Scalar(nextLayerWidth) && intermediateRoughNextPoint.
y() <
Scalar(nextLayerHeight));
1570 unsigned int*
const metricResult = metricResults ? metricResults + pointIndex :
nullptr;
1571 unsigned int*
const metricIdentityResult = metricIdentityResults ? metricIdentityResults + pointIndex :
nullptr;
1573 const Vector2 nextPoint = trackPointSubPixelMirroredBorder<tSize>(previousLayerData, nextLayerData, channels, previousLayerWidth, previousLayerHeight, nextLayerWidth, nextLayerHeight, previousLayerPaddingElements, nextLayerPaddingElements, previousPosition, layerRadiusX, layerRadiusY, intermediateRoughNextPoint, subPixelIterations, metricResult, metricIdentityResult);
1575 ocean_assert(nextPoint.
x() >= 0 && nextPoint.
x() <
Scalar(nextLayerWidth));
1576 ocean_assert(nextPoint.
y() >= 0 && nextPoint.
y() <
Scalar(nextLayerHeight));
1578 ocean_assert(pointIndex < nextPoints->size());
1579 (*nextPoints)[pointIndex] = nextPoint;
1584 ocean_assert(layerIndex > 0u);
1586 const unsigned int layerRadius = (layerIndex == numberLayers - 1u) ? coarsestLayerRadius : 2u;
1590 const Scalar finerNextLayerWidth1 =
Scalar((*nextPyramid)[layerIndex - 1u].width()) -
Scalar(1);
1591 const Scalar finerNextLayerHeight1 =
Scalar((*nextPyramid)[layerIndex - 1u].height()) -
Scalar(1);
1593 for (
unsigned int pointIndex = firstPoint; pointIndex < firstPoint + numberPoints; ++pointIndex)
1595 ocean_assert(intermediateRoughNextPoints[pointIndex].x() >=
Scalar(0) && intermediateRoughNextPoints[pointIndex].y() >=
Scalar(0));
1596 ocean_assert(intermediateRoughNextPoints[pointIndex].x() <
Scalar(nextLayerWidth) && intermediateRoughNextPoints[pointIndex].y() <
Scalar(nextLayerHeight));
1599 ocean_assert(intermediateRoughNextPoint.
x() < nextLayerWidth && intermediateRoughNextPoint.
y() < nextLayerHeight);
1601 unsigned int*
const metricResult = metricResults ? metricResults + pointIndex :
nullptr;
1603 const Vector2& previousPointFinestLayer = (*previousPoints)[pointIndex];
1605 const PixelPosition previousPoint(std::min(
Numeric::round32(previousPointFinestLayer.
x() * layerFactor),
int(previousLayerWidth - 1u)), std::min(
Numeric::round32(previousPointFinestLayer.
y() * layerFactor),
int(previousLayerHeight - 1u)));
1607 ocean_assert(previousPoint.
x() < previousLayerWidth && previousPoint.
y() < previousLayerHeight);
1608 if (previousPoint.
x() < previousLayerWidth && previousPoint.
y() < previousLayerHeight)
1610 const PixelPosition nextPoint =
Motion<TMetricInteger>::template pointMotionInFrameMirroredBorder<tSize>(previousLayerData, nextLayerData, channels, previousLayerWidth, previousLayerHeight, nextLayerWidth, nextLayerHeight, previousPoint, layerRadius, layerRadius, previousLayerPaddingElements, nextLayerPaddingElements, intermediateRoughNextPoint, metricResult);
1612 ocean_assert(nextPoint.
x() < nextLayerWidth && nextPoint.
y() < nextLayerHeight);
1614 intermediateRoughNextPoints[pointIndex] =
Vector2(min(
Scalar(nextPoint.
x() * 2u), finerNextLayerWidth1), min(
Scalar(nextPoint.
y() * 2u), finerNextLayerHeight1));
1616 ocean_assert(intermediateRoughNextPoints[pointIndex].x() >= 0 && intermediateRoughNextPoints[pointIndex].x() <= finerNextLayerWidth1);
1617 ocean_assert(intermediateRoughNextPoints[pointIndex].y() >= 0 && intermediateRoughNextPoints[pointIndex].y() <= finerNextLayerHeight1);
1621 ocean_assert(
false &&
"This should never happen!");
1623 intermediateRoughNextPoints[pointIndex] =
Vector2(previousPointFinestLayer.
x() * layerFactor *
Scalar(2), previousPointFinestLayer.
y() * layerFactor *
Scalar(2));
1625 ocean_assert(intermediateRoughNextPoints[pointIndex].x() >= 0 && intermediateRoughNextPoints[pointIndex].x() < finerNextLayerWidth1);
1626 ocean_assert(intermediateRoughNextPoints[pointIndex].y() >= 0 && intermediateRoughNextPoints[pointIndex].y() < finerNextLayerHeight1);
1633 template <
typename TMetricInteger,
typename TMetricFloat>
1634 template <
unsigned int tChannels,
unsigned int tSize>
1635 void AdvancedMotion<TMetricInteger, TMetricFloat>::trackPointsSubPixelMirroredBorderSubset(
const FramePyramid* previousPyramid,
const FramePyramid* currentPyramid,
const unsigned int numberLayers,
const Vectors2* previousPoints,
const Vectors2* roughPoints,
Vectors2* currentPoints,
const unsigned int coarsestLayerRadius,
const unsigned int subPixelIterations,
unsigned int* metricResults,
unsigned int* metricIdentityResults,
const unsigned int firstPoint,
const unsigned int numberPoints)
1637 static_assert(tSize % 2u == 1u,
"Invalid patch size, must be odd!");
1639 ocean_assert(previousPyramid && currentPyramid);
1640 ocean_assert(previousPoints && roughPoints && currentPoints);
1642 ocean_assert(*previousPyramid && *currentPyramid);
1650 ocean_assert(previousPoints->size() == roughPoints->size());
1651 ocean_assert(currentPoints->size() == previousPoints->size());
1653 ocean_assert(firstPoint + numberPoints <= previousPoints->size());
1655 ocean_assert(numberLayers >= 1u);
1656 ocean_assert(numberLayers <= previousPyramid->layers());
1657 ocean_assert(numberLayers <= currentPyramid->layers());
1659 ocean_assert(previousPyramid->
layer(numberLayers - 1u).
width() >= tSize / 2u);
1660 ocean_assert(previousPyramid->
layer(numberLayers - 1u).
height() >= tSize / 2u);
1667 ocean_assert(lowestCurrentWidth >= 1u && lowestCurrentHeight >= 1u);
1670 ocean_assert_and_suppress_unused(channels >= 1u && channels <= 4u, channels);
1672 for (
unsigned int n = firstPoint; n < firstPoint + numberPoints; ++n)
1674 const Vector2& roughPoint = (*roughPoints)[n];
1676 const Scalar x = min(roughPoint.
x() * lowestLayerFactor, lowestCurrentWidth - 1);
1677 const Scalar y = min(roughPoint.
y() * lowestLayerFactor, lowestCurrentHeight - 1);
1679 intermediateRoughPoints[n] =
Vector2(x, y);
1682 for (
int l =
int(numberLayers) - 1; l >= 0; --l)
1684 const Frame previousFrame = (*previousPyramid)[l];
1685 const Frame currentFrame = (*currentPyramid)[l];
1687 const uint8_t*
const previousFrameData = previousFrame.
constdata<uint8_t>();
1688 const uint8_t*
const currentFrameData = currentFrame.
constdata<uint8_t>();
1690 const unsigned int previousFramePaddingElements = previousFrame.
paddingElements();
1691 const unsigned int currentFramePaddingElements = currentFrame.
paddingElements();
1693 const unsigned int previousWidth = previousFrame.
width();
1694 const unsigned int previousHeight = previousFrame.
height();
1696 const unsigned int currentWidth = currentFrame.
width();
1697 const unsigned int currentHeight = currentFrame.
height();
1702 const unsigned int layerRadiusX = numberLayers == 1u ? coarsestLayerRadius : 2u;
1703 const unsigned int layerRadiusY = numberLayers == 1u ? coarsestLayerRadius : 2u;
1705 for (
unsigned int i = firstPoint; i < firstPoint + numberPoints; ++i)
1707 ocean_assert(intermediateRoughPoints[i].x() >=
Scalar(0) && intermediateRoughPoints[i].y() >=
Scalar(0));
1708 ocean_assert(intermediateRoughPoints[i].x() <
Scalar(currentWidth) && intermediateRoughPoints[i].y() <
Scalar(currentHeight));
1710 const Vector2& intermediateRoughPoint = intermediateRoughPoints[i];
1712 unsigned int*
const metricResult = metricResults ? metricResults + i :
nullptr;
1713 unsigned int*
const metricIdentityResult = metricIdentityResults ? metricIdentityResults + i :
nullptr;
1715 const Vector2& previousPosition = (*previousPoints)[i];
1717 ocean_assert(previousPosition.
x() >=
Scalar(0) && previousPosition.
y() >=
Scalar(0));
1718 ocean_assert(previousPosition.
x() <
Scalar(previousWidth) && previousPosition.
y() <
Scalar(previousHeight));
1720 const Vector2 position(trackPointSubPixelMirroredBorder<tChannels, tSize>(previousFrameData, currentFrameData, previousWidth, previousHeight, currentWidth, currentHeight, previousFramePaddingElements, currentFramePaddingElements, previousPosition, layerRadiusX, layerRadiusY, intermediateRoughPoint, subPixelIterations, metricResult, metricIdentityResult));
1722 ocean_assert(position.
x() >= 0 && position.
x() <
Scalar(currentWidth));
1723 ocean_assert(position.
y() >= 0 && position.
y() <
Scalar(currentHeight));
1725 ocean_assert(i < currentPoints->size());
1726 (*currentPoints)[i] = position;
1731 ocean_assert(l > 0);
1733 const unsigned int layerRadiusX = (l == int(numberLayers) - 1) ? coarsestLayerRadius : 2u;
1734 const unsigned int layerRadiusY = (l == int(numberLayers) - 1) ? coarsestLayerRadius : 2u;
1736 for (
unsigned int i = firstPoint; i < firstPoint + numberPoints; ++i)
1738 ocean_assert(intermediateRoughPoints[i].x() >=
Scalar(0) && intermediateRoughPoints[i].y() >=
Scalar(0));
1739 ocean_assert(intermediateRoughPoints[i].x() <
Scalar(currentWidth) && intermediateRoughPoints[i].y() <
Scalar(currentHeight));
1743 unsigned int*
const metricResult = metricResults ? metricResults + i :
nullptr;
1747 min(
Numeric::round32((*previousPoints)[i].y() * layerFactor),
int(previousHeight) - 1));
1749 if (previousPosition.
x() < previousWidth && previousPosition.
y() < previousHeight)
1751 const PixelPosition position(
Motion<TMetricInteger>::template pointMotionInFrameMirroredBorder<tChannels, tSize>(previousFrameData, currentFrameData, previousWidth, previousHeight, currentWidth, currentHeight, previousPosition, layerRadiusX, layerRadiusY, previousFramePaddingElements, currentFramePaddingElements, intermediateRoughPoint, metricResult));
1753 ocean_assert(position.
x() < currentWidth && position.
y() < currentHeight);
1755 const Scalar higherWidth =
Scalar((*currentPyramid)[l - 1].width());
1756 const Scalar higherHeight =
Scalar((*currentPyramid)[l - 1].height());
1758 intermediateRoughPoints[i] =
Vector2(min(
Scalar(position.
x() * 2u), higherWidth - 1), min(
Scalar(position.
y() * 2u), higherHeight - 1));
1760 ocean_assert(intermediateRoughPoints[i].x() >= 0 && intermediateRoughPoints[i].x() <
Scalar(higherWidth));
1761 ocean_assert(intermediateRoughPoints[i].y() >= 0 && intermediateRoughPoints[i].y() <
Scalar(higherHeight));
1765 intermediateRoughPoints[i] =
Vector2((*previousPoints)[i].x() * layerFactor *
Scalar(2), (*previousPoints)[i].y() * layerFactor *
Scalar(2));
1767 ocean_assert(intermediateRoughPoints[i].x() >= 0 && intermediateRoughPoints[i].x() <
Scalar(currentFrame.
width() * 2u));
1768 ocean_assert(intermediateRoughPoints[i].y() >= 0 && intermediateRoughPoints[i].y() <
Scalar(currentFrame.
height() * 2u));
bool isValid() const
Returns whether the box holds valid parameters.
Definition: Box2.h:766
bool box2integer(const int constraintLeft, const int constraintTop, const int constraintRight, const int constraintBottom, int &intersectionLeft, int &intersectionTop, unsigned int &intersectionWidth, unsigned int &intersectionHeight) const
Calculates the intersection of this bounding box (with floating point accuracy) and a second bounding...
Definition: Box2.h:928
This class implements advanced motion techniques (mainly with sub-pixel accuracy or binary masks) all...
Definition: AdvancedMotion.h:69
static bool trackPointsBidirectionalSubPixelMirroredBorder(const CV::FramePyramid &previousPyramid, const CV::FramePyramid &nextPyramid, const unsigned int coarsestLayerRadius, Vectors2 &previousImagePoints, Vectors2 &nextImagePoints, const Scalar maximalSqrError=Scalar(0.9 *0.9), Worker *worker=nullptr, Indices32 *validIndices=nullptr, const unsigned int subPixelIterations=4u)
Tracks a set of given points between two frame pyramids with sub-pixel accuracy.
Definition: AdvancedMotion.h:795
static bool trackPointsSubPixelMirroredBorder(const Frame &previousFrame, const Frame ¤tFrame, const Vectors2 &previousPoints, const Vectors2 &roughPoints, Vectors2 ¤tPoints, const unsigned int maximalOffset, const unsigned int coarsestLayerRadius, const FramePyramid::DownsamplingMode downsamplingMode=FramePyramid::DM_FILTER_14641, const unsigned int subPixelIterations=4u, Worker *worker=nullptr, MetricResults *metricResults=nullptr, MetricResults *metricIdentityResults=nullptr)
Tracks a set of given points between two frames, with sub-pixel accuracy.
Definition: AdvancedMotion.h:500
static Vector2 trackPointSubPixelMirroredBorder(const uint8_t *frame0, const uint8_t *frame1, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const unsigned int frame0PaddingElements, const unsigned int frame1PaddingElements, const Vector2 &position0, const unsigned int radiusX, const unsigned int radiusY, const Vector2 &rough1=Vector2(Numeric::maxValue(), Numeric::maxValue()), const unsigned int subPixelIterations=4u, uint32_t *metricResult=nullptr, uint32_t *metricIdentityResult=nullptr)
Tracks the location of one given 2D point from one image to another image with sub-pixel precision by...
Definition: AdvancedMotion.h:1268
std::vector< uint32_t > MetricResults
Definition of a vector holding metric results.
Definition: AdvancedMotion.h:75
static bool trackArbitraryPointsBidirectionalSubPixelMirroredBorder(const CV::FramePyramid &previousPyramid, const CV::FramePyramid &nextPyramid, const unsigned int coarsestLayerRadius, Vectors2 &previousImagePoints, Vectors2 &nextImagePoints, const Scalar maximalSqrError=Scalar(0.9 *0.9), const SubRegion &previousSubRegion=SubRegion(), const unsigned int horizontalBins=0u, const unsigned int verticalBins=0u, const unsigned int strength=30u, Worker *worker=nullptr, const unsigned int trackingLayers=1u)
Tracks a set of arbitrary (unknown) points between two frame pyramids with sub-pixel accuracy.
Definition: AdvancedMotion.h:626
static Vector2 trackPointBufferSubPixelMirroredBorder(const uint8_t *buffer0, const uint8_t *frame1, const unsigned int width1, const unsigned int height1, const unsigned int frame1PaddingElements, const Vector2 &roughPosition1, const unsigned int subPixelIterations, uint32_t *metricResult=nullptr)
Tracks the location of one given 2D point from one image to another image with sub-pixel precision by...
Definition: AdvancedMotion.h:1390
static bool trackPointsBidirectionalSubPixelMirroredBorderWithRoughLocations(const CV::FramePyramid &previousPyramid, const CV::FramePyramid &nextPyramid, const unsigned int coarsestLayerRadius, Vectors2 &previousImagePoints, const Vectors2 &roughNextImagePoints, Vectors2 &nextImagePoints, const Scalar maximalSqrError=Scalar(0.9 *0.9), Worker *worker=nullptr, Indices32 *validIndices=nullptr, const unsigned int subPixelIterations=4u)
Tracks a set of given points between two frame pyramids with sub-pixel accuracy.
Definition: AdvancedMotion.h:977
static bool trackReliableReferencePoints(const FramePyramid &previousPyramid, const FramePyramid ¤tPyramid, Vectors2 &previousReferencePoints, Vectors2 ¤tReferencePoints, const unsigned int horizontalBins=16u, const unsigned int verticalBins=16u, const PixelBoundingBox &boundingBox=PixelBoundingBox(), const Frame &maskFrame=Frame(), Worker *worker=nullptr)
Detects and tracks reliable arbitrary reference points between two frames.
Definition: AdvancedMotion.h:1192
static void trackPointsSubPixelMirroredBorderSubset(const FramePyramid *previousPyramid, const FramePyramid *nextPyramid, const unsigned int numberLayers, const Vectors2 *previousPoints, const Vectors2 *roughNextPoints, Vectors2 *nextPoints, const unsigned int coarsestLayerRadius, const unsigned int subPixelIterations, unsigned int *metricResults, unsigned int *metricIdentityResults, const unsigned int firstPoint, const unsigned int numberPoints)
Tracks a subset of given points between two frame pyramids with sub-pixel accuracy.
Definition: AdvancedMotion.h:1492
static bool trackPointsSubPixelMask(const FramePyramid &previousPyramid, const FramePyramid ¤tPyramid, const FramePyramid &previousMaskPyramid, const FramePyramid ¤tMaskPyramid, const Vectors2 &previousPoints, const Vectors2 &roughCurrentPoints, Vectors2 ¤tPoints, const unsigned int coarsestLayerRadius, const unsigned int subPixelIterations=4u, Worker *worker=nullptr)
Tracks a set of given points between two frame pyramids with sub-pixel accuracy while each pyramid la...
static bool trackPointsMask(const FramePyramid &previousPyramid, const FramePyramid ¤tPyramid, const FramePyramid &previousMaskPyramid, const FramePyramid ¤tMaskPyramid, const PixelPositions &previousPoints, const PixelPositions &roughCurrentPoints, PixelPositions ¤tPoints, const unsigned int coarsestLayerRadius, Worker *worker=nullptr)
Tracks a set of given points between two frame pyramids with pixel accuracy while each pyramid layer ...
static bool detectCorners(const uint8_t *yFrame, const unsigned int width, const unsigned int height, const unsigned int yFramePaddingElements, const unsigned int threshold, const bool frameIsUndistorted, HarrisCorners &corners, const bool determineExactPosition=false, Worker *worker=nullptr)
Detects Harris corners inside a given 8 bit grayscale image.
Definition: HarrisCornerDetector.h:397
static Geometry::ImagePoints corners2imagePoints(const HarrisCorners &corners)
Converts Harris corners to simple 2D image positions.
Definition: HarrisCorner.h:110
static bool convert(const Frame &source, const FrameType::PixelFormat targetPixelFormat, const FrameType::PixelOrigin targetPixelOrigin, Frame &target, const bool forceCopy=true, Worker *worker=nullptr, const Options &options=Options())
Converts a frame with arbitrary dimension, pixel format and pixel origin into a frame with the same d...
@ CP_AVOID_COPY_IF_POSSIBLE
Tries to avoid copying the frame data whenever possible.
Definition: FrameConverter.h:96
This class implements a frame pyramid.
Definition: FramePyramid.h:37
const Frame & finestLayer() const
Returns the finest layer frame of this pyramid.
Definition: FramePyramid.h:735
static unsigned int idealLayers(const unsigned int width, const unsigned int height, const unsigned int invalidCoarsestWidthOrHeight, unsigned int *coarsestLayerWidth=nullptr, unsigned int *coarsestLayerHeight=nullptr)
Determines the number of layers until an invalid frame size would be reached in the next layer.
unsigned int finestWidth() const
Returns the width of the finest (first) layer.
Definition: FramePyramid.h:778
bool isValid() const
Returns whether this pyramid holds at least one frame layer.
Definition: FramePyramid.h:863
DownsamplingMode
Definition of individual down sampling modes.
Definition: FramePyramid.h:44
@ DM_FILTER_14641
Down sampling is realized by a 5x5 Gaussian filter.
Definition: FramePyramid.h:72
unsigned int layers() const
Returns the number of layers this pyramid holds.
Definition: FramePyramid.h:761
const FrameType & frameType() const
Returns the frame type of the finest layer.
Definition: FramePyramid.h:811
unsigned int finestHeight() const
Returns the height of the finest (first) layer.
Definition: FramePyramid.h:784
static constexpr unsigned int sizeFactor(const unsigned int layer)
Returns the size factor of a specified layer in relation to the finest layer.
Definition: FramePyramid.h:834
const Frame & layer(const unsigned int layer) const
Returns the frame of a specified layer.
Definition: FramePyramid.h:723
This class implements patch-based motion techniques.
Definition: Motion.h:59
T left() const
Returns the left (including) pixel position of this bounding box.
Definition: PixelBoundingBox.h:416
unsigned int width() const
Returns the width (the number of horizontal including pixels) of this bounding box.
Definition: PixelBoundingBox.h:482
T top() const
Returns the top (including) pixel position of this bounding box.
Definition: PixelBoundingBox.h:423
unsigned int height() const
Returns the height (the number of vertical including pixels) of this bounding box.
Definition: PixelBoundingBox.h:489
T y() const
Returns the vertical coordinate position of this object.
Definition: PixelPosition.h:470
unsigned int sqrDistance(const PixelPositionT< T > &position) const
Returns the square difference between two pixel positions.
Definition: PixelPosition.h:489
static PixelPositionT< unsigned int > vector2pixelPosition(const Vector2 &value)
Converts a 2D vector into a pixel position.
T x() const
Returns the horizontal coordinate position of this object.
Definition: PixelPosition.h:458
This class implement a sub-region either defined by 2D triangles or defined by a binary mask.
Definition: SubRegion.h:32
const Box2 & boundingBox() const
Returns the bounding box of this sub-region.
Definition: SubRegion.h:218
bool isEmpty() const
Returns whether this sub-region is empty.
Definition: SubRegion.h:223
bool isInside(const Vector2 &point) const
Returns whether a given point lies inside this sub-region.
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:2876
This class implements Ocean's image class.
Definition: Frame.h:1792
unsigned int strideElements(const unsigned int planeIndex=0u) const
Returns the number of elements within one row, including optional padding at the end of a row for a s...
Definition: Frame.h:4058
const T * constdata(const unsigned int planeIndex=0u) const
Returns a pointer to the read-only pixel data of a specific plane.
Definition: Frame.h:4168
const FrameType & frameType() const
Returns the frame type of this frame.
Definition: Frame.h:3775
bool isValid() const
Returns whether this frame is valid.
Definition: Frame.h:4448
unsigned int paddingElements(const unsigned int planeIndex=0u) const
Returns the optional number of padding elements at the end of each row for a specific plane.
Definition: Frame.h:4042
@ FORMAT_Y8
Pixel format for grayscale images with byte order Y and 8 bits per pixel.
Definition: Frame.h:594
unsigned int width() const
Returns the width of the frame format in pixel.
Definition: Frame.h:3143
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition: Frame.h:3188
static bool arePixelFormatsCompatible(const PixelFormat pixelFormatA, const PixelFormat pixelFormatB)
Returns whether two given pixel formats are compatible.
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition: Frame.h:3153
unsigned int height() const
Returns the height of the frame in pixel.
Definition: Frame.h:3148
bool isPixelFormatCompatible(const PixelFormat pixelFormat) const
Returns whether the pixel format of this frame type is compatible with a given pixel format.
Definition: Frame.h:3198
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition: Frame.h:3173
unsigned int bins() const
Returns the number of bins this distribution holds.
Definition: SpatialDistribution.h:1089
This class implements a distribution array.
Definition: SpatialDistribution.h:228
static DistributionArray distributeToArray(const ImagePoint *imagePoints, const size_t number, const Scalar left, const Scalar top, const Scalar width, const Scalar height, const unsigned int averagePointsPerBin, const unsigned int maxHorizontalBins, const unsigned int maxVerticalBins, unsigned int &horizontalBins, unsigned int &verticalBins)
Distributes the given 2D image points into a spatial array.
Definition: SpatialDistribution.h:1686
static ImagePoints distributeAndFilter(const ImagePoint *imagePoints, const size_t numberImagePoints, const Scalar left, const Scalar top, const Scalar width, const Scalar height, const unsigned int horizontalBins, const unsigned int verticalBins)
Distributes the given image points into an array of specified size and returns (at most) one point fr...
Definition: SpatialDistribution.h:1714
static constexpr int32_t round32(const T value)
Returns the rounded 32 bit integer value of a given value.
Definition: Numeric.h:2064
static constexpr T maxValue()
Returns the max scalar value.
Definition: Numeric.h:3244
This class implements a vector with shifted elements.
Definition: ShiftVector.h:27
const T & x() const noexcept
Returns the x value.
Definition: Vector2.h:698
const T & y() const noexcept
Returns the y value.
Definition: Vector2.h:710
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:1089
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
uint32_t Index32
Definition of a 32 bit index value.
Definition: Base.h:84
std::vector< PixelPosition > PixelPositions
Definition of a vector holding pixel positions (with positive coordinate values).
Definition: PixelPosition.h:48
PixelBoundingBoxT< unsigned int > PixelBoundingBox
Definition of the default PixelBoundingBox object with data type allowing only positive coordinate va...
Definition: PixelBoundingBox.h:21
AdvancedMotion< ZeroMeanSumSquareDifferences, AdvancedZeroMeanSumSquareDifferences > AdvancedMotionZeroMeanSSD
Definition of an AdvancedMotion class that applies zero-mean sum square difference calculations as me...
Definition: AdvancedMotion.h:58
AdvancedMotion< SumSquareDifferences, AdvancedSumSquareDifferences > AdvancedMotionSSD
Definition of an AdvancedMotion class that applies sum square difference calculations as metric.
Definition: AdvancedMotion.h:44
std::vector< HarrisCorner > HarrisCorners
Definition of a vector holding Harris corners.
Definition: HarrisCorner.h:24
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
BoxT2< Scalar > Box2
Definition of the Box2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single or...
Definition: Box2.h:22
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15