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;
626template <
typename T,
typename TCameraWrapper>
666 std::string
name()
const override;
675 std::unique_ptr<AnyCameraT<T>>
clone(
const unsigned int width = 0
u,
const unsigned int height = 0
u)
const override;
684 std::unique_ptr<AnyCameraT<float>>
cloneToFloat(
const unsigned int width = 0
u,
const unsigned int height = 0
u)
const override;
693 std::unique_ptr<AnyCameraT<double>>
cloneToDouble(
const unsigned int width = 0
u,
const unsigned int height = 0
u)
const override;
699 unsigned int width()
const override;
705 unsigned int height()
const override;
754 T
fovX()
const override;
761 T
fovY()
const override;
959template <
typename T,
typename TCameraWrapperBase>
967 using typename TCameraWrapperBase::ActualCamera;
993 inline T
fovX()
const;
999 inline T
fovY()
const;
1068template <
typename T>
1107 inline unsigned int width()
const;
1113 inline unsigned int height()
const;
1210 template <
typename U>
1211 inline std::unique_ptr<AnyCameraT<U>>
clone(
const unsigned int width = 0u,
const unsigned int height = 0u)
const;
1223 static inline std::string
name();
1237template <
typename T>
1276 inline unsigned int width()
const;
1282 inline unsigned int height()
const;
1384 template <
typename U>
1385 inline std::unique_ptr<AnyCameraT<U>>
clone(
const unsigned int width = 0u,
const unsigned int height = 0u)
const;
1397 static inline std::string
name();
1410template <
typename T>
1425 const std::string&
reason()
const;
1460template <
typename T>
1499 inline unsigned int width()
const;
1505 inline unsigned int height()
const;
1607 template <
typename U>
1608 inline std::unique_ptr<AnyCameraT<U>>
clone(
const unsigned int width = 0u,
const unsigned int height = 0u)
const;
1620 static inline std::string
name();
1634template <
typename T>
1664template <
typename T>
1694template <
typename T>
1718template <
typename T>
1721 update(camera, segmentSteps);
1724template <
typename T>
1727 ocean_assert(camera_ !=
nullptr);
1728 ocean_assert(camera_->isValid());
1729 ocean_assert(flippedCamera_T_world.
isValid());
1731 const VectorT3<T> cameraObjectPointIF = flippedCamera_T_world * objectPoint;
1738 const T invZ = T(1) / cameraObjectPointIF.
z();
1740 const VectorT2<T> normalizedImagePoint(cameraObjectPointIF.
x() * invZ, cameraObjectPointIF.
y() * invZ);
1742 if (!isInside(cameraBoundarySegments_, normalizedImagePoint))
1747 if (imagePoint !=
nullptr)
1749 *imagePoint = camera_->projectToImageIF(cameraObjectPointIF);
1751 ocean_assert_accuracy(camera_->isInside(*imagePoint, T(std::max(camera_->width(), camera_->height())) * T(-0.1)));
1757template <
typename T>
1763template <
typename T>
1768 return camera_->width();
1774template <
typename T>
1779 return camera_->height();
1785template <
typename T>
1788 ocean_assert(camera !=
nullptr && camera->isValid() && segmentSteps >= 1);
1789 if (camera ==
nullptr || !camera->isValid() || segmentSteps == 0)
1794 if (camera_ && camera_->isEqual(*camera))
1796 ocean_assert(isValid());
1800 cameraBoundarySegments_.clear();
1802 if (determineCameraBoundary(*camera, cameraBoundarySegments_, segmentSteps))
1809 cameraBoundarySegments_.clear();
1812 ocean_assert(isValid());
1815template <
typename T>
1818 return cameraBoundarySegments_;
1821template <
typename T>
1824 ocean_assert(camera_ ==
nullptr || !cameraBoundarySegments_.empty());
1826 return camera_ !=
nullptr;
1829template <
typename T>
1832 ocean_assert(camera.
isValid());
1838 ocean_assert(segmentSteps >= 1);
1839 if (segmentSteps < 1)
1844 constexpr unsigned int border = 0u;
1846 const std::array<VectorT2<T>, 4> corners =
1862 const T sqrProjectionErrorPrincipalPoint = camera.
projectToImageIF(principalObjectPoint).sqrDistance(principalPoint);
1864 if (sqrProjectionErrorPrincipalPoint > maximalSqrDistance)
1866 ocean_assert(
false &&
"The camera model is not precise enough");
1871 normalizedImagePoints.reserve(corners.size() * segmentSteps);
1873 for (
size_t nCorner = 0; nCorner < corners.size(); ++nCorner)
1876 const VectorT2<T>& corner1 = corners[(nCorner + 1u) % corners.size()];
1878 for (
size_t nStep = 0; nStep < segmentSteps; ++nStep)
1880 const T factor = T(nStep) / T(segmentSteps);
1882 const VectorT2<T> distortedImagePoint = corner0 * (T(1) - factor) + corner1 * factor;
1884 const VectorT2<T> offsetTowardsPrincipalPoint = (principalPoint - distortedImagePoint).normalizedOrZero() * T(1.0);
1888 if (isValidForPoint(camera, distortedImagePoint, maximalSqrDistance, 3u))
1890 objectPoint = camera.
vectorIF(distortedImagePoint,
false );
1899 VectorT2<T> boundaryImagePoint = distortedImagePoint;
1902 objectPoint = principalObjectPoint;
1904 constexpr unsigned int iterations = 20u;
1906 for (
unsigned int nIteration = 0u; nIteration < iterations; ++nIteration)
1908 if (boundaryImagePoint.
sqrDistance(centerImagePoint) <= maximalSqrDistance)
1913 const VectorT2<T> middleImagePoint = (boundaryImagePoint + centerImagePoint) * T(0.5);
1918 const T sqrMiddleDistance = middleImagePoint.
sqrDistance(projectedMiddleObjectPoint);
1920 if (sqrMiddleDistance <= maximalSqrDistance)
1922 centerImagePoint = middleImagePoint;
1924 objectPoint = camera.
vectorIF(middleImagePoint + offsetTowardsPrincipalPoint,
false );
1928 boundaryImagePoint = middleImagePoint;
1936 const VectorT2<T> normalizedImagePoint = objectPoint.
xy() / objectPoint.
z();
1938 normalizedImagePoints.emplace_back(normalizedImagePoint.
x(), normalizedImagePoint.
y());
1943 ocean_assert(normalizedImagePoints.size() >= 3);
1945 ocean_assert(cameraBoundarySegments.empty());
1946 cameraBoundarySegments.clear();
1948 cameraBoundarySegments.reserve(normalizedImagePoints.size());
1950 for (
size_t n = 1; n < normalizedImagePoints.size(); ++n)
1952 cameraBoundarySegments.emplace_back(normalizedImagePoints[n - 1], normalizedImagePoints[n]);
1955 cameraBoundarySegments.emplace_back(normalizedImagePoints.back(), normalizedImagePoints.front());
1960template <
typename T>
1963 ocean_assert(cameraBoundarySegments.size() >= 3);
1967 for (
const FiniteLineT2<T>& cameraBoundarySegment : cameraBoundarySegments)
1971 const bool segmentTopDown = cameraBoundarySegment.point0().y() < cameraBoundarySegment.point1().y();
1975 if (cameraBoundarySegment.point1().y() < normalizedImagePoint.
y() || normalizedImagePoint.
y() < cameraBoundarySegment.point0().y())
1982 if (cameraBoundarySegment.point0().y() < normalizedImagePoint.
y() || normalizedImagePoint.
y() < cameraBoundarySegment.point1().y())
1988 if (cameraBoundarySegment.isOnLine(normalizedImagePoint))
1995 if (cameraBoundarySegment.isLeftOfLine(normalizedImagePoint) == segmentTopDown)
2004 return counter % 2 == 1;
2007template <
typename T>
2010 ocean_assert(camera.
isValid());
2011 ocean_assert(camera.
isInside(imagePoint, T(-1)));
2012 ocean_assert(maximalReprojectionError >= T(0));
2013 ocean_assert(additionalChecksTowardsPrincipalPoint >= 1u);
2026 const VectorT2<T> direction = (principalPoint - imagePoint).normalizedOrZero();
2034 for (
unsigned int n = 0u; n < std::min(additionalChecksTowardsPrincipalPoint, 10u); ++n)
2036 const VectorT2<T> additionalImagePoint = imagePoint + direction * T(n + 1u);
2056 return anyCamera->cloneToFloat();
2068 return anyCamera->cloneToDouble();
2074template <
typename T>
2075template <
typename U>
2078 static_assert(std::is_same<T, U>::value,
"Invalid data types!");
2083template <
typename T,
typename TCameraWrapper>
2090template <
typename T,
typename TCameraWrapper>
2097template <
typename T,
typename TCameraWrapper>
2100 return TCameraWrapper::anyCameraType();
2103template <
typename T,
typename TCameraWrapper>
2106 return TCameraWrapper::name();
2109template <
typename T,
typename TCameraWrapper>
2112 return TCameraWrapper::template clone<T>(width, height);
2115template <
typename T,
typename TCameraWrapper>
2118 return TCameraWrapper::template clone<float>(width, height);
2121template <
typename T,
typename TCameraWrapper>
2124 return TCameraWrapper::template clone<double>(width, height);
2127template <
typename T,
typename TCameraWrapper>
2130 return TCameraWrapper::width();
2133template <
typename T,
typename TCameraWrapper>
2136 return TCameraWrapper::height();
2139template <
typename T,
typename TCameraWrapper>
2142 return TCameraWrapper::principalPoint();
2145template <
typename T,
typename TCameraWrapper>
2148 return TCameraWrapper::principalPointX();
2151template <
typename T,
typename TCameraWrapper>
2154 return TCameraWrapper::principalPointY();
2157template <
typename T,
typename TCameraWrapper>
2160 return TCameraWrapper::focalLengthX();
2163template <
typename T,
typename TCameraWrapper>
2166 return TCameraWrapper::focalLengthY();
2169template <
typename T,
typename TCameraWrapper>
2172 return TCameraWrapper::inverseFocalLengthX();
2175template <
typename T,
typename TCameraWrapper>
2178 return TCameraWrapper::inverseFocalLengthY();
2181template <
typename T,
typename TCameraWrapper>
2184 return TCameraWrapper::fovX();
2187template <
typename T,
typename TCameraWrapper>
2190 return TCameraWrapper::fovY();
2193template <
typename T,
typename TCameraWrapper>
2196 return TCameraWrapper::isInside(imagePoint, signedBorder);
2199template <
typename T,
typename TCameraWrapper>
2202 return TCameraWrapper::projectToImage(objectPoint);
2205template <
typename T,
typename TCameraWrapper>
2208 return TCameraWrapper::projectToImage(world_T_camera, objectPoint);
2211template <
typename T,
typename TCameraWrapper>
2214 return TCameraWrapper::projectToImageIF(objectPoint);
2217template <
typename T,
typename TCameraWrapper>
2220 return TCameraWrapper::projectToImageIF(flippedCamera_T_world, objectPoint);
2223template <
typename T,
typename TCameraWrapper>
2226 return TCameraWrapper::projectToImage(objectPoints, size, imagePoints);
2229template <
typename T,
typename TCameraWrapper>
2232 return TCameraWrapper::projectToImage(world_T_camera, objectPoints, size, imagePoints);
2235template <
typename T,
typename TCameraWrapper>
2238 return TCameraWrapper::projectToImageIF(objectPoints, size, imagePoints);
2241template <
typename T,
typename TCameraWrapper>
2244 return TCameraWrapper::projectToImageIF(flippedCamera_T_world, objectPoints, size, imagePoints);
2247template <
typename T,
typename TCameraWrapper>
2250 return TCameraWrapper::vector(distortedImagePoint, makeUnitVector);
2253template <
typename T,
typename TCameraWrapper>
2256 return TCameraWrapper::vector(distortedImagePoints, size, vectors, makeUnitVector);
2259template <
typename T,
typename TCameraWrapper>
2262 return TCameraWrapper::vectorIF(distortedImagePoint, makeUnitVector);
2265template <
typename T,
typename TCameraWrapper>
2268 return TCameraWrapper::vectorIF(distortedImagePoints, size, vectors, makeUnitVector);
2271template <
typename T,
typename TCameraWrapper>
2274 return TCameraWrapper::ray(distortedImagePoint, world_T_camera);
2277template <
typename T,
typename TCameraWrapper>
2280 return TCameraWrapper::ray(distortedImagePoint);
2283template <
typename T,
typename TCameraWrapper>
2286 return TCameraWrapper::pointJacobian2x3IF(flippedCameraObjectPoint, jx, jy);
2289template <
typename T,
typename TCameraWrapper>
2292 return TCameraWrapper::pointJacobian2nx3IF(flippedCameraObjectPoints, numberObjectPoints, jacobians);
2295template <
typename T,
typename TCameraWrapper>
2298 ocean_assert(eps >= T(0));
2300 if (isValid() != anyCamera.
isValid())
2312 if (name() != anyCamera.
name())
2320template <
typename T,
typename TCameraWrapper>
2323 return TCameraWrapper::isValid();
2326template <
typename T,
typename TCameraWrapperBase>
2333template <
typename T,
typename TCameraWrapperBase>
2340template <
typename T,
typename TCameraWrapperBase>
2343 return VectorT2<T>(TCameraWrapperBase::principalPointX(), TCameraWrapperBase::principalPointY());
2346template <
typename T,
typename TCameraWrapperBase>
2349 ocean_assert(TCameraWrapperBase::isValid());
2364 if (T(TCameraWrapperBase::width()) <= TCameraWrapperBase::principalPointX())
2366 ocean_assert(
false &&
"Invalid principal point");
2367 return T(2) * leftAngle;
2370 const T rightAngle =
NumericT<T>::atan((T(TCameraWrapperBase::width()) - TCameraWrapperBase::principalPointX()) * TCameraWrapperBase::inverseFocalLengthX());
2372 return leftAngle + rightAngle;
2375template <
typename T,
typename TCameraWrapperBase>
2378 ocean_assert(TCameraWrapperBase::isValid());
2393 if (T(TCameraWrapperBase::height()) <= TCameraWrapperBase::principalPointY())
2395 ocean_assert(
false &&
"Invalid principal point");
2396 return T(2) * topAngle;
2399 const T bottomAngle =
NumericT<T>::atan((T(TCameraWrapperBase::height()) - TCameraWrapperBase::principalPointY()) * TCameraWrapperBase::inverseFocalLengthY());
2401 return topAngle + bottomAngle;
2404template <
typename T,
typename TCameraWrapperBase>
2407 ocean_assert(TCameraWrapperBase::isValid());
2409 const unsigned int cameraWidth = TCameraWrapperBase::width();
2410 const unsigned int cameraHeight = TCameraWrapperBase::height();
2412 ocean_assert(signedBorder < T(std::min(cameraWidth / 2u, cameraHeight / 2u)));
2414 return imagePoint.
x() >= signedBorder && imagePoint.
y() >= signedBorder
2415 && imagePoint.
x() < T(cameraWidth) - signedBorder && imagePoint.
y() < T(cameraHeight) - signedBorder;
2418template <
typename T,
typename TCameraWrapperBase>
2421 return TCameraWrapperBase::projectToImageIF(
VectorT3<T>(objectPoint.
x(), -objectPoint.
y(), -objectPoint.
z()));
2424template <
typename T,
typename TCameraWrapperBase>
2430template <
typename T,
typename TCameraWrapperBase>
2433 ocean_assert(size == 0 || objectPoints !=
nullptr);
2434 ocean_assert(size == 0 || imagePoints !=
nullptr);
2436 for (
size_t n = 0; n < size; ++n)
2439 imagePoints[n] = TCameraWrapperBase::projectToImageIF(
VectorT3<T>(objectPoint.
x(), -objectPoint.
y(), -objectPoint.
z()));
2443template <
typename T,
typename TCameraWrapperBase>
2449template <
typename T,
typename TCameraWrapperBase>
2452 const VectorT3<T> localVectorIF(TCameraWrapperBase::vectorIF(distortedImagePoint, makeUnitVector));
2454 return VectorT3<T>(localVectorIF.
x(), -localVectorIF.
y(), -localVectorIF.
z());
2457template <
typename T,
typename TCameraWrapperBase>
2460 TCameraWrapperBase::vectorIF(distortedImagePoints, size, vectors, makeUnitVector);
2462 for (
size_t n = 0; n < size; ++n)
2466 vectors[n] =
VectorT3<T>(localVectorIF.
x(), -localVectorIF.
y(), -localVectorIF.
z());
2470template <
typename T,
typename TCameraWrapperBase>
2473 ocean_assert(TCameraWrapperBase::isValid() && world_T_camera.
isValid());
2478template <
typename T,
typename TCameraWrapperBase>
2481 ocean_assert(TCameraWrapperBase::isValid());
2486template <
typename T,
typename TCameraWrapperBase>
2489 ocean_assert(flippedCameraObjectPoints !=
nullptr);
2490 ocean_assert(numberObjectPoints >= 1);
2491 ocean_assert(jacobians !=
nullptr);
2493 for (
size_t n = 0; n < numberObjectPoints; ++n)
2495 TCameraWrapperBase::pointJacobian2x3IF(flippedCameraObjectPoints[n], jacobians + 0, jacobians + 3);
2500template <
typename T>
2502 actualCamera_(std::move(actualCamera))
2507template <
typename T>
2509 actualCamera_(actualCamera)
2514template <
typename T>
2517 return actualCamera_;
2520template <
typename T>
2523 return actualCamera_.width();
2526template <
typename T>
2529 return actualCamera_.height();
2532template <
typename T>
2535 return T(actualCamera_.principalPointX());
2538template <
typename T>
2541 return T(actualCamera_.principalPointY());
2544template <
typename T>
2547 return T(actualCamera_.focalLengthX());
2550template <
typename T>
2553 return T(actualCamera_.focalLengthY());
2556template <
typename T>
2559 return T(actualCamera_.inverseFocalLengthX());
2562template <
typename T>
2565 return T(actualCamera_.inverseFocalLengthY());
2568template <
typename T>
2574template <
typename T>
2577 return VectorT2<T>(actualCamera_.template projectToImageIF<true>(flippedCamera_T_world, objectPoint,
true));
2580template <
typename T>
2583 ocean_assert(size == 0 || objectPoints !=
nullptr);
2584 ocean_assert(size == 0 || imagePoints !=
nullptr);
2586 for (
size_t n = 0; n < size; ++n)
2588 imagePoints[n] = projectToImageIF(objectPoints[n]);
2592template <
typename T>
2595 ocean_assert(size == 0 || objectPoints !=
nullptr);
2596 ocean_assert(size == 0 || imagePoints !=
nullptr);
2598 for (
size_t n = 0; n < size; ++n)
2600 imagePoints[n] = projectToImageIF(flippedCamera_T_world, objectPoints[n]);
2604template <
typename T>
2607 const VectorT2<T> undistortedImagePoint(actualCamera_.template undistort<true>(distortedImagePoint));
2609 return VectorT3<T>(actualCamera_.vectorIF(undistortedImagePoint, makeUnitVector));
2612template <
typename T>
2615 ocean_assert(distortedImagePoints !=
nullptr && size > 0);
2616 ocean_assert(vectors !=
nullptr);
2618 for (
size_t n = 0; n < size; ++n)
2620 vectors[n] = vectorIF(distortedImagePoints[n], makeUnitVector);
2624template <
typename T>
2627 ocean_assert(jx !=
nullptr && jy !=
nullptr);
2628 actualCamera_.template pointJacobian2x3IF<T, true>(flippedCameraObjectPoint, jx, jy);
2631template <
typename T>
2634 ocean_assert(eps >= T(0));
2636 return actualCamera_.isEqual(basePinhole.
actualCamera_, eps);
2639template <
typename T>
2642 return actualCamera_.isValid();
2645template <
typename T>
2646template <
typename U>
2649 ocean_assert(actualCamera_.isValid());
2651 if constexpr (std::is_same<T, U>::value)
2653 if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2655 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(actualCamera_);
2658 const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2659 const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2663 ocean_assert(
false &&
"Wrong aspect ratio!");
2667 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(
PinholeCameraT<U>(width, height, actualCamera_));
2673 if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2675 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(convertedPinholeCamera);
2678 const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2679 const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2683 ocean_assert(
false &&
"Wrong aspect ratio!");
2687 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(
PinholeCameraT<U>(width, height, convertedPinholeCamera));
2691template <
typename T>
2697template <
typename T>
2700 return std::string(
"Ocean Pinhole");
2703template <
typename T>
2705 actualCamera_(std::move(camera))
2710template <
typename T>
2712 actualCamera_(camera)
2717template <
typename T>
2720 return actualCamera_;
2723template <
typename T>
2726 return actualCamera_.width();
2729template <
typename T>
2732 return actualCamera_.height();
2735template <
typename T>
2738 return actualCamera_.principalPoint();
2741template <
typename T>
2744 return actualCamera_.principalPointX();
2747template <
typename T>
2750 return actualCamera_.principalPointY();
2753template <
typename T>
2756 return actualCamera_.focalLengthX();
2759template <
typename T>
2762 return actualCamera_.focalLengthY();
2765template <
typename T>
2768 return actualCamera_.inverseFocalLengthX();
2771template <
typename T>
2774 return actualCamera_.inverseFocalLengthY();
2777template <
typename T>
2780 return actualCamera_.projectToImageIF(objectPoint);
2783template <
typename T>
2786 return actualCamera_.projectToImageIF(flippedCamera_T_world, objectPoint);
2789template <
typename T>
2792 ocean_assert(size == 0 || objectPoints !=
nullptr);
2793 ocean_assert(size == 0 || imagePoints !=
nullptr);
2795 for (
size_t n = 0; n < size; ++n)
2797 imagePoints[n] = projectToImageIF(objectPoints[n]);
2801template <
typename T>
2804 ocean_assert(size == 0 || objectPoints !=
nullptr);
2805 ocean_assert(size == 0 || imagePoints !=
nullptr);
2807 for (
size_t n = 0; n < size; ++n)
2809 imagePoints[n] = projectToImageIF(flippedCamera_T_world, objectPoints[n]);
2813template <
typename T>
2816 return actualCamera_.vectorIF(distortedImagePoint, makeUnitVector);
2819template <
typename T>
2822 ocean_assert(distortedImagePoints !=
nullptr && size > 0);
2823 ocean_assert(vectors !=
nullptr);
2825 for (
size_t n = 0; n < size; ++n)
2827 vectors[n] = vectorIF(distortedImagePoints[n], makeUnitVector);
2831template <
typename T>
2834 actualCamera_.pointJacobian2x3IF(flippedCameraObjectPoint, jx, jy);
2837template <
typename T>
2840 ocean_assert(eps >= T(0));
2842 return actualCamera_.isEqual(baseFisheye.
actualCamera_, eps);
2845template <
typename T>
2848 return actualCamera_.isValid();
2851template <
typename T>
2852template <
typename U>
2855 ocean_assert(actualCamera_.isValid());
2857 if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2859 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBaseFisheyeT<U>>>>(
FisheyeCameraT<U>(actualCamera_));
2862 const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2863 const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2867 ocean_assert(
false &&
"Wrong aspect ratio!");
2871 const T xFactor = T(width) / T(actualCamera_.width());
2872 const T yFactor = T(height) / T(actualCamera_.height());
2874 const U newPrincipalX = U(actualCamera_.principalPointX() * xFactor);
2875 const U newPrincipalY = U(actualCamera_.principalPointY() * yFactor);
2877 const U newFocalLengthX = U(actualCamera_.focalLengthX() * xFactor);
2878 const U newFocalLengthY = U(actualCamera_.focalLengthY() * yFactor);
2880 U radialDistortion[6];
2881 for (
unsigned int n = 0u; n < 6u; ++n)
2883 radialDistortion[n] = U(actualCamera_.radialDistortion()[n]);
2886 const U tangentialDistortion[2] =
2888 U(actualCamera_.tangentialDistortion()[0]),
2889 U(actualCamera_.tangentialDistortion()[1])
2892 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBaseFisheyeT<U>>>>(
FisheyeCameraT<U>(width, height, newFocalLengthX, newFocalLengthY, newPrincipalX, newPrincipalY, radialDistortion, tangentialDistortion));
2895template <
typename T>
2901template <
typename T>
2904 return std::string(
"Ocean Fisheye");
2907template <
typename T>
2909 actualCamera_(std::move(camera))
2914template <
typename T>
2916 actualCamera_(camera)
2921template <
typename T>
2924 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2926 ocean_assert(
false &&
"This function must never be called.");
2928 return actualCamera_;
2931template <
typename T>
2934 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2936 ocean_assert(
false &&
"This function must never be called.");
2938 return (
unsigned int)(-1);
2941template <
typename T>
2944 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2946 ocean_assert(
false &&
"This function must never be called.");
2948 return (
unsigned int)(-1);
2951template <
typename T>
2954 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2956 ocean_assert(
false &&
"This function must never be called.");
2961template <
typename T>
2964 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2966 ocean_assert(
false &&
"This function must never be called.");
2971template <
typename T>
2974 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2976 ocean_assert(
false &&
"This function must never be called.");
2981template <
typename T>
2984 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2986 ocean_assert(
false &&
"This function must never be called.");
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.");
3050template <
typename T>
3053 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3055 ocean_assert(
false &&
"This function must never be called.");
3058template <
typename T>
3061 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3063 ocean_assert(
false &&
"This function must never be called.");
3068template <
typename T>
3071 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3073 ocean_assert(
false &&
"This function must never be called.");
3076template <
typename T>
3079 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3081 ocean_assert(
false &&
"This function must never be called.");
3084template <
typename T>
3087 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3089 ocean_assert(
false &&
"This function must never be called.");
3094template <
typename T>
3100template <
typename T>
3101template <
typename U>
3104 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3106 ocean_assert(
false &&
"This function must never be called.");
3111template <
typename T>
3117template <
typename T>
3120 return std::string(
"Invalid camera");
3123template <
typename T>
3130template <
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:1725
bool isValid() const
Returns whether this clipper holds a valid camera model and is ready to be used.
Definition AnyCamera.h:1822
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:1961
AnyCameraClipperT()=default
Default constructor creating an invalid object.
unsigned int height() const
Returns the height of the camera profile.
Definition AnyCamera.h:1775
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:1816
FiniteLinesT2< T > cameraBoundarySegments_
The 2D line segments defined in the camera's normalized image plane defining the camera's boundary,...
Definition AnyCamera.h:616
const SharedAnyCameraT< T > & camera() const
Returns the camera model of this clipper.
Definition AnyCamera.h:1758
unsigned int width() const
Returns the width of the camera profile.
Definition AnyCamera.h:1764
SharedAnyCameraT< T > camera_
The actual camera model this clipper is based on.
Definition AnyCamera.h:613
void update(const SharedAnyCameraT< T > &camera, const size_t segmentSteps=10)
Updates the clipper with a new camera model.
Definition AnyCamera.h:1786
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:1830
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:2008
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:2076
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:630
VectorT2< T > principalPoint() const override
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2140
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:2290
VectorT2< T > projectToImage(const VectorT3< T > &objectPoint) const override
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2200
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:2296
unsigned int width() const override
Returns the width of the camera image.
Definition AnyCamera.h:2128
unsigned int height() const override
Returns the height of the camera image.
Definition AnyCamera.h:2134
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:2116
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:2110
T focalLengthY() const override
Returns the vertical focal length parameter.
Definition AnyCamera.h:2164
bool isValid() const override
Returns whether this camera is valid.
Definition AnyCamera.h:2321
AnyCameraType anyCameraType() const override
Returns the type of this camera.
Definition AnyCamera.h:2098
T inverseFocalLengthX() const override
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:2170
T principalPointY() const override
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2152
AnyCameraWrappingT(ActualCamera &&actualCamera)
Creates a new AnyCamera object wrapping the actual camera model.
Definition AnyCamera.h:2084
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:2248
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const override
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2212
T TScalar
The scalar data type of this object.
Definition AnyCamera.h:634
T focalLengthX() const override
Returns the horizontal focal length parameter.
Definition AnyCamera.h:2158
T fovX() const override
Returns the field of view in x direction of the camera.
Definition AnyCamera.h:2182
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:2194
std::string name() const override
Returns the name of this camera.
Definition AnyCamera.h:2104
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:2272
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:2260
typename TCameraWrapper::ActualCamera ActualCamera
The actual camera object wrapped by this class.
Definition AnyCamera.h:640
T principalPointX() const override
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2146
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:2122
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:2284
T fovY() const override
Returns the field of view in x direction of the camera.
Definition AnyCamera.h:2188
T inverseFocalLengthY() const override
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:2176
This class implements the base class for all cameras.
Definition Camera.h:98
This class implements the base wrapper around Ocean's fisheye camera profile.
Definition AnyCamera.h:1239
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2742
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:2766
ActualCamera actualCamera_
The actual fisheye camera object.
Definition AnyCamera.h:1402
unsigned int height() const
Returns the height of the camera image.
Definition AnyCamera.h:2730
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:2832
unsigned int width() const
Returns the width of the camera image.
Definition AnyCamera.h:2724
bool isValid() const
Returns whether this camera is valid.
Definition AnyCamera.h:2846
FisheyeCameraT< T > ActualCamera
Definition of the actual camera object wrapped by this class.
Definition AnyCamera.h:1245
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:2772
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition AnyCamera.h:2896
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:2814
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition AnyCamera.h:2718
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2736
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2748
static std::string name()
Returns the name of this camera.
Definition AnyCamera.h:2902
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition AnyCamera.h:2754
T focalLengthY() const
Returns the vertical focal length parameter.
Definition AnyCamera.h:2760
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2778
CameraWrapperBaseFisheyeT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBaseFisheyeT object wrapping the actual camera model.
Definition AnyCamera.h:2704
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:2853
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:2838
This class implements the base wrapper around an invalid camera profile.
Definition AnyCamera.h:1462
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:3085
InvalidCameraT< T > ActualCamera
Definition of the actual camera object wrapped by this class.
Definition AnyCamera.h:1468
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:3022
CameraWrapperBaseInvalidT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBaseInvalidT object wrapping the actual camera model.
Definition AnyCamera.h:2908
unsigned int height() const
Returns the height of the camera image.
Definition AnyCamera.h:2942
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition AnyCamera.h:2922
static std::string name()
Returns the name of this camera.
Definition AnyCamera.h:3118
ActualCamera actualCamera_
The actual invalid camera.
Definition AnyCamera.h:1625
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2962
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2952
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:3002
bool isValid() const
Returns whether this camera is valid.
Definition AnyCamera.h:3095
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition AnyCamera.h:3112
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:3102
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:3012
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:3077
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:3059
T focalLengthY() const
Returns the vertical focal length parameter.
Definition AnyCamera.h:2992
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2972
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition AnyCamera.h:2982
unsigned int width() const
Returns the width of the camera image.
Definition AnyCamera.h:2932
This class implements the base wrapper around Ocean's pinhole camera profile.
Definition AnyCamera.h:1070
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:2557
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:2625
PinholeCameraT< T > ActualCamera
Definition of the actual camera object wrapped by this class.
Definition AnyCamera.h:1076
unsigned int height() const
Returns the height of the camera image.
Definition AnyCamera.h:2527
bool isValid() const
Returns whether this camera is valid.
Definition AnyCamera.h:2640
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2539
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:2563
static std::string name()
Returns the name of this camera.
Definition AnyCamera.h:2698
ActualCamera actualCamera_
The actual pinhole camera.
Definition AnyCamera.h:1228
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition AnyCamera.h:2515
unsigned int width() const
Returns the width of the camera image.
Definition AnyCamera.h:2521
CameraWrapperBasePinholeT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBasePinholeT object wrapping the actual camera model.
Definition AnyCamera.h:2501
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:2605
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2569
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition AnyCamera.h:2692
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2533
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:2632
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:2647
T focalLengthY() const
Returns the vertical focal length parameter.
Definition AnyCamera.h:2551
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition AnyCamera.h:2545
This class implements a wrapper for an actual camera object.
Definition AnyCamera.h:961
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:2471
T fovY() const
Returns the field of view in x direction of the camera.
Definition AnyCamera.h:2376
T fovX() const
Returns the field of view in x direction of the camera.
Definition AnyCamera.h:2347
CameraWrapperT(ActualCamera &&actualCamera)
Creates a new CameraWrapperT object wrapping the actual camera model.
Definition AnyCamera.h:2327
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:2450
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:2487
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:2405
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2341
VectorT2< T > projectToImage(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2419
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:1493
VectorT3< T > translation() const
Returns the translation of the transformation.
Definition HomogenousMatrix4.h:1381
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1806
This class implements invalid camera profiles, e.g.
Definition AnyCamera.h:1412
const std::string & reason() const
Returns the reason of this invalid camera.
Definition AnyCamera.h:3131
std::string reason_
The reason why no valid camera is available.
Definition AnyCamera.h:1430
InvalidCameraT(const std::string &reason)
Creates an invalid camera.
Definition AnyCamera.h:3124
This class implements an infinite line in 3D space.
Definition Line3.h:68
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 T abs(const T value)
Returns the absolute value of a given value.
Definition Numeric.h:1220
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:710
const T & y() const noexcept
Returns the y value.
Definition Vector2.h:722
bool isNull() const
Returns whether this vector is a null vector up to a small epsilon.
Definition Vector2.h:746
T sqrDistance(const VectorT2< T > &right) const
Returns the square distance between this 2D position and a second 2D position.
Definition Vector2.h:645
This class implements a vector with three elements.
Definition Vector3.h:97
const T & y() const noexcept
Returns the y value.
Definition Vector3.h:824
const T & x() const noexcept
Returns the x value.
Definition Vector3.h:812
VectorT2< T > xy() const noexcept
Returns the x and y component of the vector as new 2D vector.
Definition Vector3.h:848
static VectorT3< T > minValue()
Returns a 3D vector with all elements set to NumericT::minValue().
Definition Vector3.h:1059
const T & z() const noexcept
Returns the z value.
Definition Vector3.h:836
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