Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpMomentGravityCenterNormalized.cpp
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
* Description:
31
* 2D normalized gravity center moment descriptor (usually described by the
32
*pair Xn,Yn)
33
*
34
* Authors:
35
* Filip Novotny
36
*/
37
38
#include <visp3/core/vpMomentAreaNormalized.h>
39
#include <visp3/core/vpMomentGravityCenter.h>
40
#include <visp3/core/vpMomentGravityCenterNormalized.h>
41
#include <visp3/core/vpMomentObject.h>
42
43
BEGIN_VISP_NAMESPACE
48
void
vpMomentGravityCenterNormalized::compute
()
49
{
50
bool
found_moment_gravity;
51
bool
found_moment_surface_normalized;
52
53
const
vpMomentAreaNormalized
&momentSurfaceNormalized =
static_cast<
const
vpMomentAreaNormalized
&
>
(
54
getMoments
().
get
(
"vpMomentAreaNormalized"
, found_moment_surface_normalized));
55
const
vpMomentGravityCenter
&momentGravity =
56
static_cast<
const
vpMomentGravityCenter
&
>
(
getMoments
().
get
(
"vpMomentGravityCenter"
, found_moment_gravity));
57
58
if
(!found_moment_surface_normalized)
59
throw
vpException
(
vpException::notInitialized
,
"vpMomentAreaNormalized not found"
);
60
if
(!found_moment_gravity)
61
throw
vpException
(
vpException::notInitialized
,
"vpMomentGravityCenter not found"
);
62
63
double
Xn = momentGravity.
get
()[0] * momentSurfaceNormalized.
get
()[0];
64
double
Yn = momentGravity.
get
()[1] * momentSurfaceNormalized.
get
()[0];
65
66
values
[0] = Xn;
67
values
[1] = Yn;
68
}
69
73
vpMomentGravityCenterNormalized::vpMomentGravityCenterNormalized
() :
vpMomentGravityCenter
() { }
74
80
void
vpMomentGravityCenterNormalized::printDependencies
(std::ostream &os)
const
81
{
82
os << (__FILE__) << std::endl;
83
bool
found_moment_gravity;
84
bool
found_moment_surface_normalized;
85
86
const
vpMomentAreaNormalized
&momentSurfaceNormalized =
static_cast<
const
vpMomentAreaNormalized
&
>
(
87
getMoments
().
get
(
"vpMomentAreaNormalized"
, found_moment_surface_normalized));
88
const
vpMomentGravityCenter
&momentGravity =
89
static_cast<
const
vpMomentGravityCenter
&
>
(
getMoments
().
get
(
"vpMomentGravityCenter"
, found_moment_gravity));
90
91
if
(!found_moment_surface_normalized)
92
throw
vpException
(
vpException::notInitialized
,
"vpMomentAreaNormalized not found"
);
93
if
(!found_moment_gravity)
94
throw
vpException
(
vpException::notInitialized
,
"vpMomentGravityCenter not found"
);
95
os <<
"Xg = "
<< momentGravity.
get
()[0] <<
"\t"
96
<<
"Yg = "
<< momentGravity.
get
()[1] << std::endl;
97
os <<
"An = "
<< momentSurfaceNormalized.
get
()[0] << std::endl;
98
}
99
103
VISP_EXPORT std::ostream &
operator<<
(std::ostream &os,
const
vpMomentGravityCenterNormalized
&m)
104
{
105
os << (__FILE__) << std::endl;
106
os <<
"(Xn,Yn) = ("
<< m.
values
[0] <<
", "
<< m.
values
[1] <<
")"
<< std::endl;
107
return
os;
108
}
109
END_VISP_NAMESPACE
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpException::notInitialized
@ notInitialized
Used to indicate that a parameter is not initialized.
Definition
vpException.h:74
vpMomentAreaNormalized
Class handling the normalized surface moment that is invariant in scale and used to estimate depth.
Definition
vpMomentAreaNormalized.h:139
vpMomentDatabase::get
const vpMoment & get(const std::string &moment_name, bool &found) const
Definition
vpMomentDatabase.cpp:63
vpMomentGravityCenterNormalized::vpMomentGravityCenterNormalized
vpMomentGravityCenterNormalized()
Definition
vpMomentGravityCenterNormalized.cpp:73
vpMomentGravityCenterNormalized::printDependencies
void printDependencies(std::ostream &os) const VP_OVERRIDE
Definition
vpMomentGravityCenterNormalized.cpp:80
vpMomentGravityCenterNormalized::compute
void compute() VP_OVERRIDE
Definition
vpMomentGravityCenterNormalized.cpp:48
vpMomentGravityCenterNormalized::operator<<
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpMomentGravityCenterNormalized &v)
Definition
vpMomentGravityCenterNormalized.cpp:103
vpMomentGravityCenter::vpMomentGravityCenter
vpMomentGravityCenter()
Definition
vpMomentGravityCenter.cpp:54
vpMomentGravityCenter::get
const std::vector< double > & get() const
Definition
vpMomentGravityCenter.cpp:60
vpMoment::values
std::vector< double > values
Definition
vpMoment.h:113
vpMoment::getMoments
vpMomentDatabase & getMoments() const
Definition
vpMoment.h:118
vpMoment::get
const std::vector< double > & get() const
Definition
vpMoment.h:155
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
core
src
tracking
moments
vpMomentGravityCenterNormalized.cpp
Generated by
1.17.0