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());
2402 if (T(TCameraWrapperBase::width()) <= TCameraWrapperBase::principalPointX())
2404 ocean_assert(
false &&
"Invalid principal point");
2405 return T(2) * leftAngle;
2408 const T rightAngle =
NumericT<T>::atan((T(TCameraWrapperBase::width()) - TCameraWrapperBase::principalPointX()) * TCameraWrapperBase::inverseFocalLengthX());
2410 return leftAngle + rightAngle;
2413template <
typename T,
typename TCameraWrapperBase>
2416 ocean_assert(TCameraWrapperBase::isValid());
2431 if (T(TCameraWrapperBase::height()) <= TCameraWrapperBase::principalPointY())
2433 ocean_assert(
false &&
"Invalid principal point");
2434 return T(2) * topAngle;
2437 const T bottomAngle =
NumericT<T>::atan((T(TCameraWrapperBase::height()) - TCameraWrapperBase::principalPointY()) * TCameraWrapperBase::inverseFocalLengthY());
2439 return topAngle + bottomAngle;
2442template <
typename T,
typename TCameraWrapperBase>
2445 ocean_assert(TCameraWrapperBase::isValid());
2447 const unsigned int cameraWidth = TCameraWrapperBase::width();
2448 const unsigned int cameraHeight = TCameraWrapperBase::height();
2450 ocean_assert(signedBorder < T(std::min(cameraWidth / 2u, cameraHeight / 2u)));
2452 return imagePoint.
x() >= signedBorder && imagePoint.
y() >= signedBorder
2453 && imagePoint.
x() < T(cameraWidth) - signedBorder && imagePoint.
y() < T(cameraHeight) - signedBorder;
2456template <
typename T,
typename TCameraWrapperBase>
2459 return TCameraWrapperBase::projectToImageIF(
VectorT3<T>(objectPoint.
x(), -objectPoint.
y(), -objectPoint.
z()));
2462template <
typename T,
typename TCameraWrapperBase>
2468template <
typename T,
typename TCameraWrapperBase>
2471 ocean_assert(size == 0 || objectPoints !=
nullptr);
2472 ocean_assert(size == 0 || imagePoints !=
nullptr);
2474 for (
size_t n = 0; n < size; ++n)
2477 imagePoints[n] = TCameraWrapperBase::projectToImageIF(
VectorT3<T>(objectPoint.
x(), -objectPoint.
y(), -objectPoint.
z()));
2481template <
typename T,
typename TCameraWrapperBase>
2487template <
typename T,
typename TCameraWrapperBase>
2490 const VectorT3<T> localVectorIF(TCameraWrapperBase::vectorIF(distortedImagePoint, makeUnitVector));
2492 return VectorT3<T>(localVectorIF.
x(), -localVectorIF.
y(), -localVectorIF.
z());
2495template <
typename T,
typename TCameraWrapperBase>
2498 TCameraWrapperBase::vectorIF(distortedImagePoints, size, vectors, makeUnitVector);
2500 for (
size_t n = 0; n < size; ++n)
2504 vectors[n] =
VectorT3<T>(localVectorIF.
x(), -localVectorIF.
y(), -localVectorIF.
z());
2508template <
typename T,
typename TCameraWrapperBase>
2511 ocean_assert(TCameraWrapperBase::isValid() && world_T_camera.
isValid());
2516template <
typename T,
typename TCameraWrapperBase>
2519 ocean_assert(TCameraWrapperBase::isValid());
2524template <
typename T,
typename TCameraWrapperBase>
2527 ocean_assert(flippedCameraObjectPoints !=
nullptr);
2528 ocean_assert(numberObjectPoints >= 1);
2529 ocean_assert(jacobians !=
nullptr);
2531 for (
size_t n = 0; n < numberObjectPoints; ++n)
2533 TCameraWrapperBase::pointJacobian2x3IF(flippedCameraObjectPoints[n], jacobians + 0, jacobians + 3);
2538template <
typename T>
2540 actualCamera_(std::move(actualCamera))
2545template <
typename T>
2547 actualCamera_(actualCamera)
2552template <
typename T>
2555 return actualCamera_;
2558template <
typename T>
2561 return actualCamera_.width();
2564template <
typename T>
2567 return actualCamera_.height();
2570template <
typename T>
2573 return T(actualCamera_.principalPointX());
2576template <
typename T>
2579 return T(actualCamera_.principalPointY());
2582template <
typename T>
2585 return T(actualCamera_.focalLengthX());
2588template <
typename T>
2591 return T(actualCamera_.focalLengthY());
2594template <
typename T>
2597 return T(actualCamera_.inverseFocalLengthX());
2600template <
typename T>
2603 return T(actualCamera_.inverseFocalLengthY());
2606template <
typename T>
2612template <
typename T>
2615 return VectorT2<T>(actualCamera_.template projectToImageIF<true>(flippedCamera_T_world, objectPoint,
true));
2618template <
typename T>
2621 ocean_assert(size == 0 || objectPoints !=
nullptr);
2622 ocean_assert(size == 0 || imagePoints !=
nullptr);
2624 for (
size_t n = 0; n < size; ++n)
2626 imagePoints[n] = projectToImageIF(objectPoints[n]);
2630template <
typename T>
2633 ocean_assert(size == 0 || objectPoints !=
nullptr);
2634 ocean_assert(size == 0 || imagePoints !=
nullptr);
2636 for (
size_t n = 0; n < size; ++n)
2638 imagePoints[n] = projectToImageIF(flippedCamera_T_world, objectPoints[n]);
2642template <
typename T>
2645 const VectorT2<T> undistortedImagePoint(actualCamera_.template undistort<true>(distortedImagePoint));
2647 return VectorT3<T>(actualCamera_.vectorIF(undistortedImagePoint, makeUnitVector));
2650template <
typename T>
2653 ocean_assert(distortedImagePoints !=
nullptr && size > 0);
2654 ocean_assert(vectors !=
nullptr);
2656 for (
size_t n = 0; n < size; ++n)
2658 vectors[n] = vectorIF(distortedImagePoints[n], makeUnitVector);
2662template <
typename T>
2665 ocean_assert(jx !=
nullptr && jy !=
nullptr);
2666 actualCamera_.template pointJacobian2x3IF<T, true>(flippedCameraObjectPoint, jx, jy);
2669template <
typename T>
2672 ocean_assert(eps >= T(0));
2674 return actualCamera_.isEqual(basePinhole.
actualCamera_, eps);
2677template <
typename T>
2680 return actualCamera_.isValid();
2683template <
typename T>
2684template <
typename U>
2687 ocean_assert(actualCamera_.isValid());
2689 if constexpr (std::is_same<T, U>::value)
2691 if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2693 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(actualCamera_);
2696 const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2697 const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2701 ocean_assert(
false &&
"Wrong aspect ratio!");
2705 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(
PinholeCameraT<U>(width, height, actualCamera_));
2711 if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2713 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(convertedPinholeCamera);
2716 const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2717 const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2721 ocean_assert(
false &&
"Wrong aspect ratio!");
2725 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBasePinholeT<U>>>>(
PinholeCameraT<U>(width, height, convertedPinholeCamera));
2729template <
typename T>
2735template <
typename T>
2738 return std::string(
"Ocean Pinhole");
2741template <
typename T>
2743 actualCamera_(std::move(camera))
2748template <
typename T>
2750 actualCamera_(camera)
2755template <
typename T>
2758 return actualCamera_;
2761template <
typename T>
2764 return actualCamera_.width();
2767template <
typename T>
2770 return actualCamera_.height();
2773template <
typename T>
2776 return actualCamera_.principalPoint();
2779template <
typename T>
2782 return actualCamera_.principalPointX();
2785template <
typename T>
2788 return actualCamera_.principalPointY();
2791template <
typename T>
2794 return actualCamera_.focalLengthX();
2797template <
typename T>
2800 return actualCamera_.focalLengthY();
2803template <
typename T>
2806 return actualCamera_.inverseFocalLengthX();
2809template <
typename T>
2812 return actualCamera_.inverseFocalLengthY();
2815template <
typename T>
2818 return actualCamera_.projectToImageIF(objectPoint);
2821template <
typename T>
2824 return actualCamera_.projectToImageIF(flippedCamera_T_world, objectPoint);
2827template <
typename T>
2830 ocean_assert(size == 0 || objectPoints !=
nullptr);
2831 ocean_assert(size == 0 || imagePoints !=
nullptr);
2833 for (
size_t n = 0; n < size; ++n)
2835 imagePoints[n] = projectToImageIF(objectPoints[n]);
2839template <
typename T>
2842 ocean_assert(size == 0 || objectPoints !=
nullptr);
2843 ocean_assert(size == 0 || imagePoints !=
nullptr);
2845 for (
size_t n = 0; n < size; ++n)
2847 imagePoints[n] = projectToImageIF(flippedCamera_T_world, objectPoints[n]);
2851template <
typename T>
2854 return actualCamera_.vectorIF(distortedImagePoint, makeUnitVector);
2857template <
typename T>
2860 ocean_assert(distortedImagePoints !=
nullptr && size > 0);
2861 ocean_assert(vectors !=
nullptr);
2863 for (
size_t n = 0; n < size; ++n)
2865 vectors[n] = vectorIF(distortedImagePoints[n], makeUnitVector);
2869template <
typename T>
2872 actualCamera_.pointJacobian2x3IF(flippedCameraObjectPoint, jx, jy);
2875template <
typename T>
2878 ocean_assert(eps >= T(0));
2880 return actualCamera_.isEqual(baseFisheye.
actualCamera_, eps);
2883template <
typename T>
2886 return actualCamera_.isValid();
2889template <
typename T>
2890template <
typename U>
2893 ocean_assert(actualCamera_.isValid());
2895 if ((width == 0u && height == 0u) || (width == actualCamera_.width() && height == actualCamera_.height()))
2897 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBaseFisheyeT<U>>>>(
FisheyeCameraT<U>(actualCamera_));
2900 const unsigned int validWidth = (height * actualCamera_.width() + actualCamera_.height() / 2u) / actualCamera_.height();
2901 const unsigned int validHeight = (width * actualCamera_.height() + actualCamera_.width() / 2u) / actualCamera_.width();
2905 ocean_assert(
false &&
"Wrong aspect ratio!");
2909 const T xFactor = T(width) / T(actualCamera_.width());
2910 const T yFactor = T(height) / T(actualCamera_.height());
2912 const U newPrincipalX = U(actualCamera_.principalPointX() * xFactor);
2913 const U newPrincipalY = U(actualCamera_.principalPointY() * yFactor);
2915 const U newFocalLengthX = U(actualCamera_.focalLengthX() * xFactor);
2916 const U newFocalLengthY = U(actualCamera_.focalLengthY() * yFactor);
2918 U radialDistortion[6];
2919 for (
unsigned int n = 0u; n < 6u; ++n)
2921 radialDistortion[n] = U(actualCamera_.radialDistortion()[n]);
2924 const U tangentialDistortion[2] =
2926 U(actualCamera_.tangentialDistortion()[0]),
2927 U(actualCamera_.tangentialDistortion()[1])
2930 return std::make_unique<AnyCameraWrappingT<U, CameraWrapperT<U, CameraWrapperBaseFisheyeT<U>>>>(
FisheyeCameraT<U>(width, height, newFocalLengthX, newFocalLengthY, newPrincipalX, newPrincipalY, radialDistortion, tangentialDistortion));
2933template <
typename T>
2939template <
typename T>
2942 return std::string(
"Ocean Fisheye");
2945template <
typename T>
2947 actualCamera_(std::move(camera))
2952template <
typename T>
2954 actualCamera_(camera)
2959template <
typename T>
2962 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2964 ocean_assert(
false &&
"This function must never be called.");
2966 return actualCamera_;
2969template <
typename T>
2972 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2974 ocean_assert(
false &&
"This function must never be called.");
2976 return (
unsigned int)(-1);
2979template <
typename T>
2982 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2984 ocean_assert(
false &&
"This function must never be called.");
2986 return (
unsigned int)(-1);
2989template <
typename T>
2992 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
2994 ocean_assert(
false &&
"This function must never be called.");
2999template <
typename T>
3002 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3004 ocean_assert(
false &&
"This function must never be called.");
3009template <
typename T>
3012 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3014 ocean_assert(
false &&
"This function must never be called.");
3019template <
typename T>
3022 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3024 ocean_assert(
false &&
"This function must never be called.");
3029template <
typename T>
3032 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3034 ocean_assert(
false &&
"This function must never be called.");
3039template <
typename T>
3042 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3044 ocean_assert(
false &&
"This function must never be called.");
3049template <
typename T>
3052 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3054 ocean_assert(
false &&
"This function must never be called.");
3059template <
typename T>
3062 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3064 ocean_assert(
false &&
"This function must never be called.");
3069template <
typename T>
3072 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3074 ocean_assert(
false &&
"This function must never be called.");
3079template <
typename T>
3082 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3084 ocean_assert(
false &&
"This function must never be called.");
3088template <
typename T>
3091 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3093 ocean_assert(
false &&
"This function must never be called.");
3096template <
typename T>
3099 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3101 ocean_assert(
false &&
"This function must never be called.");
3106template <
typename T>
3109 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3111 ocean_assert(
false &&
"This function must never be called.");
3114template <
typename T>
3117 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3119 ocean_assert(
false &&
"This function must never be called.");
3122template <
typename T>
3125 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3127 ocean_assert(
false &&
"This function must never be called.");
3132template <
typename T>
3138template <
typename T>
3139template <
typename U>
3142 Log::error() <<
"Invalid camera: " << actualCamera_.reason();
3144 ocean_assert(
false &&
"This function must never be called.");
3149template <
typename T>
3155template <
typename T>
3158 return std::string(
"Invalid camera");
3161template <
typename T>
3168template <
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:2780
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:2804
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:2768
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:2870
unsigned int width() const
Returns the width of the camera image.
Definition AnyCamera.h:2762
bool isValid() const
Returns whether this camera is valid.
Definition AnyCamera.h:2884
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:2810
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition AnyCamera.h:2934
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:2852
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition AnyCamera.h:2756
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2774
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2786
static std::string name()
Returns the name of this camera.
Definition AnyCamera.h:2940
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition AnyCamera.h:2792
T focalLengthY() const
Returns the vertical focal length parameter.
Definition AnyCamera.h:2798
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2816
CameraWrapperBaseFisheyeT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBaseFisheyeT object wrapping the actual camera model.
Definition AnyCamera.h:2742
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:2891
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:2876
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:3123
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:3060
CameraWrapperBaseInvalidT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBaseInvalidT object wrapping the actual camera model.
Definition AnyCamera.h:2946
unsigned int height() const
Returns the height of the camera image.
Definition AnyCamera.h:2980
const ActualCamera & actualCamera() const
Returns the actual camera object wrapped in this class.
Definition AnyCamera.h:2960
static std::string name()
Returns the name of this camera.
Definition AnyCamera.h:3156
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:3000
VectorT2< T > principalPoint() const
Returns the coordinate of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2990
T inverseFocalLengthX() const
Returns the inverse horizontal focal length parameter.
Definition AnyCamera.h:3040
bool isValid() const
Returns whether this camera is valid.
Definition AnyCamera.h:3133
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition AnyCamera.h:3150
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:3140
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:3050
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:3115
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:3097
T focalLengthY() const
Returns the vertical focal length parameter.
Definition AnyCamera.h:3030
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:3010
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition AnyCamera.h:3020
unsigned int width() const
Returns the width of the camera image.
Definition AnyCamera.h:2970
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:2595
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:2663
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:2565
bool isValid() const
Returns whether this camera is valid.
Definition AnyCamera.h:2678
T principalPointY() const
Returns the y-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2577
T inverseFocalLengthY() const
Returns the inverse vertical focal length parameter.
Definition AnyCamera.h:2601
static std::string name()
Returns the name of this camera.
Definition AnyCamera.h:2736
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:2553
unsigned int width() const
Returns the width of the camera image.
Definition AnyCamera.h:2559
CameraWrapperBasePinholeT(ActualCamera &&actualCamera)
Creates a new CameraWrapperBasePinholeT object wrapping the actual camera model.
Definition AnyCamera.h:2539
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:2643
VectorT2< T > projectToImageIF(const VectorT3< T > &objectPoint) const
Projects a 3D object point into the camera frame.
Definition AnyCamera.h:2607
static AnyCameraType anyCameraType()
Returns the type of this camera.
Definition AnyCamera.h:2730
T principalPointX() const
Returns the x-value of the principal point of the camera image in the pixel domain.
Definition AnyCamera.h:2571
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:2670
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:2685
T focalLengthY() const
Returns the vertical focal length parameter.
Definition AnyCamera.h:2589
T focalLengthX() const
Returns the horizontal focal length parameter.
Definition AnyCamera.h:2583
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:2509
T fovY() const
Returns the field of view in x direction of the camera.
Definition AnyCamera.h:2414
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:2488
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:2525
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:2443
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:2457
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:1420
const std::string & reason() const
Returns the reason of this invalid camera.
Definition AnyCamera.h:3169
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:3162
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 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