Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpRBConvergenceMetric.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 */
30
31#ifndef VP_RB_CONVERGENCE_METRIC_H
32#define VP_RB_CONVERGENCE_METRIC_H
33
34#include <visp3/core/vpConfig.h>
35#include <visp3/core/vpUniRand.h>
36
37#include <visp3/rbt/vpPointMap.h>
38#include <visp3/rbt/vpObjectCentricRenderer.h>
39
40#ifdef VISP_HAVE_NLOHMANN_JSON
41#include VISP_NLOHMANN_JSON(json_fwd.hpp)
42#endif
43
45class VISP_EXPORT vpRBConvergenceMetric
46{
47public:
48 vpRBConvergenceMetric(double renderThreshold, double convergedThreshold, unsigned int numPoints, unsigned int seed);
49 virtual ~vpRBConvergenceMetric() = default;
51 {
52 return (*this)(cam, cTo1, cTo2) > m_rerenderThreshold;
53 }
55 {
56 return (*this)(cam, cTo1, cTo2) < m_convergedThreshold;
57 }
58
61
62
63 void sampleObject(vpObjectCentricRenderer &renderer);
64
65 virtual double operator()(const vpCameraParameters &cam, const vpHomogeneousMatrix &cTo1, const vpHomogeneousMatrix &cTo2) = 0;
66
67#ifdef VISP_HAVE_NLOHMANN_JSON
68 static std::shared_ptr<vpRBConvergenceMetric> loadFromJSON(const nlohmann::json &j);
69#endif
70
71protected:
72 unsigned int m_seed;
76
79};
80
82{
83public:
84 vpRBConvergenceADDMetric(double renderThreshold, double convergedThreshold, unsigned int numPoints, unsigned int seed);
85 double operator()(const vpCameraParameters & /*cam*/, const vpHomogeneousMatrix &cTo1, const vpHomogeneousMatrix &cTo2) VP_OVERRIDE;
86};
87
89{
90public:
91 vpRBConvergenceReprojectionMetric(double renderThreshold, double convergedThreshold, unsigned int numPoints, unsigned int seed);
92 double operator()(const vpCameraParameters &cam, const vpHomogeneousMatrix &cTo1, const vpHomogeneousMatrix &cTo2) VP_OVERRIDE;
93};
94
95END_VISP_NAMESPACE
96
97#endif
Implementation of a generic 2D array used as base class for matrices and vectors.
Definition vpArray2D.h:146
Generic class defining intrinsic camera parameters.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Single object focused renderer.
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)
virtual double operator()(const vpCameraParameters &cam, const vpHomogeneousMatrix &cTo1, const vpHomogeneousMatrix &cTo2)=0
bool hasConverged(const vpCameraParameters &cam, const vpHomogeneousMatrix &cTo1, const vpHomogeneousMatrix &cTo2)
double getUpdateRenderThreshold() const
virtual ~vpRBConvergenceMetric()=default
bool shouldUpdateRender(const vpCameraParameters &cam, const vpHomogeneousMatrix &cTo1, const vpHomogeneousMatrix &cTo2)
static std::shared_ptr< vpRBConvergenceMetric > loadFromJSON(const nlohmann::json &j)
double getConvergenceThreshold() const
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 for generating random numbers with uniform probability density.
Definition vpUniRand.h:127