31#include <visp3/rbt/vpRBConvergenceMetric.h>
33#ifdef VISP_HAVE_NLOHMANN_JSON
34#include VISP_NLOHMANN_JSON(json_fwd.hpp)
38 const std::string key = j.at(
"type");
39 double renderThreshold = j.value(
"renderThreshold", 0.0);
40 double convergenceThreshold = j.value(
"convergenceThreshold", 0.0);
41 unsigned int numPoints = j.value(
"samples", 0);
42 unsigned int seed = j.value(
"seed", 42);
44 if (key ==
"reprojection") {
45 return std::make_shared<vpRBConvergenceReprojectionMetric>(renderThreshold, convergenceThreshold, numPoints, seed);
47 else if (key ==
"add") {
48 return std::make_shared<vpRBConvergenceADDMetric>(renderThreshold, convergenceThreshold, numPoints, seed);
62 for (
unsigned int i = 0; i < numPoints; ++i) {
74 for (
unsigned int i = 0; i < oX.
getRows(); ++i) {
75 for (
unsigned int j = 0; j < 3; ++j) {
76 oX[i][j] =
m_random() * (maxAxes[j] - minAxes[j]) + minAxes[j];
80 std::vector<int> removed;
83 m_map.updatePoints(empty, oX, normals, removed, added);
84 if (added !=
m_map.getNumMaxPoints()) {
99 m_map.project(cTo1, X1);
100 m_map.project(cTo2, X2);
106 for (
unsigned int i = 0; i < X1.
getRows(); ++i) {
113 return error /
static_cast<double>(X1.
getRows());
127 for (
unsigned int i = 0; i < uv1.
getRows(); ++i) {
128 double d = sqrtf((uv1[i][0] - uv2[i][0]) +
vpMath::sqr(uv1[i][1] - uv2[i][1]));
133 return error /
static_cast<double>(uv1.
getRows());
Implementation of a generic 2D array used as base class for matrices and vectors.
unsigned int getRows() const
Generic class defining intrinsic camera parameters.
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
@ dimensionError
Bad dimension.
Implementation of an homogeneous matrix and operations on such kind of matrices.
static bool isNaN(double value)
static double sqr(double x)
Implementation of a matrix and operations on matrices.
Single object focused renderer.
void get3DExtents(vpTranslationVector &minValues, vpTranslationVector &maxValues)
double operator()(const vpCameraParameters &, const vpHomogeneousMatrix &cTo1, const vpHomogeneousMatrix &cTo2) VP_OVERRIDE
vpRBConvergenceADDMetric(double renderThreshold, double convergedThreshold, unsigned int numPoints, unsigned int seed)
vpRBConvergenceMetric(double renderThreshold, double convergedThreshold, unsigned int numPoints, unsigned int seed)
double m_rerenderThreshold
vpArray2D< int > m_indices
double m_convergedThreshold
static std::shared_ptr< vpRBConvergenceMetric > loadFromJSON(const nlohmann::json &j)
void sampleObject(vpObjectCentricRenderer &renderer)
vpRBConvergenceReprojectionMetric(double renderThreshold, double convergedThreshold, unsigned int numPoints, unsigned int seed)
double operator()(const vpCameraParameters &cam, const vpHomogeneousMatrix &cTo1, const vpHomogeneousMatrix &cTo2) VP_OVERRIDE
Class that consider the case of a translation vector.