8#ifndef META_OCEAN_MATH_ANY_CAMERA_H
9#define META_OCEAN_MATH_ANY_CAMERA_H
154 virtual std::string
name()
const = 0;
163 virtual std::unique_ptr<AnyCameraT<T>>
clone(
const unsigned int width = 0
u,
const unsigned int height = 0
u)
const = 0;
187 virtual unsigned int width()
const = 0;
450 template <
typename U>
552 inline unsigned int width()
const;
558 inline unsigned int height()
const;
634template <
typename T,
typename TCameraWrapper>
674 std::string
name()
const override;
683 std::unique_ptr<AnyCameraT<T>>
clone(
const unsigned int width = 0
u,
const unsigned int height = 0
u)
const override;
692 std::unique_ptr<AnyCameraT<float>>
cloneToFloat(
const unsigned int width = 0
u,
const unsigned int height = 0
u)
const override;
701 std::unique_ptr<AnyCameraT<double>>
cloneToDouble(
const unsigned int width = 0
u,
const unsigned int height = 0
u)
const override;
707 unsigned int width()
const override;
713 unsigned int height()
const override;
762 T
fovX()
const override;
769 T
fovY()
const override;
967template <
typename T,
typename TCameraWrapperBase>
975 using typename TCameraWrapperBase::ActualCamera;
1001 inline T
fovX()
const;
1007 inline T
fovY()
const;
1076template <
typename T>
1115 inline unsigned int width()
const;
1121 inline unsigned int height()
const;
1218 template <
typename U>
1219 inline std::unique_ptr<AnyCameraT<U>>
clone(
const unsigned int width = 0u,
const unsigned int height = 0u)
const;
1231 static inline std::string
name();
1245template <
typename T>
1284 inline unsigned int width()
const;
1290 inline unsigned int height()
const;
1392 template <
typename U>
1393 inline std::unique_ptr<AnyCameraT<U>>
clone(
const unsigned int width = 0u,
const unsigned int height = 0u)
const;
1405 static inline std::string
name();
1418template <
typename T>
1433 const std::string&
reason()
const;
1468template <
typename T>
1507 inline unsigned int width()
const;
1513 inline unsigned int height()
const;
1615 template <
typename U>
1616 inline std::unique_ptr<AnyCameraT<U>>
clone(
const unsigned int width = 0u,
const unsigned int height = 0u)
const;
1628 static inline std::string
name();
1642template <
typename T>
1672template <
typename T>
1702template <
typename T>
1726template <
typename T>
1729 update(camera, segmentSteps);
1732template <
typename T>
1735 ocean_assert(camera_ !=
nullptr);
1736 ocean_assert(camera_->isValid());
1737 ocean_assert(flippedCamera_T_world.
isValid());
1739 const VectorT3<T> cameraObjectPointIF = flippedCamera_T_world * objectPoint;
1746 const T invZ = T(1) / cameraObjectPointIF.
z();
1748 const VectorT2<T> normalizedImagePoint(cameraObjectPointIF.
x() * invZ, cameraObjectPointIF.
y() * invZ);
1750 if (!isInside(cameraBoundarySegments_, normalizedImagePoint))
1755 if (imagePoint !=
nullptr)
1757 *imagePoint = camera_->projectToImageIF(cameraObjectPointIF);
1759 ocean_assert_accuracy(camera_->isInside(*imagePoint, T(std::max(camera_->width(), camera_->height())) * T(-0.1)));
1765template <
typename T>
1771template <
typename T>
1776 return camera_->width();
1782template <
typename T>
1787 return camera_->height();
1793template <
typename T>
1796 ocean_assert(camera !=
nullptr && camera->isValid() && segmentSteps >= 1);
1797 if (camera ==
nullptr || !camera->isValid() || segmentSteps == 0)
1802 if (camera_ && camera_->isEqual(*camera))
1804 ocean_assert(isValid());
1808 cameraBoundarySegments_.clear();
1810 if (determineCameraBoundary(*camera, cameraBoundarySegments_, segmentSteps))
1817 cameraBoundarySegments_.clear();
1820 ocean_assert(isValid());
1823template <
typename T>
1826 ocean_assert(camera.
isValid() && segmentSteps >= 1);
1827 if (!camera.
isValid() || segmentSteps == 0)
1832 if (camera_ && camera_->isEqual(camera))
1834 ocean_assert(isValid());
1838 cameraBoundarySegments_.clear();
1840 if (determineCameraBoundary(camera, cameraBoundarySegments_, segmentSteps))
1842 camera_ = camera.
clone();
1847 cameraBoundarySegments_.clear();
1850 ocean_assert(isValid());
1853template <
typename T>
1856 return cameraBoundarySegments_;
1859template <
typename T>
1862 ocean_assert(camera_ ==
nullptr || !cameraBoundarySegments_.empty());
1864 return camera_ !=
nullptr;
1867template <
typename T>
1870 ocean_assert(camera.
isValid());
1876 ocean_assert(segmentSteps >= 1);
1877 if (segmentSteps < 1)
1882 constexpr unsigned int border = 0u;
1884 const std::array<VectorT2<T>, 4> corners =
1900 const T sqrProjectionErrorPrincipalPoint = camera.
projectToImageIF(principalObjectPoint).sqrDistance(principalPoint);
1902 if (sqrProjectionErrorPrincipalPoint > maximalSqrDistance)
1904 ocean_assert(
false &&
"The camera model is not precise enough");
1909 normalizedImagePoints.reserve(corners.size() * segmentSteps);
1911 for (
size_t nCorner = 0; nCorner < corners.size(); ++nCorner)
1914 const VectorT2<T>& corner1 = corners[(nCorner + 1u) % corners.size()];
1916 for (
size_t nStep = 0; nStep < segmentSteps; ++nStep)
1918 const T factor = T(nStep) / T(segmentSteps);
1920 const VectorT2<T> distortedImagePoint = corner0 * (T(1) - factor) + corner1 * factor;
1922 const VectorT2<T> offsetTowardsPrincipalPoint = (principalPoint - distortedImagePoint).normalizedOrZero() * T(1.0);
1926 if (isValidForPoint(camera, distortedImagePoint, maximalSqrDistance, 3u))
1928 objectPoint = camera.
vectorIF(distortedImagePoint,
false );
1937 VectorT2<T> boundaryImagePoint = distortedImagePoint;
1940 objectPoint = principalObjectPoint;
1942 constexpr unsigned int iterations = 20u;
1944 for (
unsigned int nIteration = 0u; nIteration < iterations; ++nIteration)
1946 if (boundaryImagePoint.
sqrDistance(centerImagePoint) <= maximalSqrDistance)
1951 const VectorT2<T> middleImagePoint = (boundaryImagePoint + centerImagePoint) * T(0.5);
1956 const T sqrMiddleDistance = middleImagePoint.
sqrDistance(projectedMiddleObjectPoint);
1958 if (sqrMiddleDistance <= maximalSqrDistance)
1960 centerImagePoint = middleImagePoint;
1962 objectPoint = camera.
vectorIF(middleImagePoint + offsetTowardsPrincipalPoint,
false );
1966 boundaryImagePoint = middleImagePoint;
1974 const VectorT2<T> normalizedImagePoint = objectPoint.
xy() / objectPoint.
z();
1976 normalizedImagePoints.emplace_back(normalizedImagePoint.
x(), normalizedImagePoint.
y());
1981 ocean_assert(normalizedImagePoints.size() >= 3);
1983 ocean_assert(cameraBoundarySegments.empty());
1984 cameraBoundarySegments.clear();
1986 cameraBoundarySegments.reserve(normalizedImagePoints.size());
1988 for (
size_t n = 1; n < normalizedImagePoints.size(); ++n)
1990 cameraBoundarySegments.emplace_back(normalizedImagePoints[n - 1], normalizedImagePoints[n]);
1993 cameraBoundarySegments.emplace_back(normalizedImagePoints.back(), normalizedImagePoints.front());
1998template <
typename T>
2001 ocean_assert(cameraBoundarySegments.size() >= 3);
2005 for (
const FiniteLineT2<T>& cameraBoundarySegment : cameraBoundarySegments)
2009 const bool segmentTopDown = cameraBoundarySegment.point0().y() < cameraBoundarySegment.point1().y();
2013 if (cameraBoundarySegment.point1().y() < normalizedImagePoint.
y() || normalizedImagePoint.
y() < cameraBoundarySegment.point0().y())
2020 if (cameraBoundarySegment.point0().y() < normalizedImagePoint.
y() || normalizedImagePoint.
y() < cameraBoundarySegment.point1().y())
2026 if (cameraBoundarySegment.isOnLine(normalizedImagePoint))
2033 if (cameraBoundarySegment.isLeftOfLine(normalizedImagePoint) == segmentTopDown)
2042 return counter % 2 == 1;
2045template <
typename T>
2048 ocean_assert(camera.
isValid());
2049 ocean_assert(camera.
isInside(imagePoint, T(-1)));
2050 ocean_assert(maximalReprojectionError >= T(0));
2051 ocean_assert(additionalChecksTowardsPrincipalPoint >= 1u);
2064 const VectorT2<T> direction = (principalPoint - imagePoint).normalizedOrZero();
2072 for (
unsigned int n = 0u; n < std::min(additionalChecksTowardsPrincipalPoint, 10u); ++n)
2074 const VectorT2<T> additionalImagePoint = imagePoint + direction * T(n + 1u);
2094 return anyCamera->cloneToFloat();
2106 return anyCamera->cloneToDouble();
2112template <
typename T>
2113template <
typename U>
2116 static_assert(std::is_same<T, U>::value,
"Invalid data types!");
2121template <
typename T,
typename TCameraWrapper>
2128template <
typename T,
typename TCameraWrapper>
2135template <
typename T,
typename TCameraWrapper>
2138 return TCameraWrapper::anyCameraType();
2141template <
typename T,
typename TCameraWrapper>
2144 return TCameraWrapper::name();
2147template <
typename T,
typename TCameraWrapper>
2150 return TCameraWrapper::template clone<T>(width, height);
2153template <
typename T,
typename TCameraWrapper>
2156 return TCameraWrapper::template clone<float>(width, height);
2159template <
typename T,
typename TCameraWrapper>
2162 return TCameraWrapper::template clone<double>(width, height);
2165template <
typename T,
typename TCameraWrapper>
2168 return TCameraWrapper::width();
2171template <
typename T,
typename TCameraWrapper>
2174 return TCameraWrapper::height();
2177template <
typename T,
typename TCameraWrapper>
2180 return TCameraWrapper::principalPoint();
2183template <
typename T,
typename TCameraWrapper>
2186 return TCameraWrapper::principalPointX();
2189template <
typename T,
typename TCameraWrapper>
2192 return TCameraWrapper::principalPointY();
2195template <
typename T,
typename TCameraWrapper>
2198 return TCameraWrapper::focalLengthX();
2201template <
typename T,
typename TCameraWrapper>
2204 return TCameraWrapper::focalLengthY();
2207template <
typename T,
typename TCameraWrapper>
2210 return TCameraWrapper::inverseFocalLengthX();
2213template <
typename T,
typename TCameraWrapper>
2216 return TCameraWrapper::inverseFocalLengthY();
2219template <
typename T,
typename TCameraWrapper>
2222 return TCameraWrapper::fovX();
2225template <
typename T,
typename TCameraWrapper>
2228 return TCameraWrapper::fovY();
2231template <
typename T,
typename TCameraWrapper>
2234 return TCameraWrapper::isInside(imagePoint, signedBorder);
2237template <
typename T,
typename TCameraWrapper>
2240 return TCameraWrapper::projectToImage(objectPoint);
2243template <
typename T,
typename TCameraWrapper>
2246 return TCameraWrapper::projectToImage(world_T_camera, objectPoint);
2249template <
typename T,
typename TCameraWrapper>
2252 return TCameraWrapper::projectToImageIF(objectPoint);
2255template <
typename T,
typename TCameraWrapper>
2258 return TCameraWrapper::projectToImageIF(flippedCamera_T_world, objectPoint);
2261template <
typename T,
typename TCameraWrapper>
2264 return TCameraWrapper::projectToImage(objectPoints, size, imagePoints);
2267template <
typename T,
typename TCameraWrapper>
2270 return TCameraWrapper::projectToImage(world_T_camera, objectPoints, size, imagePoints);
2273template <
typename T,
typename TCameraWrapper>
2276 return TCameraWrapper::projectToImageIF(objectPoints, size, imagePoints);
2279template <
typename T,
typename TCameraWrapper>
2282 return TCameraWrapper::projectToImageIF(flippedCamera_T_world, objectPoints, size, imagePoints);
2285template <
typename T,
typename TCameraWrapper>
2288 return TCameraWrapper::vector(distortedImagePoint, makeUnitVector);
2291template <
typename T,
typename TCameraWrapper>
2294 return TCameraWrapper::vector(distortedImagePoints, size, vectors, makeUnitVector);
2297template <
typename T,
typename TCameraWrapper>
2300 return TCameraWrapper::vectorIF(distortedImagePoint, makeUnitVector);
2303template <
typename T,
typename TCameraWrapper>
2306 return TCameraWrapper::vectorIF(distortedImagePoints, size, vectors, makeUnitVector);
2309template <
typename T,
typename TCameraWrapper>
2312 return TCameraWrapper::ray(distortedImagePoint, world_T_camera);
2315template <
typename T,
typename TCameraWrapper>
2318 return TCameraWrapper::ray(distortedImagePoint);
2321template <
typename T,
typename TCameraWrapper>
2324 return TCameraWrapper::pointJacobian2x3IF(flippedCameraObjectPoint, jx, jy);
2327template <
typename T,
typename TCameraWrapper>
2330 return TCameraWrapper::pointJacobian2nx3IF(flippedCameraObjectPoints, numberObjectPoints, jacobians);
2333template <
typename T,
typename TCameraWrapper>
2336 ocean_assert(eps >= T(0));
2338 if (isValid() != anyCamera.
isValid())
2350 if (name() != anyCamera.
name())
2358template <
typename T,
typename TCameraWrapper>
2361 return TCameraWrapper::isValid();
2364template <
typename T,
typename TCameraWrapperBase>
2371template <
typename T,
typename TCameraWrapperBase>
2378template <
typename T,
typename TCameraWrapperBase>
2381 return VectorT2<T>(TCameraWrapperBase::principalPointX(), TCameraWrapperBase::principalPointY());
2384template <
typename T,
typename TCameraWrapperBase>
2387 ocean_assert(TCameraWrapperBase::isValid());
2401 const T leftAngle =
NumericT<T>::atan(TCameraWrapperBase::principalPointX() * TCameraWrapperBase::inverseFocalLengthX());
2403 if (T(TCameraWrapperBase::width()) <= TCameraWrapperBase::principalPointX())
2405 ocean_assert(
false &&
"Invalid principal point");
2406 return T(2) * leftAngle;
2409 const T rightAngle =
NumericT<T>::atan((T(TCameraWrapperBase::width()) - TCameraWrapperBase::principalPointX()) * TCameraWrapperBase::inverseFocalLengthX());
2411 return leftAngle + rightAngle;
2414template <
typename T,
typename TCameraWrapperBase>
2417 ocean_assert(TCameraWrapperBase::isValid());
2431 const T topAngle =
NumericT<T>::atan(TCameraWrapperBase::principalPointY() * TCameraWrapperBase::inverseFocalLengthY());
2433 if (T(TCameraWrapperBase::height()) <= TCameraWrapperBase::principalPointY())
2435 ocean_assert(
false &&
"Invalid principal point");
2436 return T(2) * topAngle;
2439 const T bottomAngle =
NumericT<T>::atan((T(TCameraWrapperBase::height()) - TCameraWrapperBase::principalPointY()) * TCameraWrapperBase::inverseFocalLengthY());
2441 return topAngle + bottomAngle;
2444template <
typename T,
typename TCameraWrapperBase>
2447 ocean_assert(TCameraWrapperBase::isValid());
2449 const unsigned int cameraWidth = TCameraWrapperBase::width();
2450 const unsigned int cameraHeight = TCameraWrapperBase::height();
2452 ocean_assert(signedBorder < T(std::min(cameraWidth / 2u, cameraHeight / 2u)));
2454 return imagePoint.
x() >= signedBorder && imagePoint.
y() >= signedBorder
2455 && imagePoint.
x() < T(cameraWidth) - signedBorder && imagePoint.
y() < T(cameraHeight) - signedBorder;
2458template <
typename T,
typename TCameraWrapperBase>
2461 return TCameraWrapperBase::projectToImageIF(
VectorT3<T>(objectPoint.
x(), -objectPoint.
y(), -objectPoint.
z()));
2464template <
typename T,
typename TCameraWrapperBase>
2470template <
typename T,
typename TCameraWrapperBase>
2473 ocean_assert(size == 0 || objectPoints !=
nullptr);
2474 ocean_assert(size == 0 || imagePoints !=
nullptr);
2476 for (
size_t n = 0; n < size; ++n)
2479 imagePoints[n] = TCameraWrapperBase::projectToImageIF(
VectorT3<T>(objectPoint.
x(), -objectPoint.
y(), -objectPoint.
z()));
2483template <
typename T,
typename TCameraWrapperBase>
2489template <
typename T,
typename TCameraWrapperBase>
2492 const VectorT3<T> localVectorIF(TCameraWrapperBase::vectorIF(distortedImagePoint, makeUnitVector));
2494 return VectorT3<T>(localVectorIF.
x(), -localVectorIF.
y(), -localVectorIF.
z());
2497template <
typename T,
typename TCameraWrapperBase>
2500 TCameraWrapperBase::vectorIF(distortedImagePoints, size, vectors, makeUnitVector);
2502 for (
size_t n = 0; n < size; ++n)
2506 vectors[n] =
VectorT3<T>(localVectorIF.
x(), -localVectorIF.
y(), -localVectorIF.
z());
2510template <
typename T,
typename TCameraWrapperBase>
2513 ocean_assert(TCameraWrapperBase::isValid() && world_T_camera.
isValid());
2518template <
typename T,
typename TCameraWrapperBase>
2521 ocean_assert(TCameraWrapperBase::isValid());
2526template <
typename T,
typename TCameraWrapperBase>
2529 ocean_assert(flippedCameraObjectPoints !=
nullptr);
2530 ocean_assert(numberObjectPoints >= 1);
2531 ocean_assert(jacobians !=
nullptr);
2533 for (
size_t n = 0; n < numberObjectPoints; ++n)
2535 TCameraWrapperBase::pointJacobian2x3IF(flippedCameraObjectPoints[n], jacobians + 0, jacobians + 3);
2540template <
typename T>
2542 actualCamera_(std::move(actualCamera))
2547template <
typename T>
2549 actualCamera_(actualCamera)
2554template <
typename T>
2557 return actualCamera_;
2560template <
typename T>
2563 return actualCamera_.width();
2566template <
typename T>
2569 return actualCamera_.height();
2572template <
typename T>
2575 return T(actualCamera_.principalPointX());
2578template <
typename T>
2581 return T(actualCamera_.principalPointY());
2584template <
typename T>
2587 return T(actualCamera_.focalLengthX());
2590template <
typename T>
2593 return T(actualCamera_.focalLengthY());
2596template <
typename T>
2599 return T(actualCamera_.inverseFocalLengthX());
2602template <
typename T>
2605 return T(actualCamera_.inverseFocalLengthY());
2608template <
typename T>
2614template <
typename T>
2617 return VectorT2<T>(actualCamera_.template projectToImageIF<true>(flippedCamera_T_world, objectPoint,
true));
2620template <
typename T>
2623 ocean_assert(size == 0 || objectPoints !=
nullptr);
2624 ocean_assert(size == 0 || imagePoints !=
nullptr);
2626 for (
size_t n = 0; n < size; ++n)
2628 imagePoints[n] = projectToImageIF(objectPoints[n]);
2632template <
typename T>
2635 ocean_assert(size == 0 || objectPoints !=
nullptr);
2636 ocean_assert(size == 0 || imagePoints !=
nullptr);
2638 for (
size_t n = 0; n < size; ++n)
2640 imagePoints[n] = projectToImageIF(flippedCamera_T_world, objectPoints[n]);
2644template <
typename T>
2647 const VectorT2<T> undistortedImagePoint(actualCamera_.template undistort<true>(distortedImagePoint));
2649 return VectorT3<T>(actualCamera_.vectorIF(undistortedImagePoint, makeUnitVector));
2652template <
typename T>
2655 ocean_assert(distortedImagePoints !=
nullptr && size > 0);
2656 ocean_assert(vectors !=
nullptr);
2658 for (
size_t n = 0; n < size; ++n)
2660 vectors[n] = vectorIF(distortedImagePoints[n], makeUnitVector);
2664template <
typename T>
2667 ocean_assert(jx !=
nullptr && jy !=
nullptr);
2668 actualCamera_.template pointJacobian2x3IF<T, true>(flippedCameraObjectPoint, jx, jy);
2671template <
typename T>
2674 ocean_assert(eps >= T(0));
2676 return actualCamera_.isEqual(basePinhole.
actualCamera_, eps);
2679template <
typename T>
2682 return actualCamera_.isValid();
2685template <
typename T>
2686template <
typename U>
2689 ocean_assert(actualCamera_.isValid());
2691 if constexpr (std::is_same<T, U>::value)
2693 if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2695 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(actualCamera_);
2698 const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2699 const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2703 ocean_assert(
false &&
"Wrong aspect ratio!");
2707 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(
PinholeCameraT<U>(width, height, actualCamera_));
2713 if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2715 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(convertedPinholeCamera);
2718 const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2719 const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2723 ocean_assert(
false &&
"Wrong aspect ratio!");
2727 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(
PinholeCameraT<U>(width, height, convertedPinholeCamera));
2731template <
typename T>
2737template <
typename T>
2740 return std::string(
"Ocean Pinhole");
2743template <
typename T>
2745 actualCamera_(std::move(camera))
2750template <
typename T>
2752 actualCamera_(camera)
2757template <
typename T>
2760 return actualCamera_;
2763template <
typename T>
2766 return actualCamera_.width();
2769template <
typename T>
2772 return actualCamera_.height();
2775template <
typename T>
2778 return actualCamera_.principalPoint();
2781template <
typename T>
2784 return actualCamera_.principalPointX();
2787template <
typename T>
2790 return actualCamera_.principalPointY();
2793template <
typename T>
2796 return actualCamera_.focalLengthX();
2799template <
typename T>
2802 return actualCamera_.focalLengthY();
2805template <
typename T>
2808 return actualCamera_.inverseFocalLengthX();
2811template <
typename T>
2814 return actualCamera_.inverseFocalLengthY();
2817template <
typename T>
2820 return actualCamera_.projectToImageIF(objectPoint);
2823template <
typename T>
2826 return actualCamera_.projectToImageIF(flippedCamera_T_world, objectPoint);
2829template <
typename T>
2832 ocean_assert(size == 0 || objectPoints !=
nullptr);
2833 ocean_assert(size == 0 || imagePoints !=
nullptr);
2835 for (
size_t n = 0; n < size; ++n)
2837 imagePoints[n] = projectToImageIF(objectPoints[n]);
2841template <
typename T>
2844 ocean_assert(size == 0 || objectPoints !=
nullptr);
2845 ocean_assert(size == 0 || imagePoints !=
nullptr);
2847 for (
size_t n = 0; n < size; ++n)
2849 imagePoints[n] = projectToImageIF(flippedCamera_T_world, objectPoints[n]);
2853template <
typename T>
2856 return actualCamera_.vectorIF(distortedImagePoint, makeUnitVector);
2859template <
typename T>
2862 ocean_assert(distortedImagePoints !=
nullptr && size > 0);
2863 ocean_assert(vectors !=
nullptr);
2865 for (
size_t n = 0; n < size; ++n)
2867 vectors[n] = vectorIF(distortedImagePoints[n], makeUnitVector);
2871template <
typename T>
2874 actualCamera_.pointJacobian2x3IF(flippedCameraObjectPoint, jx, jy);
2877template <
typename T>
2880 ocean_assert(eps >= T(0));
2882 return actualCamera_.isEqual(baseFisheye.
actualCamera_, eps);
2885template <
typename T>
2888 return actualCamera_.isValid();
2891template <
typename T>
2892template <
typename U>
2895 ocean_assert(actualCamera_.isValid());
2897 if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2899 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBaseFisheyeT<U>>>>(
FisheyeCameraT<U>(actualCamera_));
2902 const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2903 const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2907 ocean_assert(
false &&
"Wrong aspect ratio!");
2911 const T xFactor = T(width) / T(actualCamera_.width());
2912 const T yFactor = T(height) / T(actualCamera_.height());
2914 const U newPrincipalX = U(actualCamera_.principalPointX() * xFactor);
2915 const U newPrincipalY = U(actualCamera_.principalPointY() * yFactor);
2917 const U newFocalLengthX = U(actualCamera_.focalLengthX() * xFactor);
2918 const U newFocalLengthY = U(actualCamera_.focalLengthY() * yFactor);
2920 U radialDistortion[6];
2921 for (
unsigned int n = 0u; n < 6u; ++n)
2923 radialDistortion[n] = U(actualCamera_.radialDistortion()[n]);
2926 const U tangentialDistortion[2] =
2928 U(actualCamera_.tangentialDistortion()[0]),
2929 U(actualCamera_.tangentialDistortion()[1])
2932 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBaseFisheyeT<U>>>>(
FisheyeCameraT<U>(width, height, newFocalLengthX, newFocalLengthY, newPrincipalX, newPrincipalY, radialDistortion, tangentialDistortion));
2935template <
typename T>
2941template <
typename T>
2944 return std::string(
"Ocean Fisheye");
2947template <
typename T>
2949 actualCamera_(std::move(camera))
2954template <
typename T>
2956 actualCamera_(camera)
2961template <
typename T>
2964 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2966 ocean_assert(
false &&
"This function must never be called.");
2968 return actualCamera_;
2971template <
typename T>
2974 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2976 ocean_assert(
false &&
"This function must never be called.");
2978 return (
unsigned int)(-1);
2981template <
typename T>
2984 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2986 ocean_assert(
false &&
"This function must never be called.");
2988 return (
unsigned int)(-1);
2991template <
typename T>
2994 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2996 ocean_assert(
false &&
"This function must never be called.");
3001template <
typename T>
3004 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3006 ocean_assert(
false &&
"This function must never be called.");
3011template <
typename T>
3014 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3016 ocean_assert(
false &&
"This function must never be called.");
3021template <
typename T>
3024 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3026 ocean_assert(
false &&
"This function must never be called.");
3031template <
typename T>
3034 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3036 ocean_assert(
false &&
"This function must never be called.");
3041template <
typename T>
3044 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3046 ocean_assert(
false &&
"This function must never be called.");
3051template <
typename T>
3054 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3056 ocean_assert(
false &&
"This function must never be called.");
3061template <
typename T>
3064 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3066 ocean_assert(
false &&
"This function must never be called.");
3071template <
typename T>
3074 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3076 ocean_assert(
false &&
"This function must never be called.");
3081template <
typename T>
3084 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3086 ocean_assert(
false &&
"This function must never be called.");
3090template <
typename T>
3093 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3095 ocean_assert(
false &&
"This function must never be called.");
3098template <
typename T>
3101 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3103 ocean_assert(
false &&
"This function must never be called.");
3108template <
typename T>
3111 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3113 ocean_assert(
false &&
"This function must never be called.");
3116template <
typename T>
3119 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3121 ocean_assert(
false &&
"This function must never be called.");
3124template <
typename T>
3127 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3129 ocean_assert(
false &&
"This function must never be called.");
3134template <
typename T>
3140template <
typename T>
3141template <
typename U>
3144 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3146 ocean_assert(
false &&
"This function must never be called.");
3151template <
typename T>
3157template <
typename T>
3160 return std::string(
"Invalid camera");
3163template <
typename T>
3170template <
typename T>
This class implements a helper class allowing to check whether a 3D object point projects into the ca...
Definition AnyCamera.h:518
bool projectToImageIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint, VectorT2< T > *imagePoint=nullptr) const
Returns whether a 3D object point is located in front of the camera and projects into the camera imag...
Definition AnyCamera.h:1733
bool isValid() const
Returns whether this clipper holds a valid camera model and is ready to be used.
Definition AnyCamera.h:1860
static bool isInside(const FiniteLinesT2< T > &cameraBoundarySegments, const VectorT2< T > &normalizedImagePoint)
Returns whether a given normalized image point lies inside the camera's boundary.
Definition AnyCamera.h:1999
AnyCameraClipperT()=default
Default constructor creating an invalid object.
unsigned int height() const
Returns the height of the camera profile.
Definition AnyCamera.h:1783
const FiniteLinesT2< T > & cameraBoundarySegments() const
Returns the 2D line segments defined in the camera's normalized image plane defining the camera's bou...
Definition AnyCamera.h:1854
FiniteLinesT2< T > cameraBoundarySegments_
The 2D line segments defined in the camera's normalized image plane defining the camera's boundary,...
Definition AnyCamera.h:624
const SharedAnyCameraT< T > & camera() const
Returns the camera model of this clipper.
Definition AnyCamera.h:1766
unsigned int width() const
Returns the width of the camera profile.
Definition AnyCamera.h:1772
SharedAnyCameraT< T > camera_
The actual camera model this clipper is based on.
Definition AnyCamera.h:621
void update(const SharedAnyCameraT< T > &camera, const size_t segmentSteps=10)
Updates the clipper with a new camera model.
Definition AnyCamera.h:1794
static bool determineCameraBoundary(const AnyCameraT< T > &camera, FiniteLinesT2< T > &cameraBoundarySegments, const size_t segmentSteps)
Determines the camera boundary of a given camera model in normalized image coordinates.
Definition AnyCamera.h:1868
static bool isValidForPoint(const AnyCameraT< T > &camera, const VectorT2< T > &imagePoint, const T maximalReprojectionError=T(1), const unsigned int additionalChecksTowardsPrincipalPoint=3u)
Returns whether a given camera model is valid for a specified 2D image point in the camera image.
Definition AnyCamera.h:2046
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:131
virtual ~AnyCameraT()=default
Destructs the AnyCamera object.
virtual VectorT3< T > vector(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector=true) const =0
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
AnyCameraT(AnyCameraT< T > &&)=delete
Disabled move constructor.
virtual LineT3< T > ray(const VectorT2< T > &distortedImagePoint) const =0
Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
virtual unsigned int width() const =0
Returns the width of the camera image.
virtual T focalLengthX() const =0
Returns the horizontal focal length parameter.
virtual VectorT2< T > projectToImage(const HomogenousMatrixT4< T > &world_T_camera, const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual void vectorIF(const VectorT2< T > *distortedImagePoints, const size_t size, VectorT3< T > *vectors, const bool makeUnitVector=true) const =0
Returns vectors starting at the camera's center and intersecting a given 2D points in the image.
virtual void projectToImage(const VectorT3< T > *objectPoints, const size_t size, VectorT2< T > *imagePoints) const =0
Projects several 3D object points into the camera frame at once.
virtual VectorT2< T > principalPoint() const =0
Returns the coordinate of the principal point of the camera image in the pixel domain.
virtual std::unique_ptr< AnyCameraT< double > > cloneToDouble(const unsigned int width=0u, const unsigned int height=0u) const =0
Returns a copy of this camera object with double precision.
virtual T inverseFocalLengthY() const =0
Returns the inverse vertical focal length parameter.
AnyCameraT & operator=(AnyCameraT &&)=delete
Disabled move operator.
virtual void projectToImageIF(const VectorT3< T > *objectPoints, const size_t size, VectorT2< T > *imagePoints) const =0
Projects several 3D object points into the camera frame at once.
virtual std::unique_ptr< AnyCameraT< T > > clone(const unsigned int width=0u, const unsigned int height=0u) const =0
Returns a copy of this camera object.
virtual T fovX() const =0
Returns the field of view in x direction of the camera.
virtual VectorT2< T > projectToImage(const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual T inverseFocalLengthX() const =0
Returns the inverse horizontal focal length parameter.
virtual T focalLengthY() const =0
Returns the vertical focal length parameter.
virtual void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const =0
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
AnyCameraT & operator=(const AnyCameraT &)=delete
Disabled assign operator.
T TScalar
The scalar data type of this object.
Definition AnyCamera.h:135
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 T fovY() const =0
Returns the field of view in x direction of the camera.
virtual T principalPointY() const =0
Returns the y-value of the principal point of the camera image in the pixel domain.
virtual void projectToImage(const HomogenousMatrixT4< T > &world_T_camera, const VectorT3< T > *objectPoints, const size_t size, VectorT2< T > *imagePoints) const =0
Projects several 3D object points into the camera frame at once.
virtual bool isEqual(const AnyCameraT< T > &anyCamera, const T eps=NumericT< T >::eps()) const =0
Returns whether two camera objects are identical up to a given epsilon.
virtual VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector=true) const =0
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
virtual bool isValid() const =0
Returns whether this camera is valid.
virtual LineT3< T > ray(const VectorT2< T > &distortedImagePoint, const HomogenousMatrixT4< T > &world_T_camera) const =0
Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
virtual VectorT2< T > projectToImageIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > &objectPoint) const =0
Projects a 3D object point into the camera frame.
virtual AnyCameraType anyCameraType() const =0
Returns the type of this camera.
AnyCameraT()=default
Protected default constructor.
virtual void vector(const VectorT2< T > *distortedImagePoints, const size_t size, VectorT3< T > *vectors, const bool makeUnitVector=true) const =0
Determines vectors starting at the camera's center and intersecting given 2D points in the image.
virtual void pointJacobian2nx3IF(const VectorT3< T > *flippedCameraObjectPoints, const size_t numberObjectPoints, T *jacobians) const =0
Calculates the 2n x 3 jacobian matrix for the 3D object point projection into the camera frame.
virtual std::string name() const =0
Returns the name of this camera.
AnyCameraT(const AnyCameraT< T > &anyCamera)=default
Protected copy constructor.
static std::shared_ptr< AnyCameraT< T > > convert(const std::shared_ptr< AnyCameraT< U > > &anyCamera)
Converts an AnyCamera object with arbitrary scalar type to another AnyCamera object with arbitrary sc...
Definition AnyCamera.h:2114
virtual std::unique_ptr< AnyCameraT< float > > cloneToFloat(const unsigned int width=0u, const unsigned int height=0u) const =0
Returns a copy of this camera object with float precision.
virtual void projectToImageIF(const HomogenousMatrixT4< T > &flippedCamera_T_world, const VectorT3< T > *objectPoints, const size_t size, VectorT2< T > *imagePoints) const =0
Projects several 3D object points into the camera frame at once.
virtual bool isInside(const VectorT2< T > &imagePoint, const T signedBorder=T(0)) const =0
Returns whether a given 2D image point lies inside the camera frame.
virtual T principalPointX() const =0
Returns the x-value of the principal point of the camera image in the pixel domain.
This class implements a specialized AnyCamera object wrapping the actual camera model.
Definition AnyCamera.h:638
VectorT2< T > principalPoint() const override
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2178
void pointJacobian2nx3IF(const VectorT3< T > *flippedCameraObjectPoints, const size_t numberObjectPoints, T *jacobians) const override
Calculates the 2n x 3 jacobian matrix for the 3D object point projection into the camera frame.
Definition AnyCamera.h:2328
VectorT2< T > projectToImage(const VectorT3< T > &objectPoint) const override
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2238
bool isEqual(const AnyCameraT< T > &anyCamera, const T eps=NumericT< T >::eps()) const override
Returns whether two camera objects are identical up to a given epsilon.
Definition AnyCamera.h:2334
unsigned int width() const override
Returns the width of the camera image.
Definition AnyCamera.h:2166
unsigned int height() const override
Returns the height of the camera image.
Definition AnyCamera.h:2172
std::unique_ptr< AnyCameraT< float > > cloneToFloat(const unsigned int width=0u, const unsigned int height=0u) const override
Returns a copy of this camera object with float precision.
Definition AnyCamera.h:2154
std::unique_ptr< AnyCameraT< T > > clone(const unsigned int width=0u, const unsigned int height=0u) const override
Returns a copy of this camera object.
Definition AnyCamera.h:2148
T focalLengthY() const override
Returns the vertical focal length parameter.
Definition AnyCamera.h:2202
bool isValid() const override
Returns whether this camera is valid.
Definition AnyCamera.h:2359
AnyCameraType anyCameraType() const override
Returns the type of this camera.
Definition AnyCamera.h:2136
T inverseFocalLengthX() const override
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:2208
T principalPointY() const override
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2190
AnyCameraWrappingT(ActualCamera &&actualCamera)
Creates a new AnyCamera object wrapping the actual camera model.
Definition AnyCamera.h:2122
VectorT3< T > vector(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector=true) const override
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition AnyCamera.h:2286
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const override
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2250
T TScalar
The scalar data type of this object.
Definition AnyCamera.h:642
T focalLengthX() const override
Returns the horizontal focal length parameter.
Definition AnyCamera.h:2196
T fovX() const override
Returns the field of view in x direction of the camera.
Definition AnyCamera.h:2220
bool isInside(const VectorT2< T > &imagePoint, const T signedBorder=T(0)) const override
Returns whether a given 2D image point lies inside the camera frame.
Definition AnyCamera.h:2232
std::string name() const override
Returns the name of this camera.
Definition AnyCamera.h:2142
LineT3< T > ray(const VectorT2< T > &distortedImagePoint, const HomogenousMatrixT4< T > &world_T_camera) const override
Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
Definition AnyCamera.h:2310
VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector=true) const override
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition AnyCamera.h:2298
typename TCameraWrapper::ActualCamera ActualCamera
The actual camera object wrapped by this class.
Definition AnyCamera.h:648
T principalPointX() const override
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2184
std::unique_ptr< AnyCameraT< double > > cloneToDouble(const unsigned int width=0u, const unsigned int height=0u) const override
Returns a copy of this camera object with double precision.
Definition AnyCamera.h:2160
void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const override
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition AnyCamera.h:2322
T fovY() const override
Returns the field of view in x direction of the camera.
Definition AnyCamera.h:2226
T inverseFocalLengthY() const override
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:2214
This class implements the base class for all cameras.
Definition Camera.h:99
This class implements the base wrapper around Ocean's fisheye camera profile.
Definition AnyCamera.h:1247
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2782
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:2806
ActualCamera actualCamera_
The actual fisheye camera object.
Definition AnyCamera.h:1410
unsigned int height() const
Returns the height of the camera image.
Definition AnyCamera.h:2770
void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition AnyCamera.h:2872
unsigned int width() const
Returns the width of the camera image.
Definition AnyCamera.h:2764
bool isValid() const
Returns whether this camera is valid.
Definition AnyCamera.h:2886
FisheyeCameraT< T > ActualCamera
Definition of the actual camera object wrapped by this class.
Definition AnyCamera.h:1253
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:2812
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition AnyCamera.h:2936
VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector) const
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition AnyCamera.h:2854
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition AnyCamera.h:2758
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2776
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2788
static std::string name()
Returns the name of this camera.
Definition AnyCamera.h:2942
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition AnyCamera.h:2794
T focalLengthY() const
Returns the vertical focal length parameter.
Definition AnyCamera.h:2800
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2818
CameraWrapperBaseFisheyeT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBaseFisheyeT object wrapping the actual camera model.
Definition AnyCamera.h:2744
std::unique_ptr< AnyCameraT< U > > clone(const unsigned int width=0u, const unsigned int height=0u) const
Returns a copy of the actual camera object.
Definition AnyCamera.h:2893
bool isEqual(const CameraWrapperBaseFisheyeT< T > &baseFisheye, const T eps=NumericT< T >::eps()) const
Returns whether two camera objects are identical up to a given epsilon.
Definition AnyCamera.h:2878
This class implements the base wrapper around an invalid camera profile.
Definition AnyCamera.h:1470
bool isEqual(const CameraWrapperBaseInvalidT< T > &baseInvalid, const T eps=NumericT< T >::eps()) const
Returns whether two camera objects are identical up to a given epsilon.
Definition AnyCamera.h:3125
InvalidCameraT< T > ActualCamera
Definition of the actual camera object wrapped by this class.
Definition AnyCamera.h:1476
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:3062
CameraWrapperBaseInvalidT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBaseInvalidT object wrapping the actual camera model.
Definition AnyCamera.h:2948
unsigned int height() const
Returns the height of the camera image.
Definition AnyCamera.h:2982
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition AnyCamera.h:2962
static std::string name()
Returns the name of this camera.
Definition AnyCamera.h:3158
ActualCamera actualCamera_
The actual invalid camera.
Definition AnyCamera.h:1633
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:3002
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2992
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:3042
bool isValid() const
Returns whether this camera is valid.
Definition AnyCamera.h:3135
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition AnyCamera.h:3152
std::unique_ptr< AnyCameraT< U > > clone(const unsigned int width=0u, const unsigned int height=0u) const
Returns a copy of the actual camera object.
Definition AnyCamera.h:3142
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:3052
void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition AnyCamera.h:3117
VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector) const
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition AnyCamera.h:3099
T focalLengthY() const
Returns the vertical focal length parameter.
Definition AnyCamera.h:3032
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:3012
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition AnyCamera.h:3022
unsigned int width() const
Returns the width of the camera image.
Definition AnyCamera.h:2972
This class implements the base wrapper around Ocean's pinhole camera profile.
Definition AnyCamera.h:1078
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:2597
void pointJacobian2x3IF(const VectorT3< T > &flippedCameraObjectPoint, T *jx, T *jy) const
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition AnyCamera.h:2665
PinholeCameraT< T > ActualCamera
Definition of the actual camera object wrapped by this class.
Definition AnyCamera.h:1084
unsigned int height() const
Returns the height of the camera image.
Definition AnyCamera.h:2567
bool isValid() const
Returns whether this camera is valid.
Definition AnyCamera.h:2680
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2579
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:2603
static std::string name()
Returns the name of this camera.
Definition AnyCamera.h:2738
ActualCamera actualCamera_
The actual pinhole camera.
Definition AnyCamera.h:1236
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition AnyCamera.h:2555
unsigned int width() const
Returns the width of the camera image.
Definition AnyCamera.h:2561
CameraWrapperBasePinholeT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBasePinholeT object wrapping the actual camera model.
Definition AnyCamera.h:2541
VectorT3< T > vectorIF(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector) const
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition AnyCamera.h:2645
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2609
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition AnyCamera.h:2732
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2573
bool isEqual(const CameraWrapperBasePinholeT< T > &basePinhole, const T eps=NumericT< T >::eps()) const
Returns whether two camera objects are identical up to a given epsilon.
Definition AnyCamera.h:2672
std::unique_ptr< AnyCameraT< U > > clone(const unsigned int width=0u, const unsigned int height=0u) const
Returns a copy of the actual camera object.
Definition AnyCamera.h:2687
T focalLengthY() const
Returns the vertical focal length parameter.
Definition AnyCamera.h:2591
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition AnyCamera.h:2585
This class implements a wrapper for an actual camera object.
Definition AnyCamera.h:969
LineT3< T > ray(const VectorT2< T > &distortedImagePoint, const HomogenousMatrixT4< T > &world_T_camera) const
Returns a ray starting at the camera's center and intersecting a given 2D point in the image.
Definition AnyCamera.h:2511
T fovY() const
Returns the field of view in x direction of the camera.
Definition AnyCamera.h:2415
T fovX() const
Returns the field of view in x direction of the camera.
Definition AnyCamera.h:2385
CameraWrapperT(ActualCamera &&actualCamera)
Creates a new CameraWrapperT object wrapping the actual camera model.
Definition AnyCamera.h:2365
VectorT3< T > vector(const VectorT2< T > &distortedImagePoint, const bool makeUnitVector) const
Returns a vector starting at the camera's center and intersecting a given 2D point in the image.
Definition AnyCamera.h:2490
void pointJacobian2nx3IF(const VectorT3< T > *flippedCameraObjectPoints, const size_t numberObjectPoints, T *jacobians) const
Calculates the 2x3 jacobian matrix for the 3D object point projection into the camera frame.
Definition AnyCamera.h:2527
bool isInside(const VectorT2< T > &imagePoint, const T signedBorder=T(0)) const
Returns whether a given 2D image point lies inside the camera frame.
Definition AnyCamera.h:2445
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2379
VectorT2< T > projectToImage(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2459
This class implements an finite line in 2D space.
Definition FiniteLine2.h:82
Class representing a fisheye camera.
Definition FisheyeCamera.h:106
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition HomogenousMatrix4.h:110
SquareMatrixT3< T > rotationMatrix() const
Returns the rotation matrix of the transformation.
Definition HomogenousMatrix4.h:1487
VectorT3< T > translation() const
Returns the translation of the transformation.
Definition HomogenousMatrix4.h:1375
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1800
This class implements invalid camera profiles, e.g.
Definition AnyCamera.h:1420
const std::string & reason() const
Returns the reason of this invalid camera.
Definition AnyCamera.h:3171
std::string reason_
The reason why no valid camera is available.
Definition AnyCamera.h:1438
InvalidCameraT(const std::string &reason)
Creates an invalid camera.
Definition AnyCamera.h:3164
This class implements an infinite line in 3D space.
Definition Line3.h:69
static MessageObject error()
Returns the message for error messages.
Definition Messenger.h:1095
This class provides basic numeric functionalities.
Definition Numeric.h:57
static constexpr T minValue()
Returns the min scalar value.
Definition Numeric.h:3259
static T atan(const T value)
Returns the arctangent of a given value.
Definition Numeric.h:1620
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition Numeric.h:2395
static constexpr T sqr(const T value)
Returns the square of a given value.
Definition Numeric.h:1499
Definition of a pinhole camera model.
Definition PinholeCamera.h:114
This class implements a vector with two elements.
Definition Vector2.h:96
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
bool isNull() const
Returns whether this vector is a null vector up to a small epsilon.
Definition Vector2.h:739
T sqrDistance(const VectorT2< T > &right) const
Returns the square distance between this 2D position and a second 2D position.
Definition Vector2.h:638
This class implements a vector with three elements.
Definition Vector3.h:97
const T & y() const noexcept
Returns the y value.
Definition Vector3.h:816
const T & x() const noexcept
Returns the x value.
Definition Vector3.h:804
VectorT2< T > xy() const noexcept
Returns the x and y component of the vector as new 2D vector.
Definition Vector3.h:840
static VectorT3< T > minValue()
Returns a 3D vector with all elements set to NumericT::minValue().
Definition Vector3.h:1036
const T & z() const noexcept
Returns the z value.
Definition Vector3.h:828
std::shared_ptr< AnyCameraD > SharedAnyCameraD
Definition of a shared pointer holding an AnyCamera object with double precision.
Definition AnyCamera.h:68
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:61
std::vector< FiniteLineT2< T > > FiniteLinesT2
Definition of a typename alias for vectors with FiniteLineT2 objects.
Definition FiniteLine2.h:50
std::vector< VectorT2< T > > VectorsT2
Definition of a typename alias for vectors with VectorT2 objects.
Definition Vector2.h:57
SharedAnyCamerasT< float > SharedAnyCamerasF
Definition of a vector holding AnyCameraF objects.
Definition AnyCamera.h:105
SharedAnyCamerasT< double > SharedAnyCamerasD
Definition of a vector holding AnyCameraD objects.
Definition AnyCamera.h:98
AnyCameraType
Definition of individual camera types.
Definition AnyCamera.h:112
std::shared_ptr< AnyCameraF > SharedAnyCameraF
Definition of a shared pointer holding an AnyCamera object with float precision.
Definition AnyCamera.h:75
std::vector< std::shared_ptr< AnyCameraT< T > > > SharedAnyCamerasT
Definition of a typename alias for vectors with shared AnyCameraT objects.
Definition AnyCamera.h:84
SharedAnyCamerasT< Scalar > SharedAnyCameras
Definition of a vector holding AnyCamera objects.
Definition AnyCamera.h:91
std::shared_ptr< AnyCameraT< T > > SharedAnyCameraT
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:54
@ FISHEYE
A fisheye camera.
@ PINHOLE
A pinhole camera.
@ INVALID
An invalid camera type.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15