Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testPoint.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 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
* Performs various tests on the point class.
32
*/
33
39
40
#include <visp3/core/vpDebug.h>
41
#include <visp3/core/vpHomogeneousMatrix.h>
42
#include <visp3/core/vpMath.h>
43
#include <visp3/core/vpPoint.h>
44
#include <visp3/visual_features/vpFeatureBuilder.h>
45
#include <visp3/visual_features/vpFeatureException.h>
46
#include <visp3/visual_features/vpFeaturePoint.h>
47
48
#include <stdio.h>
49
#include <stdlib.h>
50
51
int
main()
52
{
53
#ifdef ENABLE_VISP_NAMESPACE
54
using namespace
VISP_NAMESPACE_NAME
;
55
#endif
56
try
{
57
vpHomogeneousMatrix
cMo
;
58
cMo
[0][3] = 0.1;
59
cMo
[1][3] = 0.2;
60
cMo
[2][3] = 2;
61
62
vpPoint
point;
63
vpTRACE
(
"set point coordinates in the world frame "
);
64
point.
setWorldCoordinates
(0, 0, 0);
65
66
std::cout <<
"------------------------------------------------------"
<< std::endl;
67
vpTRACE
(
"test the projection "
);
68
point.
track
(cMo);
69
70
vpTRACE
(
"coordinates in the world frame "
);
71
std::cout << point.
oP
.
t
() << std::endl;
72
vpTRACE
(
"coordinates in the camera frame "
);
73
std::cout << point.
cP
.
t
() << std::endl;
74
75
vpTRACE
(
"2D coordinates "
);
76
std::cout << point.
get_x
() <<
" "
<< point.
get_y
() << std::endl;
77
78
std::cout <<
"------------------------------------------------------"
<< std::endl;
79
vpTRACE
(
"test the interaction matrix "
);
80
81
vpFeaturePoint
p
;
82
vpFeatureBuilder::create
(p, point);
83
84
vpMatrix
L;
85
L =
p
.interaction();
86
std::cout << L << std::endl;
87
88
vpTRACE
(
"test the interaction matrix select"
);
89
vpTRACE
(
"\t only X"
);
90
L =
p
.interaction(
vpFeaturePoint::selectX
());
91
std::cout << L << std::endl;
92
93
vpTRACE
(
"\t only Y"
);
94
L =
p
.interaction(
vpFeaturePoint::selectY
());
95
std::cout << L << std::endl;
96
97
vpTRACE
(
"\t X & Y"
);
98
L =
p
.interaction(
vpFeaturePoint::selectX
() |
vpFeaturePoint::selectY
());
99
std::cout << L << std::endl;
100
101
vpTRACE
(
"\t selectAll"
);
102
L =
p
.interaction(
vpFeaturePoint::selectAll
());
103
std::cout << L << std::endl;
104
105
std::cout <<
"------------------------------------------------------"
<< std::endl;
106
vpTRACE
(
"test the error "
);
107
108
try
{
109
vpFeaturePoint
pd;
110
pd.
set_x
(0);
111
pd.
set_y
(0);
112
113
pd.
print
();
114
std::cout << std::endl;
115
vpColVector
e
;
116
e
=
p
.error(pd);
117
std::cout <<
e
<< std::endl;
118
119
vpTRACE
(
"test the interaction matrix select"
);
120
vpTRACE
(
"\t only X"
);
121
e
=
p
.error(pd,
vpFeaturePoint::selectX
());
122
std::cout <<
e
<< std::endl;
123
124
vpTRACE
(
"\t only Y"
);
125
e
=
p
.error(pd,
vpFeaturePoint::selectY
());
126
std::cout <<
e
<< std::endl;
127
128
vpTRACE
(
"\t X & Y"
);
129
e
=
p
.error(pd,
vpFeaturePoint::selectX
() |
vpFeaturePoint::selectY
());
130
std::cout <<
e
<< std::endl;
131
132
vpTRACE
(
"\t selectAll"
);
133
e
=
p
.error(pd,
vpFeaturePoint::selectAll
());
134
std::cout <<
e
<< std::endl;
135
}
136
catch
(
vpFeatureException
&me) {
137
std::cout << me << std::endl;
138
}
139
catch
(
const
vpException
&me) {
140
std::cout << me << std::endl;
141
}
142
std::cout <<
"------------------------------------------------------"
<< std::endl;
143
vpTRACE
(
"test the dimension"
);
144
unsigned
int
dim;
145
dim =
p
.getDimension();
146
std::cout <<
"Dimension = "
<< dim << std::endl;
147
148
vpTRACE
(
"test the dimension with select"
);
149
vpTRACE
(
"\t only X"
);
150
dim =
p
.getDimension(
vpFeaturePoint::selectX
());
151
std::cout <<
"Dimension = "
<< dim << std::endl;
152
153
vpTRACE
(
"\t only Y"
);
154
dim =
p
.getDimension(
vpFeaturePoint::selectY
());
155
std::cout <<
"Dimension = "
<< dim << std::endl;
156
157
vpTRACE
(
"\t X & Y"
);
158
dim =
p
.getDimension(
vpFeaturePoint::selectX
() |
vpFeaturePoint::selectY
());
159
std::cout <<
"Dimension = "
<< dim << std::endl;
160
161
vpTRACE
(
"\t selectAll"
);
162
dim =
p
.getDimension(
vpFeaturePoint::selectAll
());
163
std::cout <<
"Dimension = "
<< dim << std::endl;
164
return
EXIT_SUCCESS;
165
}
166
catch
(
const
vpException
&e) {
167
std::cout <<
"Catch an exception: "
<<
e
<< std::endl;
168
return
EXIT_FAILURE;
169
}
170
}
vpBasicFeature::selectAll
static unsigned int selectAll()
Select all the features.
Definition
vpBasicFeature.h:140
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpColVector::t
vpRowVector t() const
Definition
vpColVector.cpp:558
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpFeatureBuilder::create
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Definition
vpFeatureBuilderPoint.cpp:90
vpFeatureException
Error that can be emitted by the vpBasicFeature class and its derivates.
Definition
vpFeatureException.h:55
vpFeaturePoint
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
Definition
vpFeaturePoint.h:190
vpFeaturePoint::selectX
static unsigned int selectX()
Definition
vpFeaturePoint.cpp:508
vpFeaturePoint::print
void print(unsigned int select=FEATURE_ALL) const VP_OVERRIDE
Definition
vpFeaturePoint.cpp:369
vpFeaturePoint::selectY
static unsigned int selectY()
Definition
vpFeaturePoint.cpp:528
vpFeaturePoint::set_y
void set_y(double y)
Definition
vpFeaturePoint.cpp:134
vpFeaturePoint::set_x
void set_x(double x)
Definition
vpFeaturePoint.cpp:114
vpForwardProjection::oP
vpColVector oP
Definition
vpForwardProjection.h:205
vpForwardProjection::track
void track(const vpHomogeneousMatrix &cMo)
Definition
vpForwardProjection.cpp:101
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition
vpHomogeneousMatrix.h:221
vpMatrix
Implementation of a matrix and operations on matrices.
Definition
vpMatrix.h:175
vpPoint
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition
vpPoint.h:79
vpPoint::get_y
double get_y() const
Get the point y coordinate in the image plane.
Definition
vpPoint.cpp:429
vpPoint::get_x
double get_x() const
Get the point x coordinate in the image plane.
Definition
vpPoint.cpp:427
vpPoint::setWorldCoordinates
void setWorldCoordinates(double oX, double oY, double oZ)
Definition
vpPoint.cpp:116
vpTracker::cP
vpColVector cP
Definition
vpTracker.h:73
vpTRACE
#define vpTRACE
Definition
vpDebug.h:450
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
ibvs-four-points.p
p
Definition
ibvs-four-points.py:280
ibvs-four-points.e
e
Definition
ibvs-four-points.py:272
realsense-mbt.cMo
cMo
Definition
realsense-mbt.py:212
modules
visual_features
test
feature
testPoint.cpp
Generated by
1.17.0