Visual Servoing Platform version 3.5.0
testPoint.cpp
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5 *
6 * This software is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See http://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * Description:
32 * Performs various tests on the point class.
33 *
34 * Authors:
35 * Eric Marchand
36 *
37 *****************************************************************************/
38
44#include <visp3/core/vpDebug.h>
45#include <visp3/core/vpHomogeneousMatrix.h>
46#include <visp3/core/vpMath.h>
47#include <visp3/core/vpPoint.h>
48#include <visp3/visual_features/vpFeatureBuilder.h>
49#include <visp3/visual_features/vpFeatureException.h>
50#include <visp3/visual_features/vpFeaturePoint.h>
51
52#include <stdio.h>
53#include <stdlib.h>
54
55int main()
56{
57 try {
59 cMo[0][3] = 0.1;
60 cMo[1][3] = 0.2;
61 cMo[2][3] = 2;
62
63 vpPoint point;
64 vpTRACE("set point coordinates in the world frame ");
65 point.setWorldCoordinates(0, 0, 0);
66
67 std::cout << "------------------------------------------------------" << std::endl;
68 vpTRACE("test the projection ");
69 point.track(cMo);
70
71 vpTRACE("coordinates in the world frame ");
72 std::cout << point.oP.t() << std::endl;
73 vpTRACE("coordinates in the camera frame ");
74 std::cout << point.cP.t() << std::endl;
75
76 vpTRACE("2D coordinates ");
77 std::cout << point.get_x() << " " << point.get_y() << std::endl;
78
79 std::cout << "------------------------------------------------------" << std::endl;
80 vpTRACE("test the interaction matrix ");
81
84
85 vpMatrix L;
86 L = p.interaction();
87 std::cout << L << std::endl;
88
89 vpTRACE("test the interaction matrix select");
90 vpTRACE("\t only X");
92 std::cout << L << std::endl;
93
94 vpTRACE("\t only Y");
96 std::cout << L << std::endl;
97
98 vpTRACE("\t X & Y");
100 std::cout << L << std::endl;
101
102 vpTRACE("\t selectAll");
104 std::cout << L << std::endl;
105
106 std::cout << "------------------------------------------------------" << std::endl;
107 vpTRACE("test the error ");
108
109 try {
111 pd.set_x(0);
112 pd.set_y(0);
113
114 pd.print();
115 std::cout << std::endl;
116 vpColVector e;
117 e = p.error(pd);
118 std::cout << e << std::endl;
119
120 vpTRACE("test the interaction matrix select");
121 vpTRACE("\t only X");
122 e = p.error(pd, vpFeaturePoint::selectX());
123 std::cout << e << std::endl;
124
125 vpTRACE("\t only Y");
126 e = p.error(pd, vpFeaturePoint::selectY());
127 std::cout << e << std::endl;
128
129 vpTRACE("\t X & Y");
131 std::cout << e << std::endl;
132
133 vpTRACE("\t selectAll");
134 e = p.error(pd, vpFeaturePoint::selectAll());
135 std::cout << e << std::endl;
136 } catch (vpFeatureException &me) {
137 std::cout << me << std::endl;
138 } catch (const vpException &me) {
139 std::cout << me << std::endl;
140 }
141 std::cout << "------------------------------------------------------" << std::endl;
142 vpTRACE("test the dimension");
143 unsigned int dim;
144 dim = p.getDimension();
145 std::cout << "Dimension = " << dim << std::endl;
146
147 vpTRACE("test the dimension with select");
148 vpTRACE("\t only X");
150 std::cout << "Dimension = " << dim << std::endl;
151
152 vpTRACE("\t only Y");
154 std::cout << "Dimension = " << dim << std::endl;
155
156 vpTRACE("\t X & Y");
158 std::cout << "Dimension = " << dim << std::endl;
159
160 vpTRACE("\t selectAll");
162 std::cout << "Dimension = " << dim << std::endl;
163 return 0;
164 } catch (const vpException &e) {
165 std::cout << "Catch an exception: " << e << std::endl;
166 return 1;
167 }
168}
static unsigned int selectAll()
Select all the features.
unsigned int getDimension(unsigned int select=FEATURE_ALL) const
Get the feature vector dimension.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
vpRowVector t() const
error that can be emited by ViSP classes.
Definition: vpException.h:72
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Error that can be emited by the vpBasicFeature class and its derivates.
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
static unsigned int selectX()
vpColVector error(const vpBasicFeature &s_star, unsigned int select=FEATURE_ALL)
static unsigned int selectY()
void set_y(double y)
void set_x(double x)
void print(unsigned int select=FEATURE_ALL) const
vpMatrix interaction(unsigned int select=FEATURE_ALL)
void track(const vpHomogeneousMatrix &cMo)
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:154
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:82
double get_y() const
Get the point y coordinate in the image plane.
Definition: vpPoint.cpp:472
double get_x() const
Get the point x coordinate in the image plane.
Definition: vpPoint.cpp:470
void setWorldCoordinates(double oX, double oY, double oZ)
Definition: vpPoint.cpp:113
vpColVector cP
Definition: vpTracker.h:77
#define vpTRACE
Definition: vpDebug.h:416