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);
457 template <
unsigned int tChannels>
458 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);
481 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
482 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);
503 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
504 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);
526 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
527 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);
546 template <
unsigned int tChannels>
547 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);
550 template <
bool tPixelOriginUpperLeft>
553 ocean_assert(anyCamera.
isValid() && flippedCamera_T_world.
isValid());
554 ocean_assert(rectifiedWidth != 0u && rectifiedHeight != 0u);
556 ocean_assert(rectifiedPosition.
x() >= 0 && rectifiedPosition.
x() <
Scalar(rectifiedWidth));
557 ocean_assert(rectifiedPosition.
y() >= 0 && rectifiedPosition.
y() <
Scalar(rectifiedHeight));
559 const Scalar yCorrected = tPixelOriginUpperLeft ? rectifiedPosition.
y() : (
Scalar(rectifiedHeight - 1u) - rectifiedPosition.
y());
562 const Vector3 objectPoint(rectangleOrigin + rectangleHorizontal * (rectifiedPosition.
x() /
Scalar(rectifiedWidth)) + rectangleVertical * (yCorrected /
Scalar(rectifiedHeight)));
565 const Vector2 correctedCameraPoint(cameraPoint.
x(), tPixelOriginUpperLeft ? cameraPoint.
y() : (
Scalar(anyCamera.
height() - 1u) - cameraPoint.
y()));
567 return correctedCameraPoint;
570 template <
unsigned int tChannels>
571 inline 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)
573 static_assert(tChannels > 0u,
"Invalid frame channel number!");
575 const uint8_t zeroValue[tChannels] = {0x00};
577 if (approximationBinSize == 0u)
583 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);
587 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);
594 planarRectangleObjectIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, rectifiedFrameHeight);
598 planarRectangleObjectIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, rectifiedFrameHeight);
604 const unsigned int binsX =
minmax(1u, rectifiedFrameWidth / approximationBinSize, rectifiedFrameWidth / 4u);
605 const unsigned int binsY =
minmax(1u, rectifiedFrameHeight / approximationBinSize, rectifiedFrameHeight / 4u);
606 LookupTable lookupTable(rectifiedFrameWidth, rectifiedFrameHeight, binsX, binsY);
610 planarRectangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, rectangleOrigin, rectangleHorizontal, rectangleVertical, lookupTable);
614 planarRectangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, rectangleOrigin, rectangleHorizontal, rectangleVertical, lookupTable);
617 CV::FrameInterpolatorBilinear::lookup<uint8_t, tChannels>(cameraFrame, camera.
width(), camera.
height(), lookupTable,
false, outsideFrameColor ? outsideFrameColor : zeroValue, rectifiedFrame, cameraFramePaddingElements, rectifiedFramePaddingElements, worker);
621 template <
unsigned int tChannels>
622 inline 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)
624 static_assert(tChannels > 0u,
"Invalid frame channel number!");
626 const uint8_t zeroValue[tChannels] = {0x00};
628 if (approximationBinSize == 0u)
630 const Vector3 rectangle[4] = {rectangle0, rectangle1, rectangle2, rectangle3};
636 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);
640 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);
647 arbitraryRectangleObjectIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, rectifiedFrameHeight);
651 arbitraryRectangleObjectIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, rectifiedFrame, rectifiedFrameWidth, rectifiedFrameHeight, rectifiedFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, rectifiedFrameHeight);
657 const unsigned int binsX =
minmax(1u, rectifiedFrameWidth / approximationBinSize, rectifiedFrameWidth / 4u);
658 const unsigned int binsY =
minmax(1u, rectifiedFrameHeight / approximationBinSize, rectifiedFrameHeight / 4u);
659 LookupTable lookupTable(rectifiedFrameWidth, rectifiedFrameHeight, binsX, binsY);
663 arbitraryRectangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, rectangle0, rectangle1, rectangle2, rectangle3, lookupTable);
667 arbitraryRectangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, rectangle0, rectangle1, rectangle2, rectangle3, lookupTable);
670 CV::FrameInterpolatorBilinear::lookup<uint8_t, tChannels>(cameraFrame, camera.
width(), camera.
height(), lookupTable,
false, outsideFrameColor ? outsideFrameColor : zeroValue, rectifiedFrame, cameraFramePaddingElements, rectifiedFramePaddingElements, worker);
674 template <
unsigned int tChannels>
675 inline 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)
677 static_assert(tChannels > 0u,
"Invalid frame channel number!");
679 const uint8_t zeroValue[tChannels] = {0x00};
681 if (approximationBinSize == 0u)
687 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);
691 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);
698 triangleObjectIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetWidth, targetHeight, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, targetHeight);
702 triangleObjectIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetWidth, targetHeight, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, targetHeight);
708 const unsigned int binsX =
minmax(1u, targetWidth / approximationBinSize, targetWidth / 4u);
709 const unsigned int binsY =
minmax(1u, targetHeight / approximationBinSize, targetHeight / 4u);
710 LookupTable lookupTable(targetWidth, targetHeight, binsX, binsY);
714 triangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, triangle2, triangle3, lookupTable);
718 triangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, triangle2, triangle3, lookupTable);
723 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectLookup8BitPerChannelSubset<tChannels>, cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, (
const LookupTable*)(&lookupTable), &triangle2, targetFrame, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, 0u), 0u, targetHeight, 9u, 10u, 20u);
727 triangleObjectLookup8BitPerChannelSubset<tChannels>(cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, &lookupTable, &triangle2, targetFrame, targetFramePaddingElements, outsideFrameColor ? outsideFrameColor : zeroValue, 0u, targetHeight);
732 template <
unsigned int tChannels>
733 inline 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)
735 static_assert(tChannels > 0u,
"Invalid frame channel number!");
737 if (approximationBinSize == 0u)
743 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);
747 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);
754 planarRectangleObjectMaskIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
758 planarRectangleObjectMaskIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &rectangleOrigin, &rectangleHorizontal, &rectangleVertical, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
764 const unsigned int binsX =
minmax(1u, targetWidth / approximationBinSize, targetWidth / 4u);
765 const unsigned int binsY =
minmax(1u, targetHeight / approximationBinSize, targetHeight / 4u);
766 LookupTable lookupTable(targetWidth, targetHeight, binsX, binsY);
770 planarRectangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, rectangleOrigin, rectangleHorizontal, rectangleVertical, lookupTable);
774 planarRectangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, rectangleOrigin, rectangleHorizontal, rectangleVertical, lookupTable);
777 CV::FrameInterpolatorBilinear::lookupMask8BitPerChannel<tChannels>(cameraFrame, camera.
width(), camera.
height(), lookupTable,
false, targetFrame, targetMask, cameraFramePaddingElements, targetFramePaddingElements, targetMaskPaddingElements, worker, maskValue);
781 template <
unsigned int tChannels>
782 inline 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)
784 static_assert(tChannels > 0u,
"Invalid frame channel number!");
786 if (approximationBinSize == 0u)
788 const Vector3 rectangle[4] = {rectangle0, rectangle1, rectangle2, rectangle3};
794 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);
798 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);
805 arbitraryRectangleObjectMaskIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
809 arbitraryRectangleObjectMaskIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, rectangle, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
815 const unsigned int binsX =
minmax(1u, targetWidth / approximationBinSize, targetWidth / 4u);
816 const unsigned int binsY =
minmax(1u, targetHeight / approximationBinSize, targetHeight / 4u);
817 LookupTable lookupTable(targetWidth, targetHeight, binsX, binsY);
821 arbitraryRectangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, rectangle0, rectangle1, rectangle2, rectangle3, lookupTable);
825 arbitraryRectangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, rectangle0, rectangle1, rectangle2, rectangle3, lookupTable);
828 CV::FrameInterpolatorBilinear::lookupMask8BitPerChannel<tChannels>(cameraFrame, camera.
width(), camera.
height(), lookupTable,
false, targetFrame, targetMask, cameraFramePaddingElements, targetFramePaddingElements, targetMaskPaddingElements, worker, maskValue);
832 template <
unsigned int tChannels>
833 inline 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)
835 static_assert(tChannels > 0u,
"Invalid frame channel number!");
837 if (approximationBinSize == 0u)
843 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);
847 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);
854 triangleObjectMaskIF8BitPerChannelSubset<tChannels, true>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
858 triangleObjectMaskIF8BitPerChannelSubset<tChannels, false>(cameraFrame, cameraFramePaddingElements, &camera, &flippedCamera_T_world, &triangle2, &triangle3, targetFrame, targetMask, targetWidth, targetHeight, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
864 const unsigned int binsX =
minmax(1u, targetWidth / approximationBinSize, targetWidth / 4u);
865 const unsigned int binsY =
minmax(1u, targetHeight / approximationBinSize, targetHeight / 4u);
866 LookupTable lookupTable(targetWidth, targetHeight, binsX, binsY);
870 triangleObjectIFLookupTable<true>(camera, flippedCamera_T_world, triangle2, triangle3, lookupTable);
874 triangleObjectIFLookupTable<false>(camera, flippedCamera_T_world, triangle2, triangle3, lookupTable);
879 worker->
executeFunction(
Worker::Function::createStatic(triangleObjectMaskLookup8BitPerChannelSubset<tChannels>, cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, (
const LookupTable*)&lookupTable, &triangle2, targetFrame, targetMask, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, 0u), 0u, targetHeight, 11u, 12u, 20u);
883 triangleObjectMaskLookup8BitPerChannelSubset<tChannels>(cameraFrame, camera.
width(), camera.
height(), cameraFramePaddingElements, (
const LookupTable*)(&lookupTable), &triangle2, targetFrame, targetMask, targetFramePaddingElements, targetMaskPaddingElements, maskValue, 0u, targetHeight);
888 template <
bool tPixelOriginUpperLeft>
891 ocean_assert(anyCamera.
isValid() && flippedCamera_T_world.
isValid());
901 for (
unsigned int yBin = 0u; yBin <= lookupTable.
binsY(); ++yBin)
906 for (
unsigned int xBin = 0u; xBin <= lookupTable.
binsX(); ++xBin)
910 objectPoints[xBin] =
Vector3(rectangleOrigin + rectangleHorizontal * (
Scalar(x) * invRectifiedWidth) + rectangleVertical * (yCorrected * invRectifiedHeight));
913 anyCamera.
projectToImageIF(flippedCamera_T_world, objectPoints.
data(), objectPoints.size(), imagePoints.data());
915 for (
unsigned int xBin = 0u; xBin <= lookupTable.
binsX(); ++xBin)
917 const Vector2& imagePoint = imagePoints[xBin];
919 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
926 template <
bool tPixelOriginUpperLeft>
929 ocean_assert(anyCamera.
isValid() && flippedCamera_T_world.
isValid());
936 for (
unsigned int yBin = 0u; yBin <= lookupTable.
binsY(); ++yBin)
941 const Vector3 left(rectangle0 + (rectangle1 - rectangle0) * (
Scalar(yCorrected) * invRectifiedHeight));
942 const Vector3 right(rectangle3 + (rectangle2 - rectangle3) * (
Scalar(yCorrected) * invRectifiedHeight));
944 for (
unsigned int xBin = 0u; xBin <= lookupTable.
binsX(); ++xBin)
948 const Vector3 objectPoint(left + (right - left) * (
Scalar(x) * invRectifiedWidth));
951 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
958 template <
bool tPixelOriginUpperLeft>
961 ocean_assert(anyCamera.
isValid() && flippedCamera_T_world.
isValid());
965 for (
unsigned int yBin = 0u; yBin <= lookupTable.
binsY(); ++yBin)
970 for (
unsigned int xBin = 0u; xBin <= lookupTable.
binsX(); ++xBin)
979 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
986 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
987 void 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)
989 static_assert(tChannels >= 1u,
"Invalid channel number!");
991 ocean_assert(cameraFrame !=
nullptr && rectifiedFrame !=
nullptr && rectangleOrigin !=
nullptr && rectangleHorizontal !=
nullptr && rectangleVertical !=
nullptr);
992 ocean_assert(camera !=
nullptr && camera->
isValid() && flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
993 ocean_assert(rectifiedFrameWidth >= 1u && rectifiedFrameHeight >= 1u);
995 ocean_assert(firstRectifiedFrameRow + numberRectifiedFrameRows <= rectifiedFrameHeight);
1003 const unsigned int rectifiedFrameStrideElements = rectifiedFrameWidth * tChannels + rectifiedFramePaddingElements;
1005 uint8_t* rectifiedPixel = rectifiedFrame + firstRectifiedFrameRow * rectifiedFrameStrideElements;
1007 for (
unsigned int y = firstRectifiedFrameRow; y < firstRectifiedFrameRow + numberRectifiedFrameRows; ++y)
1011 for (
unsigned int x = 0u; x < rectifiedFrameWidth; ++x)
1013 const Vector3 objectPoint(*rectangleOrigin + *rectangleHorizontal * (
Scalar(x) * invRectifiedFrameWidth) + *rectangleVertical * (yCorrected * invRectifiedFrameHeight));
1016 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1018 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1020 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, rectifiedPixel);
1024 memcpy(rectifiedPixel, outsideFrameColor,
sizeof(uint8_t) * tChannels);
1027 rectifiedPixel += tChannels;
1030 rectifiedPixel += rectifiedFramePaddingElements;
1034 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1035 void 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)
1037 static_assert(tChannels >= 1u,
"Invalid channel number!");
1039 ocean_assert(cameraFrame !=
nullptr && rectifiedFrame !=
nullptr && rectangle !=
nullptr);
1040 ocean_assert(camera !=
nullptr && camera->
isValid() && flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1041 ocean_assert(rectifiedFrameWidth >= 1u && rectifiedFrameHeight >= 1u);
1043 ocean_assert(firstRectifiedFrameRow + numberRectifiedFrameRows <= rectifiedFrameHeight);
1051 const unsigned int rectifiedFrameStrideElements = rectifiedFrameWidth * tChannels + rectifiedFramePaddingElements;
1053 uint8_t* rectifiedPixel = rectifiedFrame + firstRectifiedFrameRow * rectifiedFrameStrideElements;
1055 const Vector3 direction10 = rectangle[1] - rectangle[0];
1056 const Vector3 direction23 = rectangle[2] - rectangle[3];
1058 for (
unsigned int y = firstRectifiedFrameRow; y < firstRectifiedFrameRow + numberRectifiedFrameRows; ++y)
1062 const Vector3 left(rectangle[0] + direction10 * (
Scalar(yCorrected) * invRectifiedFrameHeight));
1063 const Vector3 right(rectangle[3] + direction23 * (
Scalar(yCorrected) * invRectifiedFrameHeight));
1065 for (
unsigned int x = 0u; x < rectifiedFrameWidth; ++x)
1067 const Vector3 objectPoint(left + (right - left) * (
Scalar(x) * invRectifiedFrameWidth));
1070 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1072 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1074 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, rectifiedPixel);
1078 memcpy(rectifiedPixel, outsideFrameColor,
sizeof(uint8_t) * tChannels);
1081 rectifiedPixel += tChannels;
1084 rectifiedPixel += rectifiedFramePaddingElements;
1088 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1089 void 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)
1091 static_assert(tChannels >= 1u,
"Invalid channel number!");
1093 ocean_assert(cameraFrame !=
nullptr && targetFrame !=
nullptr && triangle2 !=
nullptr && triangle3 !=
nullptr);
1094 ocean_assert(camera !=
nullptr && camera->
isValid() && flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1095 ocean_assert(targetWidth >= 0u &&targetHeight >= 0u);
1097 ocean_assert(firstTargetRow + numberTargetRows <= targetHeight);
1102 const unsigned int targetStrideElements = targetWidth * tChannels + targetFramePaddingElements;
1106 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1110 uint8_t* targetPixel = targetFrame + y * targetStrideElements;
1112 for (
unsigned int x = 0u; x < targetWidth; ++x)
1121 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1123 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1125 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, targetPixel);
1129 *((PixelType*)(targetPixel)) = *((
const PixelType*)(outsideFrameColor));
1133 targetPixel += tChannels;
1138 template <
unsigned int tChannels>
1139 void 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)
1141 static_assert(tChannels >= 1u,
"Invalid channel number!");
1143 ocean_assert(cameraFrame !=
nullptr && targetFrame !=
nullptr && triangle2 !=
nullptr && lookupTable && !lookupTable->
isEmpty());
1144 ocean_assert(cameraFrameWidth >= 1u && cameraFrameHeight >= 1u);
1146 ocean_assert(firstTargetRow + numberTargetRows <= (
unsigned int)(lookupTable->
sizeY()));
1148 const Scalar cameraFrameWidth1 =
Scalar(cameraFrameWidth - 1u);
1149 const Scalar cameraFrameHeight1 =
Scalar(cameraFrameHeight - 1u);
1151 const unsigned int targetFrameWidth = (
unsigned int)(lookupTable->
sizeX());
1153 const unsigned int targetFrameStrideElements = targetFrameWidth * tChannels + targetFramePaddingElements;
1157 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1159 uint8_t* targetPixel = targetFrame + y * targetFrameStrideElements;
1161 for (
unsigned int x = 0u; x < targetFrameWidth; ++x)
1167 if (inputPosition.
x() >= 0 && inputPosition.
y() >= 0 && inputPosition.
x() <= cameraFrameWidth1 && inputPosition.
y() <= cameraFrameHeight1)
1169 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, cameraFrameWidth, cameraFrameHeight, cameraFramePaddingElements, inputPosition, targetPixel);
1173 *((PixelType*)(targetPixel)) = *((PixelType*)(outsideFrameColor));
1177 targetPixel += tChannels;
1182 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1183 void 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)
1185 static_assert(tChannels >= 1u,
"Invalid channel number!");
1187 ocean_assert(cameraFrame !=
nullptr);
1188 ocean_assert(camera !=
nullptr && camera->
isValid());
1189 ocean_assert(flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1190 ocean_assert(rectangleOrigin !=
nullptr && rectangleHorizontal !=
nullptr && rectangleVertical !=
nullptr);
1191 ocean_assert(targetFrame !=
nullptr && targetMask !=
nullptr);
1192 ocean_assert(targetWidth > 0u && targetHeight > 0u);
1194 ocean_assert(firstTargetRow + numberTargetRows <= targetHeight);
1196 const unsigned int targetFrameStrideElements = targetWidth * tChannels + targetFramePaddingElements;
1197 const unsigned int targetMaskStrideElements = targetWidth + targetMaskPaddingElements;
1205 uint8_t* targetPixel = targetFrame + firstTargetRow * targetFrameStrideElements;
1207 targetMask += firstTargetRow * targetMaskStrideElements;
1209 Vectors3 objectPoints(targetWidth);
1212 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1216 for (
unsigned int x = 0u; x < targetWidth; ++x)
1218 objectPoints[x] =
Vector3(*rectangleOrigin + *rectangleHorizontal * (
Scalar(x) * invTargetWidth) + *rectangleVertical * (
Scalar(yCorrected) * invTargetHeight));
1221 camera->
projectToImageIF(*flippedCamera_T_world, objectPoints.
data(), objectPoints.size(), imagePoints.data());
1223 for (
unsigned int x = 0u; x < targetWidth; ++x)
1225 const Vector2& imagePoint = imagePoints[x];
1227 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1229 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1231 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, targetPixel);
1232 *targetMask = maskValue;
1236 *targetMask = 0xFF - maskValue;
1239 targetPixel += tChannels;
1243 targetPixel += targetFramePaddingElements;
1244 targetMask += targetMaskPaddingElements;
1248 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1249 void 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)
1251 static_assert(tChannels >= 1u,
"Invalid channel number!");
1253 ocean_assert(cameraFrame !=
nullptr);
1254 ocean_assert(camera !=
nullptr && camera->
isValid());
1255 ocean_assert(flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1256 ocean_assert(rectangle !=
nullptr);
1257 ocean_assert(targetFrame !=
nullptr && targetMask !=
nullptr);
1258 ocean_assert(targetWidth > 0u && targetHeight > 0u);
1260 ocean_assert(firstTargetRow + numberTargetRows <= targetHeight);
1262 const unsigned int targetFrameStrideElements = targetWidth * tChannels + targetFramePaddingElements;
1263 const unsigned int targetMaskStrideElements = targetWidth + targetMaskPaddingElements;
1271 uint8_t* targetPixel = targetFrame + firstTargetRow * targetFrameStrideElements;
1273 targetMask += firstTargetRow * targetMaskStrideElements;
1275 Vectors3 objectPoints(targetWidth);
1278 const Vector3 direction10 = rectangle[1] - rectangle[0];
1279 const Vector3 direction23 = rectangle[2] - rectangle[3];
1281 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1285 const Vector3 left(rectangle[0] + direction10 * (
Scalar(yCorrected) * invTargetHeight));
1286 const Vector3 right(rectangle[3] + direction23 * (
Scalar(yCorrected) * invTargetHeight));
1288 for (
unsigned int x = 0u; x < targetWidth; ++x)
1290 objectPoints[x] = left + (right - left) * (
Scalar(x) * invTargetWidth);
1293 camera->
projectToImageIF(*flippedCamera_T_world, objectPoints.
data(), objectPoints.size(), imagePoints.data());
1295 for (
unsigned int x = 0u; x < targetWidth; ++x)
1297 const Vector2& imagePoint = imagePoints[x];
1299 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1301 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1303 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, targetPixel);
1304 *targetMask = maskValue;
1308 *targetMask = 0xFF - maskValue;
1311 targetPixel += tChannels;
1315 targetPixel += targetFramePaddingElements;
1316 targetMask += targetMaskPaddingElements;
1320 template <
unsigned int tChannels,
bool tPixelOriginUpperLeft>
1321 void 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)
1323 static_assert(tChannels >= 1u,
"Invalid channel number!");
1325 ocean_assert(cameraFrame !=
nullptr && camera !=
nullptr && camera->
isValid());
1326 ocean_assert(flippedCamera_T_world !=
nullptr && flippedCamera_T_world->
isValid());
1328 ocean_assert(triangle2 !=
nullptr && triangle2->
isValid());
1329 ocean_assert(triangle3 !=
nullptr && triangle2->
isValid());
1331 ocean_assert(targetFrame !=
nullptr && targetMask !=
nullptr);
1333 ocean_assert(targetWidth > 0u && targetHeight > 0u);
1334 ocean_assert(firstTargetRow + numberTargetRows <= targetHeight);
1339 const unsigned int targetFrameStrideElements = targetWidth * tChannels + targetFramePaddingElements;
1340 const unsigned int targetMaskStrideElements = targetWidth + targetMaskPaddingElements;
1342 uint8_t* targetPixel = targetFrame + firstTargetRow * targetFrameStrideElements;
1344 targetMask += firstTargetRow * targetMaskStrideElements;
1346 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1350 for (
unsigned int x = 0u; x < targetWidth; ++x)
1359 const Vector2 correctedImagePoint(imagePoint.
x(), tPixelOriginUpperLeft ? imagePoint.
y() : (frameHeight1 - imagePoint.
y()));
1361 if (correctedImagePoint.
x() >= 0 && correctedImagePoint.
y() >= 0 && correctedImagePoint.
x() <= frameWidth1 && correctedImagePoint.
y() <= frameHeight1)
1363 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, camera->
width(), camera->
height(), cameraFramePaddingElements, correctedImagePoint, targetPixel);
1364 *targetMask = maskValue;
1368 *targetMask = 0xFF - maskValue;
1372 targetPixel += tChannels;
1376 targetPixel += targetFramePaddingElements;
1377 targetMask += targetMaskPaddingElements;
1381 template <
unsigned int tChannels>
1382 void 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)
1384 static_assert(tChannels >= 1u,
"Invalid channel number!");
1386 ocean_assert(cameraFrame !=
nullptr && cameraFrameWidth >= 1u && cameraFrameHeight >= 1u);
1387 ocean_assert(triangle2 !=
nullptr && lookupTable && !lookupTable->
isEmpty());
1389 ocean_assert(targetFrame !=
nullptr && targetMask !=
nullptr);
1391 ocean_assert(firstTargetRow + numberTargetRows <= (
unsigned int)(lookupTable->
sizeY()));
1393 const unsigned int targetFrameStrideElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels + targetFramePaddingElements;
1394 const unsigned int targetMaskStrideElements = (
unsigned int)(lookupTable->
sizeX()) + targetMaskPaddingElements;
1396 const Scalar cameraFrameWidth1 =
Scalar(cameraFrameWidth - 1u);
1397 const Scalar cameraFrameHeight1 =
Scalar(cameraFrameHeight - 1u);
1399 uint8_t* targetPixel = targetFrame + firstTargetRow * targetFrameStrideElements;
1401 targetMask += firstTargetRow * targetMaskStrideElements;
1403 for (
unsigned int y = firstTargetRow; y < firstTargetRow + numberTargetRows; ++y)
1405 for (
unsigned int x = 0u; x < (
unsigned int)(lookupTable->
sizeX()); ++x)
1411 if (inputPosition.
x() >= 0 && inputPosition.
y() >= 0 && inputPosition.
x() <= cameraFrameWidth1 && inputPosition.
y() <= cameraFrameHeight1)
1413 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(cameraFrame, cameraFrameWidth, cameraFrameHeight, cameraFramePaddingElements, inputPosition, targetPixel);
1414 *targetMask = maskValue;
1418 *targetMask = 0xFFu - maskValue;
1422 targetPixel += tChannels;
1426 targetPixel += targetFramePaddingElements;
1427 targetMask += targetMaskPaddingElements;
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
virtual unsigned int width() const =0
Returns the width of the camera image.
virtual VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual unsigned int height() const =0
Returns the height of the camera image.
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:1035
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:987
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:1321
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:551
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:622
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:571
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:675
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:1089
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:927
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:733
LookupCorner2< Vector2 > LookupTable
Definition of a lookup table storing 2D vectors as elements.
Definition: FrameRectification.h:45
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:889
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:1183
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:959
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:1139
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:1382
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:1249
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:782
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:833
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a static function with no function parameter.
Definition: Caller.h:2876
Template class allowing to define an array of data types.
Definition: DataType.h:27
This class implements Ocean's image class.
Definition: Frame.h:1792
PixelOrigin
Defines different types of frame origin positions.
Definition: Frame.h:1046
@ ORIGIN_UPPER_LEFT
The first pixel lies in the upper left corner, the last pixel in the lower right corner.
Definition: Frame.h:1050
const T * data() const
Returns a pointer to the internal values.
Definition: HomogenousMatrix4.h:1843
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
size_t sizeY() const
Returns the vertical dimension of this lookup object.
Definition: Lookup2.h:947
size_t sizeX() const
Returns the horizontal dimension of this lookup object.
Definition: Lookup2.h:941
bool isEmpty() const
Returns whether this lookup object does not hold any lookup bin.
Definition: Lookup2.h:1009
size_t binsY() const
Returns the number of vertical bins of this lookup object.
Definition: Lookup2.h:959
size_t binsX() const
Returns the number of horizontal bins of this lookup object.
Definition: Lookup2.h:953
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:2128
T bilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1815
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:1775
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:1764
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:767
bool isInside(const VectorT2< T > &point) const
Returns whether a given point lies inside this triangle.
Definition: Triangle2.h:730
bool isValid() const
Returns whether this triangle can provide valid barycentric coordinates (for 64 bit floating point va...
Definition: Triangle2.h:806
This class implements a 3D triangle.
Definition: Triangle3.h:80
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:698
const T & y() const noexcept
Returns the y value.
Definition: Vector2.h:710
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
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:903
float Scalar
Definition of a scalar type.
Definition: Math.h:128
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition: Vector3.h:22
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition: Vector3.h:65
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15