8#ifndef META_OCEAN_CV_ADVANCED_FRAME_RECTIFICATION_H
9#define META_OCEAN_CV_ADVANCED_FRAME_RECTIFICATION_H
91 static bool arbitraryRectangleObject(
const Frame& cameraFrame,
const AnyCamera& camera,
const HomogenousMatrix4& world_T_camera,
const Vector3& rectangle0,
const Vector3& rectangle1,
const Vector3& rectangle2,
const Vector3& rectangle3,
Frame& rectifiedFrame,
Worker* worker =
nullptr,
const uint8_t* outsideFrameColor =
nullptr,
const unsigned int approximationBinSize = 0u);
127 static bool planarRectangleObjectMask(
const Frame& cameraFrame,
const AnyCamera& camera,
const HomogenousMatrix4& world_T_camera,
const Vector3& rectangleOrigin,
const Vector3& rectangleHorizontal,
const Vector3& rectangleVertical,
Frame& targetFrame,
Frame& targetMask,
Worker* worker =
nullptr,
const uint8_t maskValue = 0xFFu,
const unsigned int approximationBinSize = 0u);
147 static bool arbitraryRectangleObjectMask(
const Frame& cameraFrame,
const AnyCamera& camera,
const HomogenousMatrix4& world_T_camera,
const Vector3& rectangle0,
const Vector3& rectangle1,
const Vector3& rectangle2,
const Vector3& rectangle3,
Frame& targetFrame,
Frame& targetMask,
Worker* worker =
nullptr,
const uint8_t maskValue = 0xFFu,
const unsigned int approximationBinSize = 0u);
185 template <
bool tPixelOriginUpperLeft>
186 static Vector2 planarRectangleObjectRectifiedPosition2cameraPositionIF(
const AnyCamera& anyCamera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vector3& rectangleOrigin,
const Vector3& rectangleHorizontal,
const Vector3& rectangleVertical,
const unsigned int rectifiedWidth,
const unsigned int rectifiedHeight,
const Vector2& rectifiedPosition);
209 template <
unsigned int tChannels>
210 static inline void planarRectangleObjectIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vector3& rectangleOrigin,
const Vector3& rectangleHorizontal,
const Vector3& rectangleVertical, uint8_t* rectifiedFrame,
const unsigned int rectifiedFrameWidth,
const unsigned int rectifiedFrameHeight,
const unsigned int rectifiedFramePaddingElements,
Worker* worker =
nullptr,
const uint8_t* outsideFrameColor =
nullptr,
const unsigned int approximationBinSize = 0u);
234 template <
unsigned int tChannels>
235 static inline void arbitraryRectangleObjectIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vector3& rectangle0,
const Vector3& rectangle1,
const Vector3& rectangle2,
const Vector3& rectangle3, uint8_t* rectifiedFrame,
const unsigned int rectifiedFrameWidth,
const unsigned int rectifiedFrameHeight,
const unsigned int rectifiedFramePaddingElements,
Worker* worker =
nullptr,
const uint8_t* outsideFrameColor =
nullptr,
const unsigned int approximationBinSize = 0u);
257 template <
unsigned int tChannels>
258 static inline void triangleObjectIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Triangle2& triangle2,
const Triangle3& triangle3, uint8_t* targetFrame,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr,
const uint8_t* outsideFrameColor =
nullptr,
const unsigned int approximationBinSize = 0u);
283 template <
unsigned int tChannels>
284 static inline void planarRectangleObjectMaskIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vector3& rectangleOrigin,
const Vector3& rectangleHorizontal,
const Vector3& rectangleVertical, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
Worker* worker =
nullptr,
const uint8_t maskValue = 0xFFu,
const unsigned int approximationBinSize = 0u);
310 template <
unsigned int tChannels>
311 static inline void arbitraryRectangleObjectMaskIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vector3& rectangle0,
const Vector3& rectangle1,
const Vector3& rectangle2,
const Vector3& rectangle3, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
Worker* worker =
nullptr,
const uint8_t maskValue = 0xFFu,
const unsigned int approximationBinSize = 0u);
335 template <
unsigned int tChannels>
336 static inline void triangleObjectMaskIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Triangle2& triangle2,
const Triangle3& triangle3, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
Worker* worker =
nullptr,
const uint8_t maskValue = 0xFFu,
const unsigned int approximationBinSize = 0u);
350 template <
bool tPixelOriginUpperLeft>
364 template <
bool tPixelOriginUpperLeft>
376 template <
bool tPixelOriginUpperLeft>
398 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
399 static void planarRectangleObjectIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Vector3* rectangleOrigin,
const Vector3* rectangleHorizontal,
const Vector3* rectangleVertical, uint8_t* rectifiedFrame,
const unsigned int rectifiedFrameWidth,
const unsigned int rectifiedFrameHeight,
const unsigned int rectifiedFramePaddingElements,
const uint8_t* outsideFrameColor,
const unsigned int firstRectifiedFrameRow,
const unsigned int numberRectifiedFrameRows);
418 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
419 static void arbitraryRectangleObjectIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Vector3* rectangle, uint8_t* rectifiedFrame,
const unsigned int rectifiedFrameWidth,
const unsigned int rectifiedFrameHeight,
const unsigned int rectifiedFramePaddingElements,
const uint8_t* outsideFrameColor,
const unsigned int firstRectifiedFrameRow,
const unsigned int numberRectifiedFrameRows);
439 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
440 static void triangleObjectIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Triangle2* triangle2,
const Triangle3* triangle3, uint8_t* targetFrame,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const uint8_t* outsideFrameColor,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows);
458 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
459 static void triangleObjectLookup8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFrameWidth,
const unsigned int cameraFrameHeight,
const unsigned int cameraFramePaddingElements,
const LookupTable* lookupTable,
const Triangle2* triangle2, uint8_t* targetFrame,
const unsigned int targetFramePaddingElements,
const uint8_t* outsideFrameColor,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows);
482 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
483 static void planarRectangleObjectMaskIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Vector3* rectangleOrigin,
const Vector3* rectangleHorizontal,
const Vector3* rectangleVertical, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
const uint8_t maskValue,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows);
504 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
505 static void arbitraryRectangleObjectMaskIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Vector3* rectangle, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
const uint8_t maskValue,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows);
527 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
528 static void triangleObjectMaskIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Triangle2* triangle2,
const Triangle3* triangle3, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
const uint8_t maskValue,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows);
548 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
549 static void triangleObjectMaskLookup8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFrameWidth,
const unsigned int cameraFrameHeight,
const unsigned int cameraFramePaddingElements,
const LookupTable* lookupTable,
const Triangle2* triangle2, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
const uint8_t maskValue,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows);
552template <
bool tPixelOriginUpperLeft>
555 ocean_assert(anyCamera.
isValid() && flippedCamera_T_world.
isValid());
556 ocean_assert(rectifiedWidth != 0u && rectifiedHeight != 0u);
558 ocean_assert(rectifiedPosition.
x() >= 0 && rectifiedPosition.
x() <
Scalar(rectifiedWidth));
559 ocean_assert(rectifiedPosition.
y() >= 0 && rectifiedPosition.
y() <
Scalar(rectifiedHeight));
561 const Scalar yCorrected = tPixelOriginUpperLeft ? rectifiedPosition.
y() : (
Scalar(rectifiedHeight - 1u) - rectifiedPosition.
y());
564 const Vector3 objectPoint(rectangleOrigin + rectangleHorizontal * (rectifiedPosition.
x() /
Scalar(rectifiedWidth)) + rectangleVertical * (yCorrected /
Scalar(rectifiedHeight)));
567 const Vector2 correctedCameraPoint(cameraPoint.
x(), tPixelOriginUpperLeft ? cameraPoint.
y() : (
Scalar(anyCamera.
height() - 1u) - cameraPoint.
y()));
569 return correctedCameraPoint;
572template <
unsigned int tChannels>
573inline void FrameRectification::planarRectangleObjectIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vector3& rectangleOrigin,
const Vector3& rectangleHorizontal,
const Vector3& rectangleVertical, uint8_t* rectifiedFrame,
const unsigned int rectifiedFrameWidth,
const unsigned int rectifiedFrameHeight,
const unsigned int rectifiedFramePaddingElements,
Worker* worker,
const uint8_t* outsideFrameColor,
const unsigned int approximationBinSize)
575 static_assert(tChannels > 0u,
"Invalid frame channel number!");
577 const uint8_t zeroValue[tChannels] = {0x00};
579 if (approximationBinSize == 0u)
585 worker->
executeFunction(
Worker::Function::createStatic(planarRectangleObjectIF8BitPerChannelSubset<tChannels, true>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, 0u), 0u, rectifiedFrameHeight, 12u, 13u, 20u);
589 worker->
executeFunction(
Worker::Function::createStatic(planarRectangleObjectIF8BitPerChannelSubset<tChannels, false>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, 0u), 0u, rectifiedFrameHeight, 12u, 13u, 20u);
596 planarRectangleObjectIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, rectifiedFrameHeight);
600 planarRectangleObjectIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, rectifiedFrameHeight);
606 const unsigned int binsX =
minmax(1u, rectifiedFrameWidth / approximationBinSize, rectifiedFrameWidth / 4u);
607 const unsigned int binsY =
minmax(1u, rectifiedFrameHeight / approximationBinSize, rectifiedFrameHeight / 4u);
608 LookupTable lookupTable(rectifiedFrameWidth, rectifiedFrameHeight, binsX, binsY);
612 planarRectangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, rectangleOrigin, rectangleHorizontal, rectangleVertical, lookupTable);
616 planarRectangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, rectangleOrigin, rectangleHorizontal, rectangleVertical, lookupTable);
619 CV::FrameInterpolatorBilinear::lookup<uint8_t, tChannels>(cameraFrame, camera.
width(), camera.
height(), lookupTable,
false, outsideFrameColor ? outsideFrameColor : zeroValue, rectifiedFrame, cameraFramePaddingElements, rectifiedFramePaddingElements, worker);
623template <
unsigned int tChannels>
624inline void FrameRectification::arbitraryRectangleObjectIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vector3& rectangle0,
const Vector3& rectangle1,
const Vector3& rectangle2,
const Vector3& rectangle3, uint8_t* rectifiedFrame,
const unsigned int rectifiedFrameWidth,
const unsigned int rectifiedFrameHeight,
const unsigned int rectifiedFramePaddingElements,
Worker* worker,
const uint8_t* outsideFrameColor,
const unsigned int approximationBinSize)
626 static_assert(tChannels > 0u,
"Invalid frame channel number!");
628 const uint8_t zeroValue[tChannels] = {0x00};
630 if (approximationBinSize == 0u)
632 const Vector3 rectangle[4] = {rectangle0, rectangle1, rectangle2, rectangle3};
638 worker->
executeFunction(
Worker::Function::createStatic(arbitraryRectangleObjectIF8BitPerChannelSubset<tChannels, true>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, 0u), 0u, rectifiedFrameHeight, 10u, 11u, 20u);
642 worker->
executeFunction(
Worker::Function::createStatic(arbitraryRectangleObjectIF8BitPerChannelSubset<tChannels, false>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, 0u), 0u, rectifiedFrameHeight, 10u, 11u, 20u);
649 arbitraryRectangleObjectIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, rectifiedFrameHeight);
653 arbitraryRectangleObjectIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, rectifiedFrameHeight);
659 const unsigned int binsX =
minmax(1u, rectifiedFrameWidth / approximationBinSize, rectifiedFrameWidth / 4u);
660 const unsigned int binsY =
minmax(1u, rectifiedFrameHeight / approximationBinSize, rectifiedFrameHeight / 4u);
661 LookupTable lookupTable(rectifiedFrameWidth, rectifiedFrameHeight, binsX, binsY);
665 arbitraryRectangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, rectangle0, rectangle1, rectangle2, rectangle3, lookupTable);
669 arbitraryRectangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, rectangle0, rectangle1, rectangle2, rectangle3, lookupTable);
672 CV::FrameInterpolatorBilinear::lookup<uint8_t, tChannels>(cameraFrame, camera.
width(), camera.
height(), lookupTable,
false, outsideFrameColor ? outsideFrameColor : zeroValue, rectifiedFrame, cameraFramePaddingElements, rectifiedFramePaddingElements, worker);
676template <
unsigned int tChannels>
677inline void FrameRectification::triangleObjectIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Triangle2& triangle2,
const Triangle3& triangle3, uint8_t* targetFrame,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
Worker* worker,
const uint8_t* outsideFrameColor,
const unsigned int approximationBinSize)
679 static_assert(tChannels > 0u,
"Invalid frame channel number!");
681 const uint8_t zeroValue[tChannels] = {0x00};
683 if (approximationBinSize == 0u)
689 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectIF8BitPerChannelSubset<tChannels, true>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetWidth, targetHeight, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, 0u), 0u, targetHeight, 11u, 12u, 20u);
693 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectIF8BitPerChannelSubset<tChannels, false>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetWidth, targetHeight, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, 0u), 0u, targetHeight, 11u, 12u, 20u);
700 triangleObjectIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetWidth, targetHeight, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, targetHeight);
704 triangleObjectIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetWidth, targetHeight, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, targetHeight);
710 const unsigned int binsX =
minmax(1u, targetWidth / approximationBinSize, targetWidth / 4u);
711 const unsigned int binsY =
minmax(1u, targetHeight / approximationBinSize, targetHeight / 4u);
712 LookupTable lookupTable(targetWidth, targetHeight, binsX, binsY);
716 triangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, triangle2, triangle3, lookupTable);
720 triangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, triangle2, triangle3, lookupTable);
727 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectLookup8BitPerChannelSubset<tChannels, true>, cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, (
const LookupTable*)(&lookupTable), &triangle2, targetFrame, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, 0u), 0u, targetHeight, 9u, 10u, 20u);
731 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectLookup8BitPerChannelSubset<tChannels, false>, cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, (
const LookupTable*)(&lookupTable), &triangle2, targetFrame, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, 0u), 0u, targetHeight, 9u, 10u, 20u);
738 triangleObjectLookup8BitPerChannelSubset<tChannels, true>(cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, &lookupTable, &triangle2, targetFrame, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, targetHeight);
742 triangleObjectLookup8BitPerChannelSubset<tChannels, false>(cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, &lookupTable, &triangle2, targetFrame, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, targetHeight);
748template <
unsigned int tChannels>
749inline void FrameRectification::planarRectangleObjectMaskIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vector3& rectangleOrigin,
const Vector3& rectangleHorizontal,
const Vector3& rectangleVertical, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
Worker* worker,
const uint8_t maskValue,
const unsigned int approximationBinSize)
751 static_assert(tChannels > 0u,
"Invalid frame channel number!");
753 if (approximationBinSize == 0u)
759 worker->
executeFunction(
Worker::Function::createStatic(planarRectangleObjectMaskIF8BitPerChannelSubset<tChannels, true>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, 0u), 0u, targetHeight, 14u, 15u, 20u);
763 worker->
executeFunction(
Worker::Function::createStatic(planarRectangleObjectMaskIF8BitPerChannelSubset<tChannels, false>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, 0u), 0u, targetHeight, 14u, 15u, 20u);
770 planarRectangleObjectMaskIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
774 planarRectangleObjectMaskIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
780 const unsigned int binsX =
minmax(1u, targetWidth / approximationBinSize, targetWidth / 4u);
781 const unsigned int binsY =
minmax(1u, targetHeight / approximationBinSize, targetHeight / 4u);
782 LookupTable lookupTable(targetWidth, targetHeight, binsX, binsY);
786 planarRectangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, rectangleOrigin, rectangleHorizontal, rectangleVertical, lookupTable);
790 planarRectangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, rectangleOrigin, rectangleHorizontal, rectangleVertical, lookupTable);
793 CV::FrameInterpolatorBilinear::lookupMask8BitPerChannel<tChannels>(cameraFrame, camera.
width(), camera.
height(), lookupTable,
false, targetFrame, targetMask, cameraFramePaddingElements, targetFramePaddingElements, targetMaskPaddingElements, worker, maskValue);
797template <
unsigned int tChannels>
798inline void FrameRectification::arbitraryRectangleObjectMaskIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vector3& rectangle0,
const Vector3& rectangle1,
const Vector3& rectangle2,
const Vector3& rectangle3, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
Worker* worker,
const uint8_t maskValue,
const unsigned int approximationBinSize)
800 static_assert(tChannels > 0u,
"Invalid frame channel number!");
802 if (approximationBinSize == 0u)
804 const Vector3 rectangle[4] = {rectangle0, rectangle1, rectangle2, rectangle3};
810 worker->
executeFunction(
Worker::Function::createStatic(arbitraryRectangleObjectMaskIF8BitPerChannelSubset<tChannels, true>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, 0u), 0u, targetHeight, 12u, 13u, 20u);
814 worker->
executeFunction(
Worker::Function::createStatic(arbitraryRectangleObjectMaskIF8BitPerChannelSubset<tChannels, false>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, 0u), 0u, targetHeight, 12u, 13u, 20u);
821 arbitraryRectangleObjectMaskIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
825 arbitraryRectangleObjectMaskIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
831 const unsigned int binsX =
minmax(1u, targetWidth / approximationBinSize, targetWidth / 4u);
832 const unsigned int binsY =
minmax(1u, targetHeight / approximationBinSize, targetHeight / 4u);
833 LookupTable lookupTable(targetWidth, targetHeight, binsX, binsY);
837 arbitraryRectangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, rectangle0, rectangle1, rectangle2, rectangle3, lookupTable);
841 arbitraryRectangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, rectangle0, rectangle1, rectangle2, rectangle3, lookupTable);
844 CV::FrameInterpolatorBilinear::lookupMask8BitPerChannel<tChannels>(cameraFrame, camera.
width(), camera.
height(), lookupTable,
false, targetFrame, targetMask, cameraFramePaddingElements, targetFramePaddingElements, targetMaskPaddingElements, worker, maskValue);
848template <
unsigned int tChannels>
849inline void FrameRectification::triangleObjectMaskIF8BitPerChannel(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const FrameType::PixelOrigin pixelOrigin,
const AnyCamera& camera,
const HomogenousMatrix4& flippedCamera_T_world,
const Triangle2& triangle2,
const Triangle3& triangle3, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
Worker* worker,
const uint8_t maskValue,
const unsigned int approximationBinSize)
851 static_assert(tChannels > 0u,
"Invalid frame channel number!");
853 if (approximationBinSize == 0u)
859 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectMaskIF8BitPerChannelSubset<tChannels, true>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, 0u), 0u, targetHeight, 13u, 14u, 20u);
863 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectMaskIF8BitPerChannelSubset<tChannels, false>, cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, 0u), 0u, targetHeight, 13u, 14u, 20u);
870 triangleObjectMaskIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
874 triangleObjectMaskIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
880 const unsigned int binsX =
minmax(1u, targetWidth / approximationBinSize, targetWidth / 4u);
881 const unsigned int binsY =
minmax(1u, targetHeight / approximationBinSize, targetHeight / 4u);
882 LookupTable lookupTable(targetWidth, targetHeight, binsX, binsY);
886 triangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, triangle2, triangle3, lookupTable);
890 triangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, triangle2, triangle3, lookupTable);
897 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectMaskLookup8BitPerChannelSubset<tChannels, true>, cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, (
const LookupTable*)&lookupTable, &triangle2, targetFrame, targetMask, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, 0u), 0u, targetHeight, 11u, 12u, 20u);
901 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectMaskLookup8BitPerChannelSubset<tChannels, false>, cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, (
const LookupTable*)&lookupTable, &triangle2, targetFrame, targetMask, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, 0u), 0u, targetHeight, 11u, 12u, 20u);
908 triangleObjectMaskLookup8BitPerChannelSubset<tChannels, true>(cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, (
const LookupTable*)(&lookupTable), &triangle2, targetFrame, targetMask, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
912 triangleObjectMaskLookup8BitPerChannelSubset<tChannels, false>(cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, (
const LookupTable*)(&lookupTable), &triangle2, targetFrame, targetMask, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
918template <
bool tPixelOriginUpperLeft>
921 ocean_assert(anyCamera.
isValid() && flippedCamera_T_world.
isValid());
931 for (
unsigned int yBin = 0u; yBin <= lookupTable.
binsY(); ++yBin)
936 for (
unsigned int xBin = 0u; xBin <= lookupTable.
binsX(); ++xBin)
940 objectPoints[xBin] =
Vector3(rectangleOrigin + rectangleHorizontal * (
Scalar(x) * invRectifiedWidth) + rectangleVertical * (yCorrected * invRectifiedHeight));
943 anyCamera.
projectToImageIF(flippedCamera_T_world, objectPoints.
data(), objectPoints.size(), imagePoints.data());
945 for (
unsigned int xBin = 0u; xBin <= lookupTable.
binsX(); ++xBin)
947 const Vector2& imagePoint = imagePoints[xBin];
949 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
956template <
bool tPixelOriginUpperLeft>
959 ocean_assert(anyCamera.
isValid() && flippedCamera_T_world.
isValid());
966 for (
unsigned int yBin = 0u; yBin <= lookupTable.
binsY(); ++yBin)
971 const Vector3 left(rectangle0 + (rectangle1 - rectangle0) * (
Scalar(yCorrected) * invRectifiedHeight));
972 const Vector3 right(rectangle3 + (rectangle2 - rectangle3) * (
Scalar(yCorrected) * invRectifiedHeight));
974 for (
unsigned int xBin = 0u; xBin <= lookupTable.
binsX(); ++xBin)
978 const Vector3 objectPoint(left + (right - left) * (
Scalar(x) * invRectifiedWidth));
981 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
988template <
bool tPixelOriginUpperLeft>
991 ocean_assert(anyCamera.
isValid() && flippedCamera_T_world.
isValid());
995 for (
unsigned int yBin = 0u; yBin <= lookupTable.
binsY(); ++yBin)
1000 for (
unsigned int xBin = 0u; xBin <= lookupTable.
binsX(); ++xBin)
1009 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1016template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1017void FrameRectification::planarRectangleObjectIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Vector3* rectangleOrigin,
const Vector3* rectangleHorizontal,
const Vector3* rectangleVertical, uint8_t* rectifiedFrame,
const unsigned int rectifiedFrameWidth,
const unsigned int rectifiedFrameHeight,
const unsigned int rectifiedFramePaddingElements,
const uint8_t* outsideFrameColor,
const unsigned int firstRectifiedFrameRow,
const unsigned int numberRectifiedFrameRows)
1019 static_assert(tChannels >= 1u,
"Invalid channel number!");
1021 ocean_assert(cameraFrame !=
nullptr && rectifiedFrame !=
nullptr && rectangleOrigin !=
nullptr && rectangleHorizontal !=
nullptr && rectangleVertical !=
nullptr);
1022 ocean_assert(camera !=
nullptr && camera->
isValid() && flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1023 ocean_assert(rectifiedFrameWidth >= 1u && rectifiedFrameHeight >= 1u);
1025 ocean_assert(firstRectifiedFrameRow + numberRectifiedFrameRows <= rectifiedFrameHeight);
1033 const unsigned int rectifiedFrameStrideElements = rectifiedFrameWidth * tChannels + rectifiedFramePaddingElements;
1035 uint8_t* rectifiedPixel = rectifiedFrame + firstRectifiedFrameRow * rectifiedFrameStrideElements;
1037 for (
unsigned int y = firstRectifiedFrameRow; y < firstRectifiedFrameRow + numberRectifiedFrameRows; ++y)
1041 for (
unsigned int x = 0u; x < rectifiedFrameWidth; ++x)
1043 const Vector3 objectPoint(*rectangleOrigin + *rectangleHorizontal * (
Scalar(x) * invRectifiedFrameWidth) + *rectangleVertical * (yCorrected * invRectifiedFrameHeight));
1046 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1048 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1050 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, rectifiedPixel);
1054 memcpy(rectifiedPixel, outsideFrameColor,
sizeof(uint8_t) * tChannels);
1057 rectifiedPixel += tChannels;
1060 rectifiedPixel += rectifiedFramePaddingElements;
1064template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1065void FrameRectification::arbitraryRectangleObjectIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Vector3* rectangle, uint8_t* rectifiedFrame,
const unsigned int rectifiedFrameWidth,
const unsigned int rectifiedFrameHeight,
const unsigned int rectifiedFramePaddingElements,
const uint8_t* outsideFrameColor,
const unsigned int firstRectifiedFrameRow,
const unsigned int numberRectifiedFrameRows)
1067 static_assert(tChannels >= 1u,
"Invalid channel number!");
1069 ocean_assert(cameraFrame !=
nullptr && rectifiedFrame !=
nullptr && rectangle !=
nullptr);
1070 ocean_assert(camera !=
nullptr && camera->
isValid() && flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1071 ocean_assert(rectifiedFrameWidth >= 1u && rectifiedFrameHeight >= 1u);
1073 ocean_assert(firstRectifiedFrameRow + numberRectifiedFrameRows <= rectifiedFrameHeight);
1081 const unsigned int rectifiedFrameStrideElements = rectifiedFrameWidth * tChannels + rectifiedFramePaddingElements;
1083 uint8_t* rectifiedPixel = rectifiedFrame + firstRectifiedFrameRow * rectifiedFrameStrideElements;
1085 const Vector3 direction10 = rectangle[1] - rectangle[0];
1086 const Vector3 direction23 = rectangle[2] - rectangle[3];
1088 for (
unsigned int y = firstRectifiedFrameRow; y < firstRectifiedFrameRow + numberRectifiedFrameRows; ++y)
1092 const Vector3 left(rectangle[0] + direction10 * (
Scalar(yCorrected) * invRectifiedFrameHeight));
1093 const Vector3 right(rectangle[3] + direction23 * (
Scalar(yCorrected) * invRectifiedFrameHeight));
1095 for (
unsigned int x = 0u; x < rectifiedFrameWidth; ++x)
1097 const Vector3 objectPoint(left + (right - left) * (
Scalar(x) * invRectifiedFrameWidth));
1100 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1102 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1104 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, rectifiedPixel);
1108 memcpy(rectifiedPixel, outsideFrameColor,
sizeof(uint8_t) * tChannels);
1111 rectifiedPixel += tChannels;
1114 rectifiedPixel += rectifiedFramePaddingElements;
1118template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1119void FrameRectification::triangleObjectIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Triangle2* triangle2,
const Triangle3* triangle3, uint8_t* targetFrame,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const uint8_t* outsideFrameColor,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows)
1121 static_assert(tChannels >= 1u,
"Invalid channel number!");
1123 ocean_assert(cameraFrame !=
nullptr && targetFrame !=
nullptr && triangle2 !=
nullptr && triangle3 !=
nullptr);
1124 ocean_assert(camera !=
nullptr && camera->
isValid() && flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1125 ocean_assert(targetWidth >= 0u &&targetHeight >= 0u);
1127 ocean_assert(firstTargetRow + numberTargetRows <= targetHeight);
1132 const unsigned int targetStrideElements = targetWidth * tChannels + targetFramePaddingElements;
1136 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1140 uint8_t* targetPixel = targetFrame + y * targetStrideElements;
1142 for (
unsigned int x = 0u; x < targetWidth; ++x)
1151 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1153 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1155 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, targetPixel);
1159 *((PixelType*)(targetPixel)) = *((
const PixelType*)(outsideFrameColor));
1163 targetPixel += tChannels;
1168template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1169void FrameRectification::triangleObjectLookup8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFrameWidth,
const unsigned int cameraFrameHeight,
const unsigned int cameraFramePaddingElements,
const LookupTable* lookupTable,
const Triangle2* triangle2, uint8_t* targetFrame,
const unsigned int targetFramePaddingElements,
const uint8_t* outsideFrameColor,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows)
1171 static_assert(tChannels >= 1u,
"Invalid channel number!");
1173 ocean_assert(cameraFrame !=
nullptr && targetFrame !=
nullptr && triangle2 !=
nullptr && lookupTable && !lookupTable->
isEmpty());
1174 ocean_assert(cameraFrameWidth >= 1u && cameraFrameHeight >= 1u);
1176 ocean_assert(firstTargetRow + numberTargetRows <= (
unsigned int)(lookupTable->
sizeY()));
1178 const Scalar cameraFrameWidth1 =
Scalar(cameraFrameWidth - 1u);
1179 const Scalar cameraFrameHeight1 =
Scalar(cameraFrameHeight - 1u);
1181 const unsigned int targetFrameWidth = (
unsigned int)(lookupTable->
sizeX());
1182 const unsigned int targetFrameHeight = (
unsigned int)(lookupTable->
sizeY());
1184 const unsigned int targetFrameStrideElements = targetFrameWidth * tChannels + targetFramePaddingElements;
1188 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1192 uint8_t* targetPixel = targetFrame + y * targetFrameStrideElements;
1194 for (
unsigned int x = 0u; x < targetFrameWidth; ++x)
1200 if (inputPosition.
x() >= 0 && inputPosition.
y() >= 0 && inputPosition.
x() <= cameraFrameWidth1 && inputPosition.
y() <= cameraFrameHeight1)
1202 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, cameraFrameWidth, cameraFrameHeight, cameraFramePaddingElements, inputPosition, targetPixel);
1206 *((PixelType*)(targetPixel)) = *((PixelType*)(outsideFrameColor));
1210 targetPixel += tChannels;
1215template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1216void FrameRectification::planarRectangleObjectMaskIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Vector3* rectangleOrigin,
const Vector3* rectangleHorizontal,
const Vector3* rectangleVertical, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
const uint8_t maskValue,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows)
1218 static_assert(tChannels >= 1u,
"Invalid channel number!");
1220 ocean_assert(cameraFrame !=
nullptr);
1221 ocean_assert(camera !=
nullptr && camera->
isValid());
1222 ocean_assert(flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1223 ocean_assert(rectangleOrigin !=
nullptr && rectangleHorizontal !=
nullptr && rectangleVertical !=
nullptr);
1224 ocean_assert(targetFrame !=
nullptr && targetMask !=
nullptr);
1225 ocean_assert(targetWidth > 0u && targetHeight > 0u);
1227 ocean_assert(firstTargetRow + numberTargetRows <= targetHeight);
1229 const unsigned int targetFrameStrideElements = targetWidth * tChannels + targetFramePaddingElements;
1230 const unsigned int targetMaskStrideElements = targetWidth + targetMaskPaddingElements;
1238 uint8_t* targetPixel = targetFrame + firstTargetRow * targetFrameStrideElements;
1240 targetMask += firstTargetRow * targetMaskStrideElements;
1242 Vectors3 objectPoints(targetWidth);
1245 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1249 for (
unsigned int x = 0u; x < targetWidth; ++x)
1251 objectPoints[x] =
Vector3(*rectangleOrigin + *rectangleHorizontal * (
Scalar(x) * invTargetWidth) + *rectangleVertical * (
Scalar(yCorrected) * invTargetHeight));
1254 camera->
projectToImageIF(*flippedCamera_T_world, objectPoints.
data(), objectPoints.size(), imagePoints.data());
1256 for (
unsigned int x = 0u; x < targetWidth; ++x)
1258 const Vector2& imagePoint = imagePoints[x];
1260 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1262 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1264 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, targetPixel);
1265 *targetMask = maskValue;
1269 *targetMask = 0xFF - maskValue;
1272 targetPixel += tChannels;
1276 targetPixel += targetFramePaddingElements;
1277 targetMask += targetMaskPaddingElements;
1281template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1282void FrameRectification::arbitraryRectangleObjectMaskIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Vector3* rectangle, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
const uint8_t maskValue,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows)
1284 static_assert(tChannels >= 1u,
"Invalid channel number!");
1286 ocean_assert(cameraFrame !=
nullptr);
1287 ocean_assert(camera !=
nullptr && camera->
isValid());
1288 ocean_assert(flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1289 ocean_assert(rectangle !=
nullptr);
1290 ocean_assert(targetFrame !=
nullptr && targetMask !=
nullptr);
1291 ocean_assert(targetWidth > 0u && targetHeight > 0u);
1293 ocean_assert(firstTargetRow + numberTargetRows <= targetHeight);
1295 const unsigned int targetFrameStrideElements = targetWidth * tChannels + targetFramePaddingElements;
1296 const unsigned int targetMaskStrideElements = targetWidth + targetMaskPaddingElements;
1304 uint8_t* targetPixel = targetFrame + firstTargetRow * targetFrameStrideElements;
1306 targetMask += firstTargetRow * targetMaskStrideElements;
1308 Vectors3 objectPoints(targetWidth);
1311 const Vector3 direction10 = rectangle[1] - rectangle[0];
1312 const Vector3 direction23 = rectangle[2] - rectangle[3];
1314 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1318 const Vector3 left(rectangle[0] + direction10 * (
Scalar(yCorrected) * invTargetHeight));
1319 const Vector3 right(rectangle[3] + direction23 * (
Scalar(yCorrected) * invTargetHeight));
1321 for (
unsigned int x = 0u; x < targetWidth; ++x)
1323 objectPoints[x] = left + (right - left) * (
Scalar(x) * invTargetWidth);
1326 camera->
projectToImageIF(*flippedCamera_T_world, objectPoints.
data(), objectPoints.size(), imagePoints.data());
1328 for (
unsigned int x = 0u; x < targetWidth; ++x)
1330 const Vector2& imagePoint = imagePoints[x];
1332 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1334 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1336 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, targetPixel);
1337 *targetMask = maskValue;
1341 *targetMask = 0xFF - maskValue;
1344 targetPixel += tChannels;
1348 targetPixel += targetFramePaddingElements;
1349 targetMask += targetMaskPaddingElements;
1353template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1354void FrameRectification::triangleObjectMaskIF8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFramePaddingElements,
const AnyCamera* camera,
const HomogenousMatrix4* flippedCamera_T_world,
const Triangle2* triangle2,
const Triangle3* triangle3, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
const uint8_t maskValue,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows)
1356 static_assert(tChannels >= 1u,
"Invalid channel number!");
1358 ocean_assert(cameraFrame !=
nullptr && camera !=
nullptr && camera->
isValid());
1359 ocean_assert(flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1361 ocean_assert(triangle2 !=
nullptr && triangle2->
isValid());
1362 ocean_assert(triangle3 !=
nullptr && triangle2->
isValid());
1364 ocean_assert(targetFrame !=
nullptr && targetMask !=
nullptr);
1366 ocean_assert(targetWidth > 0u && targetHeight > 0u);
1367 ocean_assert(firstTargetRow + numberTargetRows <= targetHeight);
1372 const unsigned int targetFrameStrideElements = targetWidth * tChannels + targetFramePaddingElements;
1373 const unsigned int targetMaskStrideElements = targetWidth + targetMaskPaddingElements;
1375 uint8_t* targetPixel = targetFrame + firstTargetRow * targetFrameStrideElements;
1377 targetMask += firstTargetRow * targetMaskStrideElements;
1379 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1383 for (
unsigned int x = 0u; x < targetWidth; ++x)
1392 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1394 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1396 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, targetPixel);
1397 *targetMask = maskValue;
1401 *targetMask = 0xFF - maskValue;
1405 targetPixel += tChannels;
1409 targetPixel += targetFramePaddingElements;
1410 targetMask += targetMaskPaddingElements;
1414template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1415void FrameRectification::triangleObjectMaskLookup8BitPerChannelSubset(
const uint8_t* cameraFrame,
const unsigned int cameraFrameWidth,
const unsigned int cameraFrameHeight,
const unsigned int cameraFramePaddingElements,
const LookupTable* lookupTable,
const Triangle2* triangle2, uint8_t* targetFrame, uint8_t* targetMask,
const unsigned int targetFramePaddingElements,
const unsigned int targetMaskPaddingElements,
const uint8_t maskValue,
const unsigned int firstTargetRow,
const unsigned int numberTargetRows)
1417 static_assert(tChannels >= 1u,
"Invalid channel number!");
1419 ocean_assert(cameraFrame !=
nullptr && cameraFrameWidth >= 1u && cameraFrameHeight >= 1u);
1420 ocean_assert(triangle2 !=
nullptr && lookupTable && !lookupTable->
isEmpty());
1422 ocean_assert(targetFrame !=
nullptr && targetMask !=
nullptr);
1424 ocean_assert(firstTargetRow + numberTargetRows <= (
unsigned int)(lookupTable->
sizeY()));
1426 const unsigned int targetFrameStrideElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels + targetFramePaddingElements;
1427 const unsigned int targetMaskStrideElements = (
unsigned int)(lookupTable->
sizeX()) + targetMaskPaddingElements;
1429 const Scalar cameraFrameWidth1 =
Scalar(cameraFrameWidth - 1u);
1430 const Scalar cameraFrameHeight1 =
Scalar(cameraFrameHeight - 1u);
1432 uint8_t* targetPixel = targetFrame + firstTargetRow * targetFrameStrideElements;
1434 targetMask += firstTargetRow * targetMaskStrideElements;
1436 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1440 for (
unsigned int x = 0u; x < (
unsigned int)(lookupTable->
sizeX()); ++x)
1446 if (inputPosition.
x() >= 0 && inputPosition.
y() >= 0 && inputPosition.
x() <= cameraFrameWidth1 && inputPosition.
y() <= cameraFrameHeight1)
1448 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, cameraFrameWidth, cameraFrameHeight, cameraFramePaddingElements, inputPosition, targetPixel);
1449 *targetMask = maskValue;
1453 *targetMask = 0xFFu - maskValue;
1457 targetPixel += tChannels;
1461 targetPixel += targetFramePaddingElements;
1462 targetMask += targetMaskPaddingElements;
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:131
virtual unsigned int width() const =0
Returns the width of the camera image.
virtual unsigned int height() const =0
Returns the height of the camera image.
virtual VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual bool isValid() const =0
Returns whether this camera is valid.
The following comfort class provides comfortable functions simplifying prototyping applications but a...
Definition FrameRectification.h:53
static bool triangleObject(const Frame &cameraFrame, const AnyCamera &camera, const HomogenousMatrix4 &world_T_camera, const Triangle2 &triangle2, const Triangle3 &triangle3, Frame &targetFrame, Worker *worker=nullptr, const uint8_t *outsideFrameColor=nullptr, const unsigned int approximationBinSize=0u)
Draws a 2D triangle into an image of a 3D triangle as seen in a camera image.
static bool arbitraryRectangleObject(const Frame &cameraFrame, const AnyCamera &camera, const HomogenousMatrix4 &world_T_camera, const Vector3 &rectangle0, const Vector3 &rectangle1, const Vector3 &rectangle2, const Vector3 &rectangle3, Frame &rectifiedFrame, Worker *worker=nullptr, const uint8_t *outsideFrameColor=nullptr, const unsigned int approximationBinSize=0u)
Given a camera image, an arbitrary 3D rectangle defined in world, and a sampling resolution on the re...
static bool arbitraryRectangleObjectMask(const Frame &cameraFrame, const AnyCamera &camera, const HomogenousMatrix4 &world_T_camera, const Vector3 &rectangle0, const Vector3 &rectangle1, const Vector3 &rectangle2, const Vector3 &rectangle3, Frame &targetFrame, Frame &targetMask, Worker *worker=nullptr, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=0u)
Given a camera image, an arbitrary 3D rectangle defined in world, and a sampling resolution on the re...
static bool planarRectangleObject(const Frame &cameraFrame, const AnyCamera &camera, const HomogenousMatrix4 &world_T_camera, const Vector3 &rectangleOrigin, const Vector3 &rectangleHorizontal, const Vector3 &rectangleVertical, Frame &rectifiedFrame, Worker *worker=nullptr, const uint8_t *outsideFrameColor=nullptr, const unsigned int approximationBinSize=0u)
Given a camera image, a planar 3D rectangle defined in world, and a sampling resolution on the rectan...
static bool planarRectangleObjectMask(const Frame &cameraFrame, const AnyCamera &camera, const HomogenousMatrix4 &world_T_camera, const Vector3 &rectangleOrigin, const Vector3 &rectangleHorizontal, const Vector3 &rectangleVertical, Frame &targetFrame, Frame &targetMask, Worker *worker=nullptr, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=0u)
Given a camera image, a planar 3D rectangle defined in world, and a sampling resolution on the rectan...
static bool triangleObjectMask(const Frame &cameraFrame, const AnyCamera &camera, const HomogenousMatrix4 &world_T_camera, const Triangle2 &triangle2, const Triangle3 &triangle3, Frame &targetFrame, Frame &targetMask, Worker *worker=nullptr, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=0u)
Draws a 2D triangle into an image of a 3D triangle as seen in a camera image.
This class implements functions creating rectified images from frame areas or objects located in a fr...
Definition FrameRectification.h:39
static void arbitraryRectangleObjectIF8BitPerChannelSubset(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const AnyCamera *camera, const HomogenousMatrix4 *flippedCamera_T_world, const Vector3 *rectangle, uint8_t *rectifiedFrame, const unsigned int rectifiedFrameWidth, const unsigned int rectifiedFrameHeight, const unsigned int rectifiedFramePaddingElements, const uint8_t *outsideFrameColor, const unsigned int firstRectifiedFrameRow, const unsigned int numberRectifiedFrameRows)
Creates a subset of the rectangle image from a specific position in 3D space.
Definition FrameRectification.h:1065
static void planarRectangleObjectIF8BitPerChannelSubset(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const AnyCamera *camera, const HomogenousMatrix4 *flippedCamera_T_world, const Vector3 *rectangleOrigin, const Vector3 *rectangleHorizontal, const Vector3 *rectangleVertical, uint8_t *rectifiedFrame, const unsigned int rectifiedFrameWidth, const unsigned int rectifiedFrameHeight, const unsigned int rectifiedFramePaddingElements, const uint8_t *outsideFrameColor, const unsigned int firstRectifiedFrameRow, const unsigned int numberRectifiedFrameRows)
Creates a subset of the rectangular image of an area on a 3D plane as seen in a camera image.
Definition FrameRectification.h:1017
static void triangleObjectMaskIF8BitPerChannelSubset(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const AnyCamera *camera, const HomogenousMatrix4 *flippedCamera_T_world, const Triangle2 *triangle2, const Triangle3 *triangle3, uint8_t *targetFrame, uint8_t *targetMask, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int targetFramePaddingElements, const unsigned int targetMaskPaddingElements, const uint8_t maskValue, const unsigned int firstTargetRow, const unsigned int numberTargetRows)
Creates a subset of a 2D triangle in a target image from a specific 3D triangle on a 3D plane.
Definition FrameRectification.h:1354
static Vector2 planarRectangleObjectRectifiedPosition2cameraPositionIF(const AnyCamera &anyCamera, const HomogenousMatrix4 &flippedCamera_T_world, const Vector3 &rectangleOrigin, const Vector3 &rectangleHorizontal, const Vector3 &rectangleVertical, const unsigned int rectifiedWidth, const unsigned int rectifiedHeight, const Vector2 &rectifiedPosition)
Converts the pixel position defined in the rectified frame to the pixel position defined in the camer...
Definition FrameRectification.h:553
static void arbitraryRectangleObjectIF8BitPerChannel(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const FrameType::PixelOrigin pixelOrigin, const AnyCamera &camera, const HomogenousMatrix4 &flippedCamera_T_world, const Vector3 &rectangle0, const Vector3 &rectangle1, const Vector3 &rectangle2, const Vector3 &rectangle3, uint8_t *rectifiedFrame, const unsigned int rectifiedFrameWidth, const unsigned int rectifiedFrameHeight, const unsigned int rectifiedFramePaddingElements, Worker *worker=nullptr, const uint8_t *outsideFrameColor=nullptr, const unsigned int approximationBinSize=0u)
Given a camera image, an arbitrary 3D rectangle defined in world, and a sampling resolution on the re...
Definition FrameRectification.h:624
static void planarRectangleObjectIF8BitPerChannel(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const FrameType::PixelOrigin pixelOrigin, const AnyCamera &camera, const HomogenousMatrix4 &flippedCamera_T_world, const Vector3 &rectangleOrigin, const Vector3 &rectangleHorizontal, const Vector3 &rectangleVertical, uint8_t *rectifiedFrame, const unsigned int rectifiedFrameWidth, const unsigned int rectifiedFrameHeight, const unsigned int rectifiedFramePaddingElements, Worker *worker=nullptr, const uint8_t *outsideFrameColor=nullptr, const unsigned int approximationBinSize=0u)
Given a camera image, a planar 3D rectangle defined in world, and a sampling resolution on the rectan...
Definition FrameRectification.h:573
static void triangleObjectIF8BitPerChannel(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const FrameType::PixelOrigin pixelOrigin, const AnyCamera &camera, const HomogenousMatrix4 &flippedCamera_T_world, const Triangle2 &triangle2, const Triangle3 &triangle3, uint8_t *targetFrame, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int targetPaddingElements, Worker *worker=nullptr, const uint8_t *outsideFrameColor=nullptr, const unsigned int approximationBinSize=0u)
Draws a 2D triangle into an image of a 3D triangle as seen in a camera image.
Definition FrameRectification.h:677
static void triangleObjectIF8BitPerChannelSubset(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const AnyCamera *camera, const HomogenousMatrix4 *flippedCamera_T_world, const Triangle2 *triangle2, const Triangle3 *triangle3, uint8_t *targetFrame, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int targetFramePaddingElements, const uint8_t *outsideFrameColor, const unsigned int firstTargetRow, const unsigned int numberTargetRows)
Draws a subset of a 2D triangle into a target frame.
Definition FrameRectification.h:1119
static void arbitraryRectangleObjectIFLookupTable(const AnyCamera &anyCamera, const HomogenousMatrix4 &flippedCamera_T_world, const Vector3 &rectangle0, const Vector3 &rectangle1, const Vector3 &rectangle2, const Vector3 &rectangle3, LookupTable &lookupTable)
Creates an interpolation lookup table for a rectification of an arbitrary rectangle object (a 2D text...
Definition FrameRectification.h:957
static void planarRectangleObjectMaskIF8BitPerChannel(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const FrameType::PixelOrigin pixelOrigin, const AnyCamera &camera, const HomogenousMatrix4 &flippedCamera_T_world, const Vector3 &rectangleOrigin, const Vector3 &rectangleHorizontal, const Vector3 &rectangleVertical, uint8_t *targetFrame, uint8_t *targetMask, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int targetFramePaddingElements, const unsigned int targetMaskPaddingElements, Worker *worker=nullptr, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=0u)
Given a camera image, a planar 3D rectangle defined in world, and a sampling resolution on the rectan...
Definition FrameRectification.h:749
static void planarRectangleObjectIFLookupTable(const AnyCamera &anyCamera, const HomogenousMatrix4 &flippedCamera_T_world, const Vector3 &rectangleOrigin, const Vector3 &rectangleHorizontal, const Vector3 &rectangleVertical, LookupTable &lookupTable)
Creates an interpolation lookup table for a rectification of a planar rectangle object (a 2D texture ...
Definition FrameRectification.h:919
static void triangleObjectLookup8BitPerChannelSubset(const uint8_t *cameraFrame, const unsigned int cameraFrameWidth, const unsigned int cameraFrameHeight, const unsigned int cameraFramePaddingElements, const LookupTable *lookupTable, const Triangle2 *triangle2, uint8_t *targetFrame, const unsigned int targetFramePaddingElements, const uint8_t *outsideFrameColor, const unsigned int firstTargetRow, const unsigned int numberTargetRows)
Draws a subset of a 2D triangle into an image of a 3D triangle as seen in a camera image.
Definition FrameRectification.h:1169
static void planarRectangleObjectMaskIF8BitPerChannelSubset(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const AnyCamera *camera, const HomogenousMatrix4 *flippedCamera_T_world, const Vector3 *rectangleOrigin, const Vector3 *rectangleHorizontal, const Vector3 *rectangleVertical, uint8_t *targetFrame, uint8_t *targetMask, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int targetFramePaddingElements, const unsigned int targetMaskPaddingElements, const uint8_t maskValue, const unsigned int firstTargetRow, const unsigned int numberTargetRows)
Creates a subset of the rectangular image of an area on a 3D plane as seen in a camera image.
Definition FrameRectification.h:1216
static void triangleObjectIFLookupTable(const AnyCamera &anyCamera, const HomogenousMatrix4 &flippedCamera_T_world, const Triangle2 &triangle2, const Triangle3 &triangle3, LookupTable &lookupTable)
Creates an interpolation lookup table for a triangle object (a 2D texture in 3D place).
Definition FrameRectification.h:989
static void triangleObjectMaskLookup8BitPerChannelSubset(const uint8_t *cameraFrame, const unsigned int cameraFrameWidth, const unsigned int cameraFrameHeight, const unsigned int cameraFramePaddingElements, const LookupTable *lookupTable, const Triangle2 *triangle2, uint8_t *targetFrame, uint8_t *targetMask, const unsigned int targetFramePaddingElements, const unsigned int targetMaskPaddingElements, const uint8_t maskValue, const unsigned int firstTargetRow, const unsigned int numberTargetRows)
Creates a subset of a 2D triangle in a target image from a specific 3D triangle on a 3D plane and app...
Definition FrameRectification.h:1415
static void arbitraryRectangleObjectMaskIF8BitPerChannelSubset(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const AnyCamera *camera, const HomogenousMatrix4 *flippedCamera_T_world, const Vector3 *rectangle, uint8_t *targetFrame, uint8_t *targetMask, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int targetFramePaddingElements, const unsigned int targetMaskPaddingElements, const uint8_t maskValue, const unsigned int firstTargetRow, const unsigned int numberTargetRows)
Creates a subset of the rectangular image from a specific position in 3D space.
Definition FrameRectification.h:1282
static void arbitraryRectangleObjectMaskIF8BitPerChannel(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const FrameType::PixelOrigin pixelOrigin, const AnyCamera &camera, const HomogenousMatrix4 &flippedCamera_T_world, const Vector3 &rectangle0, const Vector3 &rectangle1, const Vector3 &rectangle2, const Vector3 &rectangle3, uint8_t *targetFrame, uint8_t *targetMask, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int targetFramePaddingElements, const unsigned int targetMaskPaddingElements, Worker *worker=nullptr, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=0u)
Given a camera image, an arbitrary 3D rectangle defined in world, and a sampling resolution on the re...
Definition FrameRectification.h:798
static void triangleObjectMaskIF8BitPerChannel(const uint8_t *cameraFrame, const unsigned int cameraFramePaddingElements, const FrameType::PixelOrigin pixelOrigin, const AnyCamera &camera, const HomogenousMatrix4 &flippedCamera_T_world, const Triangle2 &triangle2, const Triangle3 &triangle3, uint8_t *targetFrame, uint8_t *targetMask, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int targetFramePaddingElements, const unsigned int targetMaskPaddingElements, Worker *worker=nullptr, const uint8_t maskValue=0xFFu, const unsigned int approximationBinSize=0u)
Draws a 2D triangle into an image of a 3D triangle as seen in a camera image.
Definition FrameRectification.h:849
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:1969
PixelOrigin
Defines different types of frame origin positions.
Definition Frame.h:1136
@ ORIGIN_UPPER_LEFT
The first pixel lies in the upper left corner, the last pixel in the lower right corner.
Definition Frame.h:1140
const T * data() const
Returns a pointer to the internal values.
Definition HomogenousMatrix4.h:1837
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1800
size_t sizeY() const
Returns the vertical dimension of this lookup object.
Definition Lookup2.h:960
size_t sizeX() const
Returns the horizontal dimension of this lookup object.
Definition Lookup2.h:954
bool isEmpty() const
Returns whether this lookup object does not hold any lookup bin.
Definition Lookup2.h:1022
size_t binsY() const
Returns the number of vertical bins of this lookup object.
Definition Lookup2.h:972
size_t binsX() const
Returns the number of horizontal bins of this lookup object.
Definition Lookup2.h:966
This class implements a 2D lookup object with values at the bins' corners defining the individual loo...
Definition Lookup2.h:636
void setBinTopLeftCornerValue(const size_t binX, const size_t binY, const T &value)
Sets the value of one specific lookup bin's top left corner.
Definition Lookup2.h:2215
T bilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition Lookup2.h:1828
TScalar binTopLeftCornerPositionY(const size_t binY) const
Returns the vertical corner position of a specific bin corner (the top left corner) in relation to th...
Definition Lookup2.h:1788
TScalar binTopLeftCornerPositionX(const size_t binX) const
Returns the horizontal corner position of a specific bin corner (the top left corner) in relation to ...
Definition Lookup2.h:1777
This class implements a 2D triangle with Cartesian coordinates.
Definition Triangle2.h:81
VectorT3< T > cartesian2barycentric(const VectorT2< T > &cartesian) const
Returns the barycentric coordinate of a given 2D Cartesian coordinate defined in relation to this tri...
Definition Triangle2.h:759
bool isInside(const VectorT2< T > &point) const
Returns whether a given point lies inside this triangle.
Definition Triangle2.h:722
bool isValid() const
Returns whether this triangle can provide valid barycentric coordinates (for 64 bit floating point va...
Definition Triangle2.h:798
This class implements a 3D triangle.
Definition Triangle3.h:80
VectorT3< T > barycentric2cartesian(const VectorT3< T > &barycentric) const
Returns the 3D cartesian coordinate of a given barycentric coordinate defined in relation to this tri...
Definition Triangle3.h:296
static bool isBarycentricInside(const VectorT3< T > &barycentricPoint)
Returns whether a given point, specified as barycentric coordinate, lies inside a triangle.
Definition Triangle.h:69
const T & x() const noexcept
Returns the x value.
Definition Vector2.h:703
const T & y() const noexcept
Returns the y value.
Definition Vector2.h:715
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.
T minmax(const T &lowerBoundary, const T &value, const T &upperBoundary)
This function fits a given parameter into a specified value range.
Definition base/Utilities.h:973
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition Vector3.h:29
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Default definition of a type with tBytes bytes.
Definition DataType.h:32