Ocean
Loading...
Searching...
No Matches
Ocean::AnyCameraClipperT< T > Class Template Reference

This class implements a helper class allowing to check whether a 3D object point projects into the camera image (i.e., clipping against the camera's field of view). More...

#include <AnyCamera.h>

Public Member Functions

 AnyCameraClipperT ()=default
 Default constructor creating an invalid object.
 
 AnyCameraClipperT (const SharedAnyCameraT< T > &camera, const size_t segmentSteps=10)
 Creates a new clipper object for a specified camera model.
 
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 image.
 
const SharedAnyCameraT< T > & camera () const
 Returns the camera model of this clipper.
 
unsigned int width () const
 Returns the width of the camera profile.
 
unsigned int height () const
 Returns the height of the camera profile.
 
void update (const SharedAnyCameraT< T > &camera, const size_t segmentSteps=10)
 Updates the clipper with a new camera model.
 
const FiniteLinesT2< T > & cameraBoundarySegments () const
 Returns the 2D line segments defined in the camera's normalized image plane defining the camera's boundary.
 
bool isValid () const
 Returns whether this clipper holds a valid camera model and is ready to be used.
 

Static Protected Member Functions

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.
 
static bool isInside (const FiniteLinesT2< T > &cameraBoundarySegments, const VectorT2< T > &normalizedImagePoint)
 Returns whether a given normalized image point lies inside the camera's boundary.
 
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.
 

Protected Attributes

SharedAnyCameraT< T > camera_
 The actual camera model this clipper is based on.
 
FiniteLinesT2< T > cameraBoundarySegments_
 The 2D line segments defined in the camera's normalized image plane defining the camera's boundary, defined in the flipped camera coordinate system with y-axis down.
 

Detailed Description

template<typename T>
class Ocean::AnyCameraClipperT< T >

This class implements a helper class allowing to check whether a 3D object point projects into the camera image (i.e., clipping against the camera's field of view).

The clipper uses normalized coordinates when verifying the projection behavior to avoid numerical issues when object points project far outside the image area.
In contrast to AnyCamera::projectToImageIF() + AnyCamera::isInside(), the clipper is more precise but also more expensive.

Template Parameters
TThe data type of a scalar, 'float' or 'double'

Constructor & Destructor Documentation

◆ AnyCameraClipperT() [1/2]

template<typename T >
Ocean::AnyCameraClipperT< T >::AnyCameraClipperT ( )
default

Default constructor creating an invalid object.

◆ AnyCameraClipperT() [2/2]

template<typename T >
Ocean::AnyCameraClipperT< T >::AnyCameraClipperT ( const SharedAnyCameraT< T > &  camera,
const size_t  segmentSteps = 10 
)
explicit

Creates a new clipper object for a specified camera model.

Parameters
cameraThe camera model defining the projection, must be valid
segmentStepsThe number of segments to be used to determine the camera boundary, with range [2, infinity)

Member Function Documentation

◆ camera()

template<typename T >
const SharedAnyCameraT< T > & Ocean::AnyCameraClipperT< T >::camera ( ) const

Returns the camera model of this clipper.

Returns
The clipper's camera model, nullptr if no camera model has been set

◆ cameraBoundarySegments()

template<typename T >
const FiniteLinesT2< T > & Ocean::AnyCameraClipperT< T >::cameraBoundarySegments ( ) const

Returns the 2D line segments defined in the camera's normalized image plane defining the camera's boundary.

Returns
The camera boundary segments

◆ determineCameraBoundary()

template<typename T >
bool Ocean::AnyCameraClipperT< T >::determineCameraBoundary ( const AnyCameraT< T > &  camera,
FiniteLinesT2< T > &  cameraBoundarySegments,
const size_t  segmentSteps 
)
staticprotected

Determines the camera boundary of a given camera model in normalized image coordinates.

Parameters
cameraThe camera model for which the boundary will be determined, must be valid
cameraBoundarySegmentsThe resulting 2D line segments defining the camera's boundary
segmentStepsThe number of segments to be used to determine the camera boundary, with range [1, infinity)
Returns
True, if succeeded

◆ height()

template<typename T >
unsigned int Ocean::AnyCameraClipperT< T >::height ( ) const
inline

Returns the height of the camera profile.

Returns
The camera image height in pixel, with range [0, infinity), 0 if no camera has been set

◆ isInside()

template<typename T >
bool Ocean::AnyCameraClipperT< T >::isInside ( const FiniteLinesT2< T > &  cameraBoundarySegments,
const VectorT2< T > &  normalizedImagePoint 
)
staticprotected

Returns whether a given normalized image point lies inside the camera's boundary.

Parameters
cameraBoundarySegmentsThe 2D line segments defining the camera's boundary, at least three
normalizedImagePointThe normalized image point to be checked
Returns
True, if if so

◆ isValid()

template<typename T >
bool Ocean::AnyCameraClipperT< T >::isValid ( ) const

Returns whether this clipper holds a valid camera model and is ready to be used.

Returns
True, if so

◆ isValidForPoint()

template<typename T >
bool Ocean::AnyCameraClipperT< T >::isValidForPoint ( const AnyCameraT< T > &  camera,
const VectorT2< T > &  imagePoint,
const T  maximalReprojectionError = T(1),
const unsigned int  additionalChecksTowardsPrincipalPoint = 3u 
)
staticprotected

Returns whether a given camera model is valid for a specified 2D image point in the camera image.

The function does not only check whether the provided image point re-projects back to the same image point but also whether additional image points sampled towards the principal point have the same behavior.

Parameters
cameraThe camera model to be checked, must be valid
imagePointThe 2D image point to be checked, defined in the camera image, with range [0, width()]x[0, height()]
maximalReprojectionErrorThe maximal allowed re-projection error in pixel, with range [0, infinity)
additionalChecksTowardsPrincipalPointThe number of additional image points sampled towards the principal point to be checked, with range [1, infinity)
Returns
True, if the camera model is valid for the specified image point

◆ projectToImageIF()

template<typename T >
bool Ocean::AnyCameraClipperT< T >::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 image.

Parameters
flippedCamera_T_worldThe inverted and flipped camera pose, the default flipped camera is looking into the positive z-space with y-axis down, transforming world to flipped camera, must be valid
objectPointThe 3D object point to be checked, defined in world
imagePointOptional resulting 2D projected image point inside the camera image, nullptr if not of interest
Returns
True, if the object point projects into the camera image; False, if the object point is behind the camera or projects outside the camera image

◆ update()

template<typename T >
void Ocean::AnyCameraClipperT< T >::update ( const SharedAnyCameraT< T > &  camera,
const size_t  segmentSteps = 10 
)

Updates the clipper with a new camera model.

If the new camera is equal to the current camera, the function will return immediately without any updates.

Parameters
cameraThe camera model defining the projection, must be valid
segmentStepsThe number of segments to be used to determine the camera boundary, with range [1, infinity)

◆ width()

template<typename T >
unsigned int Ocean::AnyCameraClipperT< T >::width ( ) const
inline

Returns the width of the camera profile.

Returns
The camera image width in pixel, with range [0, infinity), 0 if no camera has been set

Field Documentation

◆ camera_

template<typename T >
SharedAnyCameraT<T> Ocean::AnyCameraClipperT< T >::camera_
protected

The actual camera model this clipper is based on.

◆ cameraBoundarySegments_

template<typename T >
FiniteLinesT2<T> Ocean::AnyCameraClipperT< T >::cameraBoundarySegments_
protected

The 2D line segments defined in the camera's normalized image plane defining the camera's boundary, defined in the flipped camera coordinate system with y-axis down.


The documentation for this class was generated from the following file: