class mola::internal::ViewDirectionTest

Overview

Decides whether a cov-to-cov pair must be rejected from the view directions of its two points, as configured by a ViewDirectionFilter mode.

Both view vectors, and the covariance of the matched map point, must be given in the same frame (whichever is cheaper for the caller).

#include <view_direction_test.h>

class ViewDirectionTest
{
public:
    // construction

    ViewDirectionTest(bool enabled, ViewDirectionFilter mode, double maxViewAngleDeg);

    // methods

    ViewDirectionFilter mode() const;
    bool active() const;
    bool needsCovariance() const;

    template <class IsFlatFn>
    bool rejects(
        const Eigen::Vector3f& vQuery,
        const Eigen::Vector3f& vMap,
        const Eigen::Matrix3f* covMap,
        IsFlatFn&& isFlat
        ) const;

    bool rejects(const Eigen::Vector3f& vQuery, const Eigen::Vector3f& vMap) const;

    static bool seenFromOppositeSides(
        const Eigen::Matrix3f& cov,
        const Eigen::Vector3f& v1,
        const Eigen::Vector3f& v2
        );

    template <class PointAtFn>
    static bool neighborhoodIsFlat(std::size_t n, PointAtFn&& pointAt);
};

Construction

ViewDirectionTest(bool enabled, ViewDirectionFilter mode, double maxViewAngleDeg)

enabled is the classes’ use_view_direction_filter master switch. A MaxAngle threshold of 180 deg or more rejects nothing, so it is reported as inactive.

Methods

bool active() const

Whether the test can reject anything at all.

bool needsCovariance() const

Whether rejects() needs the covariance of the matched map point.

template <class IsFlatFn>
bool rejects(
    const Eigen::Vector3f& vQuery,
    const Eigen::Vector3f& vMap,
    const Eigen::Matrix3f* covMap,
    IsFlatFn&& isFlat
    ) const

True if the pair must be rejected. covMap is only read in SurfaceSide mode, and so is isFlat : a callable returning whether the raw (not regularized) neighborhood of the matched map point is flat, invoked only for a pair the side test would otherwise reject. A zero (missing) direction on either side never rejects.

The flatness check is needed because the stored covariances are plane-regularized: every one that is not the isotropic fallback looks like a plane, including those of foliage, edges or poles, whose “normal” says nothing about which side a view comes from.

bool rejects(const Eigen::Vector3f& vQuery, const Eigen::Vector3f& vMap) const

Overload for the modes that need neither covariance nor flatness.

static bool seenFromOppositeSides(
    const Eigen::Matrix3f& cov,
    const Eigen::Vector3f& v1,
    const Eigen::Vector3f& v2
    )

True if two view directions see the surface of a point with covariance cov from opposite sides, both clearly (not near grazing incidence). A covariance without a clear normal (not plane-shaped) never qualifies.

template <class PointAtFn>
static bool neighborhoodIsFlat(
    std::size_t n,
    PointAtFn&& pointAt
    )

Whether the n points given by pointAt(i) (an Eigen::Vector3d each) lie close to a plane: smallest scatter eigenvalue under a tenth of the middle one. Fewer than 3 points never qualify.