32#ifndef META_OCEAN_CV_DETECTOR_FREAK_DESCRIPTOR_H
33#define META_OCEAN_CV_DETECTOR_FREAK_DESCRIPTOR_H
62template <
size_t tSize>
63class FREAKDescriptorT;
218template <
size_t tSize>
221 static_assert(tSize == 32 || tSize == 64,
"Invalid size!");
300 static constexpr size_t size();
355 template <
typename TImagePo
int>
393 template <
typename TImagePo
int>
414 static bool extractHarrisCornersAndComputeDescriptors(
const Frame& yFrame,
const unsigned int maxFrameArea,
const unsigned int minFrameArea,
const unsigned int expectedHarrisCorners640x480,
const Scalar harrisCornersReductionScale,
const unsigned int harrisCornerThreshold,
const CameraDerivativeFunctor& cameraDerivativeFunctor,
HarrisCorners& corners,
Indices32& cornerPyramidLevels, std::vector<
FREAKDescriptorT<tSize>>& descriptors,
const bool removeInvalid =
false,
const Scalar border =
Scalar(20),
const bool determineExactHarrisCornerPositions =
false,
const bool yFrameIsUndistorted =
true,
Worker* worker =
nullptr);
430 template <
typename TImagePo
int>
459 template <
bool tEnableBorderChecks>
550template <
size_t tSize>
552 orientation_(orientation),
553 data_(std::move(data)),
556 ocean_assert(levels >= 1u && levels <= 3u);
560template <
size_t tSize>
567template <
size_t tSize>
573template <
size_t tSize>
579template <
size_t tSize>
582 ocean_assert(dataLevels_ <= 3u);
586template <
size_t tSize>
589 ocean_assert(isValid() && descriptor.
isValid());
591 unsigned int bestDistance = (
unsigned int)(-1);
593 for (
unsigned int nOuter = 0u; nOuter < dataLevels_; ++nOuter)
597 for (
unsigned int nInner = 0u; nInner < descriptor.
dataLevels_; ++nInner)
601 const unsigned int distance = Descriptor::calculateHammingDistance<tSize * 8u>(outerData.data(), innerData.data());
603 if (distance < bestDistance)
605 bestDistance = distance;
610 ocean_assert(bestDistance != (
unsigned int)(-1));
615template <
size_t tSize>
618 ocean_assert(isValid());
619 ocean_assert(!descriptors.empty());
621 unsigned int bestDistance = (
unsigned int)(-1);
625 ocean_assert(descriptor.isValid());
627 const unsigned int currentDistance = distance(descriptor);
629 if (currentDistance < bestDistance)
631 bestDistance = currentDistance;
638template <
size_t tSize>
641 return descriptorA.
distance(descriptorB);
644template <
size_t tSize>
647 return descriptor.
distance(descriptors);
650template <
size_t tSize>
653 ocean_assert(percent <= 100u);
655 constexpr size_t descriptorBits = tSize * 8;
657 return (
unsigned int)(descriptorBits * percent / 100u);
660template <
size_t tSize>
666template <
size_t tSize>
672template <
size_t tSize>
673template <
typename TImagePo
int>
676 ocean_assert(camera && camera->isValid());
677 ocean_assert(camera->width() == framePyramid.
finestWidth() && camera->height() == framePyramid.
finestHeight());
681 return computeDescriptors<TImagePoint>(framePyramid, points, pointsSize, pointsPyramidLevel, freakDescriptors, cameraDerivativeFunctor, worker);
684template <
size_t tSize>
685template <
typename TImagePo
int>
688 ocean_assert(framePyramid.
isValid());
689 ocean_assert(points !=
nullptr && pointsSize != 0u);
690 ocean_assert(pointsPyramidLevel < framePyramid.
layers());
691 ocean_assert(freakDescriptors !=
nullptr);
695 worker->
executeFunction(
Worker::Function::createStatic(&
FREAKDescriptorT<tSize>::computeDescriptorsSubset<TImagePoint>, &framePyramid, points, pointsSize, pointsPyramidLevel, freakDescriptors, &projectionDerivativeDataCallback, 0u, 0u), 0u, (
unsigned int)(pointsSize));
703template <
size_t tSize>
707 0.0f, -14.7216f, -14.7216f, 0.0f, 14.7216f, 14.7216f, -6.3745f, -12.749f, -6.3745f, 6.3745f,
708 12.749f, 6.3745f, 0.0f, -7.97392f, -7.97392f, 0.0f, 7.97392f, 7.97392f, -3.18725f, -6.3745f,
709 -3.18725f, 3.18725f, 6.3745f, 3.18725f, 0.0f, -3.67983f, -3.67983f, 0.0f, 3.67983f, 3.67983f,
710 -1.4163f, -2.8326f, -1.4163f, 1.4163f, 2.8326f, 1.4163f, 0.0f, -1.84049f, -1.84049f, 0.0f,
711 1.84049f, 1.84049f, 0.0f
715template <
size_t tSize>
719 16.9991f, 8.49895f, -8.49895f, -16.9991f, -8.49895f, 8.49895f, 11.0406f, 0.0f, -11.0406f, -11.0406f,
720 0.0f, 11.0406f, 9.2071f, 4.60355f, -4.60355f, -9.2071f, -4.60355f, 4.60355f, 5.52032f, 0.0f,
721 -5.52032f, -5.52032f, 0.0f, 5.52032f, 4.25005f, 2.12445f, -2.12445f, -4.25005f, -2.12445f, 2.12445f,
722 2.4536f, 0.0f, -2.4536f, -2.4536f, 0.0f, 2.4536f, 2.12445f, 1.0628f, -1.0628f, -2.12445f,
723 -1.0628f, 1.0628f, 0.0f
727template <
size_t tSize>
731 {37, 4}, {38, 4}, {12, 0}, {39,10}, {27, 7}, {37,29}, {20,16}, {33,16}, {14, 0}, {31, 3},
732 {17, 4}, {24,12}, {33,22}, {31, 7}, {35,30}, {25, 6}, {34,31}, {20,19}, {22,17}, {16, 6},
733 {23, 5}, {26,10}, {13, 5}, {31,17}, {17,10}, {31,28}, {22, 4}, {29,11}, {28, 2}, {29,19},
734 {30, 6}, {37,10}, {31, 2}, {41,13}, {14, 7}, {15, 3}, {33, 4}, {18,17}, {23,19}, {33,28},
735 {41,24}, {34,16}, { 7, 1}, {26, 5}, {36,13}, {42, 9}, {20,14}, {27,26}, {41, 6}, {40,19},
736 {26, 3}, {36,29}, {23,13}, {40, 7}, {18, 0}, {28,22}, {22, 9}, {26,16}, {21,16}, {39,20},
737 { 8, 3}, {14, 1}, {12,11}, {31,25}, {29, 4}, {15, 1}, {41,22}, {35, 1}, {26, 2}, {34,14},
738 {25, 1}, {34,17}, {34,29}, {16,14}, {19, 3}, {26,14}, {15, 5}, {25,17}, {25, 5}, {34,25},
739 { 6, 0}, {23,10}, {29,24}, {28,16}, {20, 3}, { 7, 4}, {25,11}, {36,24}, {27, 9}, {11,10},
740 {23, 7}, {32,19}, {32,16}, {37,18}, {25,24}, {19, 1}, {22,20}, {38,14}, {41,31}, {16,10},
741 {19, 6}, {16,11}, {31,20}, { 8, 0}, {14, 2}, {19, 0}, {37,13}, {34, 4}, {31,14}, { 6, 1},
742 {40, 1}, {24,18}, {41, 1}, {41, 7}, {36,23}, {40,20}, {40,27}, {13, 0}, {19,12}, {42,38},
743 {16, 7}, {34, 7}, { 9, 2}, {28, 4}, {11, 5}, {40,38}, {17, 2}, { 5, 0}, {19,14}, {12, 6},
744 {19,17}, {40,22}, {26, 7}, {19, 5}, {19,11}, {28,26}, {12, 1}, {34, 0}, { 5, 1}, {27,16},
745 {21,15}, {29,25}, {19, 8}, {32,26}, {37,17}, {11, 6}, {22, 6}, {39,27}, {41,37}, {21, 5},
746 {14,11}, {31,16}, {38,28}, {16, 0}, {29,10}, {31,26}, {10, 1}, {22,13}, {10, 3}, {17, 3},
747 {42,30}, { 8, 4}, {26, 6}, {22, 8}, {38,27}, {26,22}, {41,10}, {42,13}, {40,34}, {13, 7},
748 {30,11}, {38,22}, {33,27}, {19,15}, {29, 7}, {31,10}, {26,15}, {13,12}, {29, 2}, { 5, 3},
749 {15, 7}, {28,10}, {29,17}, {40,10}, {21, 1}, {15,10}, {37,11}, {40,13}, {26, 1}, {39,21},
750 {34,21}, {40,31}, {19, 7}, {16, 5}, {40,39}, {37, 7}, {30,23}, {10, 9}, {36,30}, {38, 0},
751 {18, 6}, {40,32}, {38,10}, {22, 3}, {26,19}, {18,13}, {39,22}, {35,17}, {31,19}, {18,11},
752 {28,19}, {28, 0}, {37,31}, {30, 7}, {27,20}, {34,10}, {38, 3}, {37,23}, {18, 7}, {38,20},
753 {25,19}, {20, 7}, {22,18}, { 7, 3}, {15, 2}, {23,12}, {26,13}, {38, 7}, {11, 1}, {20, 8},
754 {33,21}, {37,36}, {17,16}, {36,35}, {41, 2}, {37,35}, {37, 2}, {15,14}, {10, 7}, {41,29},
755 { 7, 6}, {32,22}, {34,26}, {33, 2}, {38,26}, {31, 0}, {11, 3}, {24,23}, {13,11}, {41,19},
756 {41,25}, {30,13}, {27,10}, {39,38}, {21, 3}, {31, 4}, {27,14}, {37,24}, {20, 2}, {25,23},
757 {29, 1}, {39,28}, {17, 0}, { 7, 0}, { 9, 5}, {22, 2}, {33,32}, {27,21}, {30,25}, {41,23},
758 {41,30}, {15, 9}, {22,10}, {31,22}, {29, 5}, {34,20}, {24,13}, {31,11}, {36,25}, {21,19},
759 {19,13}, {30,29}, {33, 5}, { 6, 4}, { 5, 2}, { 8, 2}, {10, 2}, {25,13}, {37,19}, {28,14},
760 {15, 4}, {10, 8}, {12, 5}, {14,13}, {24, 1}, {31,12}, {14,10}, {32,27}, {19,18}, {32, 4},
761 {22, 1}, {39,26}, {17,14}, { 2, 1}, { 1, 0}, {35,23}, {34, 2}, {33,19}, {13, 3}, {39,16},
762 {25, 2}, {41, 4}, {28, 7}, {31,21}, {26, 4}, {39,19}, {24,17}, {28,20}, {21, 8}, {25, 7},
763 {34,15}, {41,36}, {16, 3}, {21,20}, {31,15}, {26,20}, {14, 5}, {38,16}, {40, 2}, {18,10},
764 {27, 8}, {29,13}, {41,18}, {18,12}, {40,26}, {36, 0}, {21,14}, {22, 0}, {27, 2}, {11, 0},
765 {21,10}, {20,10}, {23, 6}, {13, 4}, {28,21}, {22,16}, {25,22}, {35,24}, { 4, 0}, {31, 1},
766 {32,21}, {21, 4}, {37, 6}, {15, 8}, { 8, 7}, {29,22}, {28,15}, {25,18}, {41,35}, {39,14},
767 {34,12}, {23,17}, {25,10}, {39, 9}, {34,13}, {22,14}, { 7, 2}, {20, 9}, {28,11}, {10, 4},
768 {40, 0}, {35,13}, {38,32}, {13, 2}, {39, 1}, { 2, 0}, {38,19}, {41,11}, {32,28}, {39,33},
769 {30,17}, {16, 2}, {17, 6}, {13,10}, { 4, 1}, {10, 0}, {22,19}, { 4, 3}, {12, 7}, {26,21},
770 { 9, 0}, {19,16}, {34,28}, {16, 9}, { 9, 8}, {23, 0}, { 7, 5}, {10, 5}, {34,18}, {14, 6},
771 {30, 5}, {31,18}, {20,15}, {34,22}, {35,12}, {23, 1}, {35,10}, { 9, 3}, {27,15}, {17,13},
772 {37,30}, {26, 0}, {28,17}, {38,33}, {38, 5}, {16, 4}, {13, 1}, {28, 3}, { 5, 4}, {12, 2},
773 {17, 9}, {31,29}, {22,11}, {40,17}, {25, 4}, {28,27}, {29, 6}, {34, 1}, {14, 8}, {32,15},
774 {39,32}, { 6, 5}, {19, 4}, {18, 5}, {32,20}, {38,13}, {12,10}, {24, 0}, {22,15}, {36,18},
775 { 6, 3}, {34,23}, {33,15}, {22, 7}, {22,12}, {40,28}, {35,18}, {22, 5}, {29,23}, {37,34},
776 {16,13}, {23,18}, {37,22}, {29,12}, {19, 2}, {14, 9}, {34,19}, {19,10}, {25,12}, {38,21},
777 {28, 1}, {33,20}, {27, 4}, {11, 7}, {31,23}, {17, 7}, {17, 8}, {39, 8}, {40,21}, {16,15},
778 {17, 5}, {30,18}, {39, 7}, {37,25}, {41,34}, {30,24}, {18, 1}, { 3, 1}, { 9, 4}, {22,21},
779 {31, 5}, {40, 3}, {35,25}, {32, 2}, { 4, 2}, {38,31}, {14, 3}, {21, 9}, {17,12}, {16, 1},
780 {35,29}, {23,22}, {20, 1}, {34, 3}, {17, 1}, {13, 6}, {40,14}, {17,11}, {38,17}, {40,16},
781 {20, 4}, {23,11}, {12, 4}, { 3, 2}, {40,33}, {14, 4}, {21, 2}, {33,26}, {38,34}, {29,18},
786template <
size_t tSize>
789template <
size_t tSize>
792template <
size_t tSize>
793const int FREAKDescriptorT<tSize>::kernelRadius2X[kernelRadius2Elements] = { 0, -1, 0, 1, -2, -1, 0, 1, 2, -1, 0, 1, 0 };
795template <
size_t tSize>
796const int FREAKDescriptorT<tSize>::kernelRadius2Y[kernelRadius2Elements] = { -2, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 2 };
798template <
size_t tSize>
802 0, -2, -1, 0, 1, 2, -2, -1, 0, 1,
803 2, -3, -2, -1, 0, 1, 2, 3, -2, -1,
804 0, 1, 2, -2, -1, 0, 1, 2, 0
808template <
size_t tSize>
812 -3, -2, -2, -2, -2, -2, -1, -1, -1, -1,
813 -1, 0, 0, 0, 0, 0, 0, 0, 1, 1,
814 1, 1, 1, 2, 2, 2, 2, 2, 3
818template <
size_t tSize>
822 0, -3, -2, -1, 0, 1, 2, 3, -4, -3,
823 -2, -1, 0, 1, 2, 3, 4, -5, -4, -3,
824 -2, -1, 0, 1, 2, 3, 4, 5, -6, -5,
825 -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
826 6, -6, -5, -4, -3, -2, -1, 0, 1, 2,
827 3, 4, 5, 6, -6, -5, -4, -3, -2, -1,
828 0, 1, 2, 3, 4, 5, 6, -7, -6, -5,
829 -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
830 6, 7, -6, -5, -4, -3, -2, -1, 0, 1,
831 2, 3, 4, 5, 6, -6, -5, -4, -3, -2,
832 -1, 0, 1, 2, 3, 4, 5, 6, -6, -5,
833 -4, -3, -2, -1, 0, 1, 2, 3, 4, 5,
834 6, -5, -4, -3, -2, -1, 0, 1, 2, 3,
835 4, 5, -4, -3, -2, -1, 0, 1, 2, 3,
836 4, -3, -2, -1, 0, 1, 2, 3, 0
840template <
size_t tSize>
844 -7, -6, -6, -6, -6, -6, -6, -6, -5, -5,
845 -5, -5, -5, -5, -5, -5, -5, -4, -4, -4,
846 -4, -4, -4, -4, -4, -4, -4, -4, -3, -3,
847 -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
848 -3, -2, -2, -2, -2, -2, -2, -2, -2, -2,
849 -2, -2, -2, -2, -1, -1, -1, -1, -1, -1,
850 -1, -1, -1, -1, -1, -1, -1, 0, 0, 0,
851 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
852 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
853 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
854 2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
855 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
856 3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
857 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
858 5, 6, 6, 6, 6, 6, 6, 6, 7
862template <
size_t tSize>
865 ocean_assert(pointPyramidLevel < pyramid.
layers());
866 ocean_assert(inverseFocalLength > 0.0f);
870 if (pointPyramidLevel + 1u >= pyramid.
layers())
878 ocean_assert(freakDescriptor.
isValid() ==
false);
882 Eigen::Matrix<float, 2, 2> cellDeformationMatrix;
883 if (computeLocalDeformationMatrixAndOrientation(pyramid, point, pointPyramidLevel, unprojectRayIF, inverseFocalLength, pointJacobianMatrixIF, cellDeformationMatrix, freakDescriptor.
orientation_) ==
false)
893 for (
size_t i = 0; i < FREAKDescriptorT<tSize>::numberOfCells; ++i)
896 warpedCellX[i] = warpedCell[0];
897 warpedCellY[i] = warpedCell[1];
906 const float scaleFactors[3] = { 1.0f, 1.2599f, 1.5874f };
907 for (
size_t scaleLevel = 0; scaleLevel < 3; ++scaleLevel)
910 bool computationFailed =
false;
922 unsigned int cellId = 0u;
925 for (; cellId < 12u; ++cellId)
927 ocean_assert(pointPyramidLevel + 1u < pyramid.
layers());
928 const Frame& nextFramePyramidLayer = pyramid.
layer(pointPyramidLevel + 1u);
930 const float cellX = point[0] + scaleFactors[scaleLevel] * warpedCellX[cellId];
931 const float cellY = point[1] + scaleFactors[scaleLevel] * warpedCellY[cellId];
937 if (cellXi - 1 < 0 || cellXi + 1 >=
int(nextFramePyramidLayer.
width()) || cellYi - 1 < 0 || cellYi + 1 >=
int(nextFramePyramidLayer.
height()))
939 computationFailed =
true;
943 ocean_assert(cellXi >= 0 && cellXi <
int(nextFramePyramidLayer.
width()) && cellYi >= 0 && cellYi <
int(nextFramePyramidLayer.
height()));
945 if (computeAverageCellIntensity<true>(nextFramePyramidLayer, cellXi, cellYi, kernelRadius3X, kernelRadius3Y, kernelRadius3Elements, cellIntensities[cellId]) ==
false)
947 computationFailed =
true;
953 const Frame& currentFramePyramidLayer = pyramid.
layer(pointPyramidLevel);
955 ocean_assert(cellId == 12u || computationFailed ==
true);
956 for (; computationFailed ==
false && cellId < 24u; ++cellId)
958 const float cellX = point[0] + scaleFactors[scaleLevel] * warpedCellX[cellId];
959 const float cellY = point[1] + scaleFactors[scaleLevel] * warpedCellY[cellId];
964 ocean_assert(cellXi >= 0 && cellXi <
int(currentFramePyramidLayer.
width()) && cellYi >= 0 && cellYi <
int(currentFramePyramidLayer.
height()));
966 if (computeAverageCellIntensity<false>(currentFramePyramidLayer, cellXi, cellYi, kernelRadius3X, kernelRadius3Y, kernelRadius3Elements, cellIntensities[cellId]) ==
false)
968 computationFailed =
true;
974 ocean_assert(cellId == 24u || computationFailed ==
true);
975 for (; computationFailed ==
false && cellId < 30u; ++cellId)
977 const float cellX = point[0] + scaleFactors[scaleLevel] * warpedCellX[cellId];
978 const float cellY = point[1] + scaleFactors[scaleLevel] * warpedCellY[cellId];
983 ocean_assert(cellXi >= 0 && cellXi <
int(currentFramePyramidLayer.
width()) && cellYi >= 0 && cellYi <
int(currentFramePyramidLayer.
height()));
984 if (computeAverageCellIntensity<false>(currentFramePyramidLayer, cellXi, cellYi, kernelRadius2X, kernelRadius2Y, kernelRadius2Elements, cellIntensities[cellId]) ==
false)
986 computationFailed =
true;
992 ocean_assert(cellId == 30u || computationFailed ==
true);
993 for (; computationFailed ==
false && cellId < FREAKDescriptorT<tSize>::numberOfCells; ++cellId)
995 const float cellX = point[0] + scaleFactors[scaleLevel] * warpedCellX[cellId];
996 const float cellY = point[1] + scaleFactors[scaleLevel] * warpedCellY[cellId];
1001 ocean_assert(cellXi >= 0 && cellXi <
int(currentFramePyramidLayer.
width()) && cellYi >= 0 && cellYi <
int(currentFramePyramidLayer.
height()));
1003 if (computeAverageCellIntensity<false>(currentFramePyramidLayer, cellXi, cellYi, kernelRadius1X, kernelRadius1Y, kernelRadius1Elements, cellIntensities[cellId]) ==
false)
1005 computationFailed =
true;
1010 if (computationFailed)
1017 for (
size_t i = 0; i < tSize; ++i)
1019 uint8_t partialDescriptor = 0u;
1021 for (
size_t j = 0; j < 8; ++j)
1023 partialDescriptor = uint8_t(partialDescriptor << 1u);
1025 const size_t pair = i * 8 + j;
1032 partialDescriptor = partialDescriptor | 1u;
1035 freakDescriptor.
data_[scaleLevel][i] = partialDescriptor;
1038 freakDescriptor.
dataLevels_ = (
unsigned int)(scaleLevel + 1);
1043 return freakDescriptor.
isValid();
1046template <
size_t tSize>
1047template <
bool tEnableBorderChecks>
1050 ocean_assert(framePyramidLayer.
isValid());
1051 ocean_assert(kernelX !=
nullptr && kernelY !=
nullptr && kernelElements != 0u);
1053 const unsigned int width = framePyramidLayer.
width();
1054 const unsigned int height = framePyramidLayer.
height();
1055 const unsigned int frameStrideElements = framePyramidLayer.
strideElements();
1058 if constexpr (tEnableBorderChecks)
1060 unsigned int sum = 0u;
1061 unsigned int sumElements = 0u;
1063 for (
size_t i = 0; i < kernelElements; ++i)
1065 const int x = cellX + kernelX[i];
1066 const int y = cellY + kernelY[i];
1068 if (x >= 0 && x <
int(width) && y >= 0 && y < int(height))
1070 sum += frame[(
unsigned int)y * frameStrideElements + (
unsigned int)x];
1075 ocean_assert(sumElements != 0u);
1076 ocean_assert(
float(sum) /
float(sumElements) <= 255.0f);
1078 averageIntensity =
PixelType(
float(sum) /
float(sumElements));
1082 unsigned int sum = 0u;
1084 for (
size_t i = 0; i < kernelElements; ++i)
1086 const int x = cellX + kernelX[i];
1087 const int y = cellY + kernelY[i];
1088 ocean_assert_and_suppress_unused(x >= 0 && x <
int(width) && y >= 0 && y <
int(height), height);
1090 sum += frame[(
unsigned int)y * frameStrideElements + (
unsigned int)x];
1093 ocean_assert(
float(sum) /
float(kernelElements) <= 255.0f);
1095 averageIntensity =
PixelType(
float(sum) /
float(kernelElements));
1101template <
size_t tSize>
1102template <
typename TImagePo
int>
1105 ocean_assert(framePyramid !=
nullptr && framePyramid->
isValid());
1106 ocean_assert(points !=
nullptr && pointsSize != 0u);
1107 ocean_assert(pointsPyramidLevel < framePyramid->layers());
1108 ocean_assert(freakDescriptor !=
nullptr);
1109 ocean_assert(cameraDerivativeFunctor !=
nullptr);
1110 ocean_assert_and_suppress_unused(firstPoint + numberOfPoints <= pointsSize && numberOfPoints != 0u, pointsSize);
1112 for (
unsigned int i = firstPoint; i < firstPoint + numberOfPoints; ++i)
1114 ocean_assert(i < pointsSize);
1116 const TImagePoint& point = points[i];
1118 const Eigen::Vector2f eigenPoint(
float(point.x()),
float(point.y()));
1120 float inverseFocalLength;
1127template <
size_t tSize>
1130 ocean_assert(pyramid.
isValid());
1131 ocean_assert(pointPyramidLevel < pyramid.
layers());
1134 ocean_assert(inverseFocalLength > 0.0f);
1135 ocean_assert(projectionJacobianMatrix.IsRowMajor ==
false);
1139 const Eigen::Vector3f directionY(0, 1, 0);
1140 const Eigen::Vector3f nx = directionY.cross(unprojectRayIF).normalized() * inverseFocalLength;
1141 const Eigen::Vector3f ny = unprojectRayIF.cross(nx);
1145 Eigen::Matrix<float, 3, 2> N;
1148 const Eigen::Matrix<float, 2, 2> initialDeformationMatrix = projectionJacobianMatrix * N;
1152 constexpr float cornerX[4] = {-7.0f, -7.0f, 7.0f, 7.0f};
1153 constexpr float cornerY[4] = {-7.0f, 7.0f, -7.0f, 7.0f};
1154 const Frame& framePyramidLevel = pyramid.
layer(pointPyramidLevel);
1156 for (
size_t i = 0; i < 4; ++i)
1158 const Eigen::Vector2f warpedCorner = point + initialDeformationMatrix * Eigen::Vector2f(cornerX[i], cornerY[i]);
1163 if (x >= framePyramidLevel.
width() || y >= framePyramidLevel.
height())
1173 const unsigned int strideElements = framePyramidLevel.
strideElements();
1176 for (
size_t i = 0; i < FREAKDescriptorT<tSize>::kernelRadius7Elements; ++i)
1183 ocean_assert(((
unsigned int)(v) * strideElements + (
unsigned int)(u)) < framePyramidLevel.
size());
1184 const int intensity = int(data[(
unsigned int)(v) * strideElements + (
unsigned int)(u)]);
1191 if (magnitudeX == 0 && magnitudeY == 0)
1198 const Eigen::Vector3f gy = (nx * float(magnitudeX) + ny * float(magnitudeY)).normalized() * inverseFocalLength;
1199 const Eigen::Vector3f gx = gy.cross(unprojectRayIF);
1201 Eigen::Matrix<float, 3, 2> G;
1205 deformationMatrix = projectionJacobianMatrix * G;
1209 const Eigen::Vector2f patchY = projectionJacobianMatrix * gy;
1216template <
size_t tSize>
1220 ocean_assert(kernelWidth != 0u && kernelWidth % 2u == 1u);
1221 ocean_assert(kernelHeight != 0u && kernelHeight % 2u == 1u);
1222 ocean_assert(layers >= 1u);
1224 Frame reusableFrame;
1228 FramePyramid framePyramid(frame, downsamplingFunction, layers,
true , worker);
1230 if (framePyramid.
layers() != layers)
1235 return framePyramid;
1238template <
size_t tSize>
1241 ocean_assert(finerLayer.
isValid());
1242 ocean_assert(coarserLayer.
isValid());
1244 ocean_assert(kernelWidth >= 1u && kernelWidth % 2u == 1u);
1245 ocean_assert(kernelHeight >= 1u && kernelHeight % 2u == 1u);
1250 if (!reusableFrame.
set(finerLayer.
frameType(),
false ,
true ))
1252 ocean_assert(
false &&
"This should never happen!");
1256 ocean_assert(reusableFrame.
isValid());
1258 const Frame* sourceLayer = &finerLayer;
1260 if (kernelWidth <= finerLayer.
width() && kernelHeight <= finerLayer.
height())
1262 if (!CV::FrameFilterGaussian::filter<uint8_t, uint32_t>(finerLayer.
constdata<uint8_t>(), reusableFrame.
data<uint8_t>(), finerLayer.
width(), finerLayer.
height(), finerLayer.
channels(), finerLayer.
paddingElements(), reusableFrame.
paddingElements(), kernelWidth, kernelHeight, -1.0f, worker))
1267 sourceLayer = &reusableFrame;
1275template <
size_t tSize>
1276bool FREAKDescriptorT<tSize>::extractHarrisCornersAndComputeDescriptors(
const Frame& yFrame,
const unsigned int maxFrameArea,
const unsigned int minFrameArea,
const unsigned int expectedHarrisCorners640x480,
const Scalar harrisCornersReductionScale,
const unsigned int harrisCornerThreshold,
const CameraDerivativeFunctor& cameraDerivativeFunctor,
HarrisCorners& corners,
Indices32& cornerPyramidLevels, std::vector<
FREAKDescriptorT<tSize>>& descriptors,
const bool removeInvalid,
const Scalar border,
const bool determineExactHarrisCornerPositions,
const bool yFrameIsUndistorted,
Worker* worker)
1279 ocean_assert(minFrameArea != 0u && minFrameArea <= maxFrameArea);
1280 ocean_assert(expectedHarrisCorners640x480 != 0u);
1281 ocean_assert(harrisCornersReductionScale >
Scalar(0) && harrisCornersReductionScale <
Scalar(1));
1282 ocean_assert(harrisCornerThreshold <= 512u);
1286 cornerPyramidLevels.clear();
1287 descriptors.clear();
1291 const unsigned int frameArea = yFrame.
width() * yFrame.
height();
1294 ocean_assert(startLayerIndex <= lastLayerIndex);
1309 const unsigned int startLayerArea = pyramid[startLayerIndex].
width() * pyramid[startLayerIndex].
height();
1314 expectedHarrisCornersOnLevel = (
unsigned int)(
Scalar(expectedHarrisCornersOnLevel) * (
Scalar(1) - harrisCornersReductionScale) / (
Scalar(1) - std::pow(harrisCornersReductionScale,
Scalar(lastLayerIndex - startLayerIndex))));
1316 const Scalar expectedHarrisCornersOnStartLayerF =
Scalar(expectedHarrisCorners640x480) *
Scalar(startLayerArea) /
Scalar(640u * 480u);
1317 unsigned int expectedHarrisCornersOnLevel = (
unsigned int)
Numeric::round32(expectedHarrisCornersOnStartLayerF * (
Scalar(1) - harrisCornersReductionScale) / (
Scalar(1) - std::pow(harrisCornersReductionScale,
Scalar(lastLayerIndex - startLayerIndex))));
1322 for (
unsigned int layer = startLayerIndex; layer <= lastLayerIndex; ++layer)
1324 ocean_assert(layer + 1u < pyramid.
layers());
1325 ocean_assert(corners.size() == descriptors.size());
1326 ocean_assert(corners.size() == cornerPyramidLevels.size());
1328 if (expectedHarrisCornersOnLevel == 0u)
1333 const Frame& pyramidLayer = pyramid[layer];
1346 if (harrisCornersOnLevel.empty())
1353 ocean_assert(corners.size() == descriptors.size());
1354 ocean_assert(corners.size() == cornerPyramidLevels.size());
1355 const size_t firstNewCornerIndex = corners.size();
1357 if (harrisCornersOnLevel.size() > expectedHarrisCornersOnLevel)
1361 std::sort(harrisCornersOnLevel.begin(), harrisCornersOnLevel.end());
1363 unsigned int horizontalBins = 0u;
1364 unsigned int verticalBins = 0u;
1366 ocean_assert(horizontalBins != 0u && verticalBins != 0u);
1368 const HarrisCorners newCorners = Geometry::SpatialDistribution::distributeAndFilter<HarrisCorner, HarrisCorner::corner2imagePoint>(harrisCornersOnLevel.data(), harrisCornersOnLevel.size(), border, border,
Scalar(pyramidLayer.
width()) -
Scalar(2) * border,
Scalar(pyramidLayer.
height()) -
Scalar(2) * border, horizontalBins, verticalBins,
size_t(expectedHarrisCornersOnLevel));
1370 corners.insert(corners.end(), newCorners.begin(), newCorners.end());
1374 for (
const HarrisCorner& corner : harrisCornersOnLevel)
1376 if (corner.observation().x() >= border && corner.observation().x() <
Scalar(pyramidLayer.
width()) - border &&
1377 corner.observation().y() >= border && corner.observation().y() <
Scalar(pyramidLayer.
height()) - border)
1379 corners.emplace_back(corner);
1384 ocean_assert(firstNewCornerIndex <= corners.size());
1385 const size_t newCornersAdded = corners.size() - firstNewCornerIndex;
1387 if (newCornersAdded == 0)
1392 ocean_assert(firstNewCornerIndex + newCornersAdded == corners.size());
1394#if defined(OCEAN_DEBUG)
1395 for (
size_t i = firstNewCornerIndex; i < corners.size(); ++i)
1397 ocean_assert(corners[i].observation().x() >= border && corners[i].observation().x() <=
Scalar(pyramidLayer.
width()) - border);
1398 ocean_assert(corners[i].observation().y() >= border && corners[i].observation().y() <=
Scalar(pyramidLayer.
height()) - border);
1404 cornerPyramidLevels.insert(cornerPyramidLevels.end(), newCornersAdded, layer);
1408 std::vector<Eigen::Vector2f> observations;
1409 observations.reserve(newCornersAdded);
1411 for (
size_t i = firstNewCornerIndex; i < corners.size(); ++i)
1413 observations.emplace_back(
float(corners[i].observation().x()),
float(corners[i].observation().y()));
1418 ocean_assert(corners.size() > descriptors.size());
1419 descriptors.resize(corners.size());
1421 ocean_assert(descriptors.begin() +
size_t(firstNewCornerIndex) + observations.size() == descriptors.end());
1424 expectedHarrisCornersOnLevel = (
unsigned int)
Numeric::round32(
Scalar(expectedHarrisCornersOnLevel) * harrisCornersReductionScale);
1426 ocean_assert(corners.size() == descriptors.size());
1427 ocean_assert(corners.size() == cornerPyramidLevels.size());
1430 ocean_assert(corners.size() == descriptors.size());
1431 ocean_assert(corners.size() == cornerPyramidLevels.size());
1433 if (removeInvalid && corners.empty() ==
false)
1436 while (i < corners.size())
1438 if (descriptors[i].isValid())
1444 ocean_assert(corners.empty() ==
false);
1445 corners[i] = corners.back();
1448 cornerPyramidLevels[i] = cornerPyramidLevels.back();
1449 cornerPyramidLevels.pop_back();
1451 descriptors[i] = descriptors.back();
1452 descriptors.pop_back();
1457 ocean_assert(corners.size() == descriptors.size());
1458 ocean_assert(corners.size() == cornerPyramidLevels.size());
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:131
Functor that can be used to obtain the 2x3 Jacobian of the camera projection matrix wrt.
Definition FREAKDescriptor.h:175
AnyCameraDerivativeFunctor(const SharedAnyCamera &camera, const unsigned int pyramidLevels=1u)
Constructs a valid functor to compute pinhole camera derivative data.
unsigned int supportedPyramidLevels() const override
Returns the maximum number of pyramid levels for which camera derivative data can be computed.
CameraDerivativeData computeCameraDerivativeData(const Eigen::Vector2f &point, const unsigned int pointPyramidLevel, float &inverseFocalLength) const override
Computes the point Jacobian of the projection matrix and unprojection ray for a specified point.
static CameraDerivativeData computeCameraDerivativeData(const AnyCamera &camera, const Eigen::Vector2f &point)
Computes the point Jacobian of the projection matrix and unprojection ray for a specified point.
SharedAnyCameras cameras_
The camera instance used to compute the Jacobian matrix and unprojection ray at the finest layer of a...
Definition FREAKDescriptor.h:206
std::vector< float > inverseFocalLengths_
The inverse focal length of the cameras, one for each pyramid level.
Definition FREAKDescriptor.h:209
Base class to compute the Jacobian of the camera projection matrix wrt.
Definition FREAKDescriptor.h:107
virtual unsigned int supportedPyramidLevels() const =0
Returns the maximum number of pyramid levels for which camera derivative data can be computed.
virtual ~CameraDerivativeFunctor()=default
Default destructor.
virtual CameraDerivativeData computeCameraDerivativeData(const Eigen::Vector2f &point, const unsigned int pointPyramidLevel, float &inverseFocalLength) const =0
Purely virtual function to compute the camera derivative data; has to be implemented in any derived c...
Deprecated.
Definition FREAKDescriptor.h:137
unsigned int supportedPyramidLevels() const override
Returns the maximum number of pyramid levels for which camera derivative data can be computed.
PinholeCameraDerivativeFunctor(const PinholeCamera &pinholeCamera, const unsigned int pyramidLevels=1u)
Constructs a valid functor to compute pinhole camera derivative data.
CameraDerivativeData computeCameraDerivativeData(const Eigen::Vector2f &point, const unsigned int pointPyramidLevel, float &inverseFocalLength) const override
Computes the point Jacobian of the projection matrix and unprojection ray for a specified point.
PinholeCameras cameras_
The camera instance used to compute the Jacobian matrix and unprojection ray at the finest layer of a...
Definition FREAKDescriptor.h:168
static CameraDerivativeData computeCameraDerivativeData(const PinholeCamera &pinholeCamera, const Eigen::Vector2f &point)
Computes the point Jacobian of the projection matrix and unprojection ray for a specified point.
Implementation the template-free base class for the FREAK descriptors.
Definition FREAKDescriptor.h:82
std::uint8_t PixelType
Typedef for the selected pixel type. This might be turned into a template parameter at some point.
Definition FREAKDescriptor.h:86
Eigen::Matrix< float, 2, 3 > PointJacobianMatrix2x3
The Jacobian of the projection matrix at a specific 3D location (ray from projection center to pixel ...
Definition FREAKDescriptor.h:89
Forward-declaration of the descriptor class.
Definition FREAKDescriptor.h:220
MultilevelDescriptorData data_
The actual FREAK descriptor data.
Definition FREAKDescriptor.h:544
static const float cellsY[numberOfCells]
The pre-defined vertical coordinates of the cells.
Definition FREAKDescriptor.h:494
static const std::uint8_t cellPairs[numberOfCellPairs][2]
The pre-defined pairs of cell indices that uare used to compute the actual binary descriptor (pairs h...
Definition FREAKDescriptor.h:500
static constexpr size_t kernelRadius3Elements
Number of elements in the circular kernel with radius 3.
Definition FREAKDescriptor.h:521
static const float cellsX[numberOfCells]
The pre-defined horizontal coordinates of the cells.
Definition FREAKDescriptor.h:491
static bool computeLocalDeformationMatrixAndOrientation(const FramePyramid &framePyramid, const Eigen::Vector2f &point, const unsigned int pointPyramidLevel, const Eigen::Vector3f &unprojectRayIF, const float inverseFocalLength, const PointJacobianMatrix2x3 &pointJacobianMatrix2x3, Eigen::Matrix< float, 2, 2 > &deformationMatrix, float &orientation)
Computes the transformation to deform receptive fields and the orientation of the descriptor.
Definition FREAKDescriptor.h:1128
static constexpr unsigned int descriptorMatchingThreshold(const unsigned int percent)
Returns the descriptor matching threshold based on a percentage of the descriptor size.
Definition FREAKDescriptor.h:651
static constexpr size_t numberOfCellPairs
The number of pre-defined pairs of cell indices that are used to compute the actual binary descriptor...
Definition FREAKDescriptor.h:497
FREAKDescriptorT(const FREAKDescriptorT< tSize > &)=default
Creates a new FREAK descriptor object by copying from an existing one.
FREAKDescriptorT()=default
Creates a new and invalid FREAK descriptor object.
static const int kernelRadius1Y[kernelRadius1Elements]
The pre-defined vertical coordinates of the circular kernel with radius 1.
Definition FREAKDescriptor.h:509
OCEAN_FORCE_INLINE unsigned int distance(const FREAKDescriptorT< tSize > &descriptor) const
Returns the distance between this descriptor and a second descriptor.
Definition FREAKDescriptor.h:587
float orientation() const
Returns the orientation of the descriptor in Radian.
Definition FREAKDescriptor.h:561
FREAKDescriptorT & operator=(const FREAKDescriptorT< tSize > &) noexcept=default
Copy assignment operator, needs to be defined since there is a custom copy constructor.
float orientation_
The orientation of this descriptor in radian, range: [-pi, pi].
Definition FREAKDescriptor.h:541
unsigned int descriptorLevels() const
Returns the number of levels stored in the multi-level descriptor.
Definition FREAKDescriptor.h:580
static void computeDescriptorsSubset(const FramePyramid *framePyramid, const TImagePoint *points, const size_t pointsSize, const unsigned int pointPyramidLevel, FREAKDescriptorT< tSize > *freakDescriptors, const CameraDerivativeFunctor *cameraDerivativeFunctor, const unsigned int firstPoint, const unsigned int numberOfPoints)
Compute FREAK descriptors for a subset of points.
Definition FREAKDescriptor.h:1103
std::array< SinglelevelDescriptorData, 3 > MultilevelDescriptorData
Multi-level FREAK descriptor data; if possible, this implementation computes the descriptor at three ...
Definition FREAKDescriptor.h:229
static unsigned int calculateDistance(const FREAKDescriptorT< tSize > &descriptorA, const FREAKDescriptorT< tSize > &descriptorB)
Returns the distance between two descriptors.
Definition FREAKDescriptor.h:639
static const int kernelRadius7X[kernelRadius7Elements]
The pre-defined horizontal coordinates of the circular kernel with radius 7.
Definition FREAKDescriptor.h:533
static bool blurAndDownsampleByTwo11(const Frame &finerLayer, Frame &coarserLayer, Worker *worker, const unsigned int kernelWidth, const unsigned int kernelHeight, Frame &reusableFrame)
Downsamples a frame by two applying a 1-1 filter after applying a Gaussian blur to the source layer.
Definition FREAKDescriptor.h:1239
std::array< PixelType, tSize > SinglelevelDescriptorData
Single-level FREAK descriptor.
Definition FREAKDescriptor.h:226
static bool extractHarrisCornersAndComputeDescriptors(const Frame &yFrame, const unsigned int maxFrameArea, const unsigned int minFrameArea, const unsigned int expectedHarrisCorners640x480, const Scalar harrisCornersReductionScale, const unsigned int harrisCornerThreshold, const CameraDerivativeFunctor &cameraDerivativeFunctor, HarrisCorners &corners, Indices32 &cornerPyramidLevels, std::vector< FREAKDescriptorT< tSize > > &descriptors, const bool removeInvalid=false, const Scalar border=Scalar(20), const bool determineExactHarrisCornerPositions=false, const bool yFrameIsUndistorted=true, Worker *worker=nullptr)
Extract Harris corners from an image pyramid and compute FREAK descriptors.
Definition FREAKDescriptor.h:1276
static const int kernelRadius7Y[kernelRadius7Elements]
The pre-defined vertical coordinates of the circular kernel with radius 7.
Definition FREAKDescriptor.h:536
static constexpr size_t numberOfCells
The number of cells per keypoint that this implementation is using.
Definition FREAKDescriptor.h:488
static FramePyramid createFramePyramidWithBlur8BitsPerChannel(const Frame &frame, const unsigned int kernelWidth, const unsigned int kernelHeight, const unsigned int layers, Worker *worker=nullptr)
Creates a new pyramid frame for a specific pixel format (a specific number of channels) and applies a...
Definition FREAKDescriptor.h:1217
unsigned int dataLevels_
Number of valid levels in the multi-level descriptor data above, range: [0, 3].
Definition FREAKDescriptor.h:547
MultilevelDescriptorData & data()
Returns the descriptor data (writable)
Definition FREAKDescriptor.h:568
static void computeDescriptors(const SharedAnyCamera &camera, const FramePyramid &framePyramid, const TImagePoint *points, const size_t pointsSize, const unsigned int pointsPyramidLevel, FREAKDescriptorT< tSize > *freakDescriptors, Worker *worker=nullptr)
Compute FREAK descriptors for multiple image points.
Definition FREAKDescriptor.h:674
static const int kernelRadius3X[kernelRadius3Elements]
The pre-defined horizontal coordinates of the circular kernel with radius 3.
Definition FREAKDescriptor.h:524
static const int kernelRadius3Y[kernelRadius3Elements]
The pre-defined vertical coordinates of the circular kernel with radius 3.
Definition FREAKDescriptor.h:527
static const int kernelRadius2Y[kernelRadius2Elements]
The pre-defined vertical coordinates of the circular kernel with radius 2.
Definition FREAKDescriptor.h:518
static const int kernelRadius2X[kernelRadius2Elements]
The pre-defined horizontal coordinates of the circular kernel with radius 2.
Definition FREAKDescriptor.h:515
static constexpr size_t kernelRadius2Elements
Number of elements in the circular kernel with radius 2.
Definition FREAKDescriptor.h:512
static bool computeAverageCellIntensity(const Frame &framePyramidLayer, int x, int y, const int *kernelX, const int *kernelY, const size_t kernelElements, PixelType &averageIntensity)
Computes the average intensity of a cell.
Definition FREAKDescriptor.h:1048
static constexpr size_t size()
Returns the length of this descriptor in bytes.
Definition FREAKDescriptor.h:667
static bool computeDescriptor(const FramePyramid &framePyramid, const Eigen::Vector2f &point, const unsigned int pointPyramidLevel, FREAKDescriptorT< tSize > &freakDescriptor, const Eigen::Vector3f &unprojectRayIF, const float inverseFocalLength, const PointJacobianMatrix2x3 &pointJacobianMatrix2x3)
Compute a FREAK descriptor for a single image point.
Definition FREAKDescriptor.h:863
static const int kernelRadius1X[kernelRadius1Elements]
The pre-defined horizontal coordinates of the circular kernel with radius 1.
Definition FREAKDescriptor.h:506
static constexpr size_t kernelRadius1Elements
Number of elements in the circular kernel with radius 1.
Definition FREAKDescriptor.h:503
bool isValid() const
Returns true if this is a valid descriptor.
Definition FREAKDescriptor.h:661
static constexpr size_t kernelRadius7Elements
Number of elements in the circular kernel with radius 7.
Definition FREAKDescriptor.h:530
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
This class implements a Harris corner.
Definition HarrisCorner.h:37
This class implements a frame pyramid.
Definition FramePyramid.h:46
unsigned int finestWidth() const
Returns the width of the finest (first) layer.
Definition FramePyramid.h:828
bool isValid() const
Returns whether this pyramid holds at least one frame layer.
Definition FramePyramid.h:913
std::function< bool(const Frame &sourceLayer, Frame &targetLayer, Worker *worker)> DownsamplingFunction
Definition of a function allowing to downsample a frame.
Definition FramePyramid.h:91
unsigned int width(const unsigned int layer) const
Returns the width of a given layer.
Definition FramePyramid.h:816
unsigned int layers() const
Returns the number of layers this pyramid holds.
Definition FramePyramid.h:811
const FrameType & frameType() const
Returns the frame type of the finest layer.
Definition FramePyramid.h:861
unsigned int finestHeight() const
Returns the height of the finest (first) layer.
Definition FramePyramid.h:834
unsigned int height(const unsigned int layer) const
Returns the height of a given layer.
Definition FramePyramid.h:822
const Frame & layer(const unsigned int layer) const
Returns the frame of a specified layer.
Definition FramePyramid.h:773
static void downsampleByTwo8BitPerChannel11(const uint8_t *source, uint8_t *target, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int channels, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Reduces the resolution of a given frame by two, applying a 1-1 downsampling.
Definition FrameShrinker.h:508
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
This class implements Ocean's image class.
Definition Frame.h:1879
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:4222
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:4332
const FrameType & frameType() const
Returns the frame type of this frame.
Definition Frame.h:3936
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
bool set(const FrameType &frameType, const bool forceOwner, const bool forceWritable=false, const Indices32 &planePaddingElements=Indices32(), const Timestamp ×tamp=Timestamp(false), bool *reallocated=nullptr)
Sets a new frame type for this frame.
unsigned int size(const unsigned int planeIndex=0u) const
Returns the number of bytes necessary for a specific plane including optional padding at the end of p...
Definition Frame.h:4198
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:4206
@ 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:3241
bool isPixelFormatDataLayoutCompatible(const PixelFormat pixelFormat) const
Returns whether this pixel format has a compatible data layout with a given pixel format.
Definition Frame.h:3303
uint32_t numberPlanes() const
Returns the number of planes of the pixel format of this frame.
Definition Frame.h:3281
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:3251
@ DT_UNSIGNED_INTEGER_8
Unsigned 8 bit integer data type (uint8_t).
Definition Frame.h:41
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3246
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:3298
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition Frame.h:3271
DataType dataType() const
Returns the data type of the pixel format of this frame.
Definition Frame.h:3261
static void idealBins(const unsigned int width, const unsigned int height, const size_t numberBins, unsigned int &horizontalBins, unsigned int &verticalBins, const unsigned int minimalHorizontalBins=2u, const unsigned int minimalVerticalBins=2u)
Calculates the ideal number of horizontal and vertical bins for an array if the overall number of bin...
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 T atan2(const T y, const T x)
Returns the arctangent of a given value in radian.
Definition Numeric.h:1636
static constexpr T pi()
Returns PI which is equivalent to 180 degree.
Definition Numeric.h:926
static T log10(const T value)
Returns the logarithm to base 10 of a given value.
Definition Numeric.h:1715
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 bool isEqualEps(const T value)
Returns whether a value is smaller than or equal to a small epsilon.
Definition Numeric.h:2096
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.
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
std::vector< HarrisCorner > HarrisCorners
Definition of a vector holding Harris corners.
Definition HarrisCorner.h:30
PinholeCamerasT< Scalar > PinholeCameras
Definition of a vector holding pinhole camera objects.
Definition PinholeCamera.h:68
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:61
SharedAnyCamerasT< Scalar > SharedAnyCameras
Definition of a vector holding AnyCamera objects.
Definition AnyCamera.h:91
std::vector< FREAKDescriptor32 > FREAKDescriptors32
Vector of 32-bytes long FREAK descriptors.
Definition FREAKDescriptor.h:69
FREAKDescriptorT< 32 > FREAKDescriptor32
Typedef for the 32-bytes long FREAK descriptor.
Definition FREAKDescriptor.h:66
std::vector< FREAKDescriptor64 > FREAKDescriptors64
Vector of 64-bytes long FREAK descriptors.
Definition FREAKDescriptor.h:75
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
The camera data that is required to compute the FREAK descriptor of an image point.
Definition FREAKDescriptor.h:95
Eigen::Vector3f unprojectRayIF
The normalized ray that points from projection center to a 2D pixel location in the image plane of ca...
Definition FREAKDescriptor.h:97
PointJacobianMatrix2x3 pointJacobianMatrixIF
The 2-by-3 Jacobian matrix of a projection matrix wrt. to the above 2D pixel location in the image pl...
Definition FREAKDescriptor.h:100