31#include <visp3/rbt/vpDepthMask.h>
33#include <visp3/rbt/vpRBFeatureTracker.h>
35#if defined(VISP_HAVE_NLOHMANN_JSON)
36#include VISP_NLOHMANN_JSON(json.hpp)
54 const float Zmi = std::min(Zo - radius, frame.
renders.
zNear);
55 const float Zma = std::max(Zo + radius, frame.
renders.
zFar);
57 const float tol = radius * m_falloffSmoothingFactor;
58 const float fac = 1.f / (tol * sqrtf(2.f));
61 const auto getProba = [Zmi, Zma, fac](
double Z) ->
float {
68 if (Z > Zmi && Z < Zma) {
74 return erfc((Zmi - Z) * fac);
77 return erfc((Z - Zma) * fac);
82 if (!m_computeOnBBOnly) {
84#if defined(VISP_HAVE_OPENMP)
85#pragma omp parallel for
87 for (
int i = 0; i < static_cast<int>(frame.
depth.
getSize()); ++i) {
89 mask.
bitmap[i] = getProba(Z);
95 const int top =
static_cast<int>(renderBB.
getTop());
96 const int left =
static_cast<int>(renderBB.
getLeft());
97 const int bottom = std::min(
static_cast<int>(frame.
depth.
getHeight()) - 1,
static_cast<int>(renderBB.
getBottom()));
98 const int right = std::min(
static_cast<int>(frame.
depth.
getWidth()) - 1,
static_cast<int>(renderBB.
getRight()));
99#ifdef VISP_HAVE_OPENMP
100#pragma omp parallel for
102 for (
int i = top; i <= bottom; ++i) {
103 float *
const maskRow = mask[i];
104 const float *
const depthRow = frame.
depth[i];
105 for (
unsigned int j = left; j <= static_cast<unsigned int>(right); ++j) {
106 maskRow[j] = getProba(depthRow[j]);
112#if defined(VISP_HAVE_NLOHMANN_JSON)
115 m_minRadiusFactor = json.value(
"minRadiusFactor", m_minRadiusFactor);
116 m_falloffSmoothingFactor = json.value(
"falloffRadiusFactor", m_falloffSmoothingFactor);
117 m_computeOnBBOnly = json.value(
"computeOnlyOnBoundingBox", m_computeOnBBOnly);
void loadJsonConfiguration(const nlohmann::json &json) VP_OVERRIDE
void updateMask(const vpRBFeatureTrackerInput &frame, const vpRBFeatureTrackerInput &previousFrame, vpImage< float > &mask) VP_OVERRIDE
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
Definition of the vpImage class member functions.
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
unsigned int getSize() const
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
Defines a rectangle in the plane.
double zNear
Binary image indicating whether a given pixel is part of the silhouette.