31#include <visp3/rbt/vpRBDenseDepthTracker.h>
32#include <visp3/core/vpMeterPixelConversion.h>
33#include <visp3/core/vpDisplay.h>
34#include <visp3/core/vpUniRand.h>
36#ifdef VISP_HAVE_OPENMP
43void fastProjection(
const vpHomogeneousMatrix &oTc,
double X,
double Y,
double Z, std::array<double, 3> &p)
45 const double *T = oTc.
data;
46 p[0] = (T[0] * X + T[1] * Y + T[2] * Z + T[3]);
47 p[1] = (T[4] * X + T[5] * Y + T[6] * Z + T[7]);
48 p[2] = (T[8] * X + T[9] * Y + T[10] * Z + T[11]);
51double dotProd3(
const vpColVector &a,
const std::array<double, 3> &b)
53 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
71 std::vector<std::vector<vpDepthPoint>> pointsPerThread;
73#ifdef VISP_HAVE_OPENMP
77#ifdef VISP_HAVE_OPENMP
80 unsigned int numThreads = omp_get_num_threads();
81 pointsPerThread.resize(numThreads);
85 pointsPerThread.resize(1);
89#ifdef VISP_HAVE_OPENMP
90 unsigned int threadIdx = omp_get_thread_num();
92 unsigned int threadIdx = 0;
96#ifdef VISP_HAVE_OPENMP
97 std::vector<vpDepthPoint> localPoints;
98 localPoints.reserve(
m_depthPoints.capacity() / omp_get_num_threads());
104#ifdef VISP_HAVE_OPENMP
107 for (
auto i =
static_cast<int>(bb.getTop()); i <
static_cast<int>(bb.getBottom()); i +=
m_step) {
108 for (
auto j =
static_cast<int>(bb.getLeft()); j <
static_cast<int>(bb.getRight()); j +=
m_step) {
109 const double Z = renderDepth[i][j];
110 const double currZ = depthMap[i][j];
112 if (Z > 0.f && currZ > 0.f) {
116 double x = 0.0, y = 0.0;
117 vpPixelMeterConversion::convertPointWithoutDistortion(frame.
cam, j, i, x, y);
123 bool invalidNormal =
false;
124 for (
unsigned int oi = 0; oi < 3; ++oi) {
126 invalidNormal =
true;
134 fastProjection(oMc, x * Z, y * Z, Z, point.
oX);
136 cameraRay = { co[0] - point.
oX[0], co[1] - point.
oX[1], co[2] - point.
oX[2] };
150 localPoints.push_back(point);
155 pointsPerThread[threadIdx] = std::move(localPoints);
157 for (
const std::vector<vpDepthPoint> &points: pointsPerThread) {
163 std::vector<vpDepthPoint> finalPoints;
164 for (
size_t index : indices) {
176 m_L.resize(
static_cast<unsigned int>(
m_depthPoints.size()), 6,
false,
false);
177 m_cov.resize(6, 6,
false,
false);
190 const unsigned int minNumFeatures =
m_maxFeatures > 0 ? std::min(
m_maxFeatures * 0.05, minBBSamples * 0.05) : minBBSamples * 0.05;
234 double maxError =
m_error.getMaxValue();
236 vpColor c(
static_cast<unsigned int>((
m_error[i] / maxError) * 255), 0, 0);
243 double maxError =
m_error.getMaxValue();
245 vpColor c(
static_cast<unsigned int>((
m_error[i] / maxError) * 255.0),
static_cast<unsigned char>(
m_weights[i] * 255), 0);
Type * data
Address of the first element of the data array.
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
vpColVector & normalize()
Class to define RGB colors available for display functionalities.
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
error that can be emitted by ViSP classes.
@ notImplementedError
Not implemented.
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpTranslationVector getTranslationVector() const
Definition of the vpImage class member functions.
static double rad(double deg)
static bool isFinite(double value)
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpImage< vpRGBa > &IRGB, const vpImage< unsigned char > &depth) const VP_OVERRIDE
vpDepthPointSet m_depthPointSet
unsigned int m_maxFeatures
std::vector< vpDepthPoint > m_depthPoints
float m_minMaskConfidence
void computeVVSIter(const vpRBFeatureTrackerInput &frame, const vpHomogeneousMatrix &cMo, unsigned int iteration) VP_OVERRIDE
void extractFeatures(const vpRBFeatureTrackerInput &frame, const vpRBFeatureTrackerInput &previousFrame, const vpHomogeneousMatrix &cMo) VP_OVERRIDE
Extract features from the frame data and the current pose estimate.
vpDisplayType m_displayType
void updateOptimizerTerms(const vpHomogeneousMatrix &cMo)
vpColVector m_weights
Weighted VS error.
vpMatrix m_LTL
Error jacobian (In VS terms, the interaction matrix).
vpColVector m_covWeightDiag
Covariance matrix.
vpColVector m_LTR
Left side of the Gauss newton minimization.
unsigned m_numFeatures
Error weights.
vpColVector m_weighted_error
Raw VS Error vector.
vpMatrix m_cov
Right side of the Gauss Newton minimization.
Defines a rectangle in the plane.
@ TUKEY
Tukey influence function.
Implementation of a rotation matrix and operations on such kind of matrices.
Class that consider the case of a translation vector.
Class for generating random numbers with uniform probability density.
std::vector< size_t > sampleWithoutReplacement(size_t count, size_t vectorSize)
std::array< double, 2 > pixelPos
std::array< double, 3 > oX
std::array< double, 3 > objectNormal
std::array< double, 3 > observation
double zNear
Binary image indicating whether a given pixel is part of the silhouette.
vpImage< float > depth
Image containing the per-pixel normal vector (RGB, in object space).
vpImage< vpRGBf > normals