armarx::fake_object_detector Namespace Reference

Geometric primitives for the fake object detector. More...

Classes

struct  Box
 An oriented bounding box in the global frame. More...
 
struct  Frustum
 A symmetric view frustum. More...
 

Enumerations

enum class  DetectionMode { Always , FieldOfView , LineOfSight }
 How strictly an object must be perceivable before it is reported. More...
 

Functions

Eigen::Vector3f faceCenter (const Box &box, int faceIndex)
 Centre of faceIndex in global coordinates.
 
Eigen::Vector3f faceNormal (const Box &box, int faceIndex)
 Outward unit normal of faceIndex in global coordinates.
 
int frontFaceIndex (const Frustum &frustum, const Box &box)
 The face of box that points most directly at the camera - the "front facing side" of the bounding box.
 
std::optional< floatintersectRayBox (const Eigen::Vector3f &origin, const Eigen::Vector3f &unitDirection, const Box &box)
 Intersect a ray with an oriented box using the slab method.
 
bool isInFieldOfView (const Frustum &frustum, const Box &box, bool requireFullyInside)
 Whether box is inside the camera frustum.
 
std::vector< Eigen::Vector3f > sampleFace (const Box &box, int faceIndex, int gridN)
 A gridN x gridN grid of sample points spread over faceIndex, in global coordinates.
 
float visibleFraction (const Frustum &frustum, const Box &target, const std::vector< Box > &occluders, int gridN, float epsilon)
 The fraction of sample points on the front face of target that the camera can see.
 

Detailed Description

Geometric primitives for the fake object detector.

This header is deliberately free of Ice, ArmarX component and Simox types so that the visibility logic can be unit tested in isolation.

All lengths are in millimetres and all poses are in the global frame, matching the ArmarX/Simox convention.

Enumeration Type Documentation

◆ DetectionMode

enum class DetectionMode
strong

How strictly an object must be perceivable before it is reported.

Enumerator
Always 

Report every object, regardless of where the camera looks.

FieldOfView 

Report an object once its bounding box enters the camera frustum.

LineOfSight 

Additionally require a clear line of sight to the front face of the bounding box.

Definition at line 45 of file VisibilityCheck.h.

Function Documentation

◆ faceCenter()

Eigen::Vector3f faceCenter ( const Box & box,
int faceIndex )

Centre of faceIndex in global coordinates.

Definition at line 151 of file VisibilityCheck.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ faceNormal()

Eigen::Vector3f faceNormal ( const Box & box,
int faceIndex )

Outward unit normal of faceIndex in global coordinates.

Definition at line 145 of file VisibilityCheck.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ frontFaceIndex()

int frontFaceIndex ( const Frustum & frustum,
const Box & box )

The face of box that points most directly at the camera - the "front facing side" of the bounding box.

Returns
A face index in [0, 6): 0 = +X, 1 = -X, 2 = +Y, 3 = -Y, 4 = +Z, 5 = -Z.

Definition at line 158 of file VisibilityCheck.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ intersectRayBox()

std::optional< float > intersectRayBox ( const Eigen::Vector3f & origin,
const Eigen::Vector3f & unitDirection,
const Box & box )

Intersect a ray with an oriented box using the slab method.

Parameters
unitDirectionMust be normalized.
Returns
Distance from origin to the nearest intersection, or std::nullopt if the ray misses. Returns 0 when origin lies inside the box.

Definition at line 218 of file VisibilityCheck.cpp.

+ Here is the call graph for this function:

◆ isInFieldOfView()

bool isInFieldOfView ( const Frustum & frustum,
const Box & box,
bool requireFullyInside )

Whether box is inside the camera frustum.

Parameters
requireFullyInsideIf true, all eight corners must be inside. Otherwise it is enough that any corner or the box centre is inside.

Definition at line 121 of file VisibilityCheck.cpp.

+ Here is the call graph for this function:

◆ sampleFace()

std::vector< Eigen::Vector3f > sampleFace ( const Box & box,
int faceIndex,
int gridN )

A gridN x gridN grid of sample points spread over faceIndex, in global coordinates.

Samples sit at cell centres, so they never lie exactly on an edge shared with an adjacent object. gridN == 1 yields the face centre alone.

Definition at line 187 of file VisibilityCheck.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ visibleFraction()

float visibleFraction ( const Frustum & frustum,
const Box & target,
const std::vector< Box > & occluders,
int gridN,
float epsilon )

The fraction of sample points on the front face of target that the camera can see.

A sample is blocked when any occluder is hit closer than the sample itself. An occluder containing the camera (such as the head link the camera is mounted in) never blocks.

Parameters
occludersMust NOT contain target; otherwise every ray is blocked by the target's own front face.
epsilonTolerance [mm] to absorb the hit exactly on the target's surface.
Returns
A value in [0, 1]; 0 if the face has no samples.

Definition at line 270 of file VisibilityCheck.cpp.

+ Here is the call graph for this function: