Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpFeatureBuilderPoint.cpp
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2023 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 https://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 * Conversion between tracker and visual feature point.
33 *
34*****************************************************************************/
35
41#include <visp3/core/vpException.h>
42#include <visp3/visual_features/vpFeatureBuilder.h>
43#include <visp3/visual_features/vpFeatureException.h>
44
45#ifdef VISP_HAVE_MODULE_BLOB
91{
92 try {
93 double x = 0, y = 0;
94
95 vpImagePoint cog;
96 cog = d.getCog();
97
99
100 s.set_x(x);
101 s.set_y(y);
102 } catch (...) {
103 vpERROR_TRACE("Error caught");
104 throw;
105 }
106}
107
151{
152 try {
153 double x = 0, y = 0;
154
155 vpImagePoint cog;
156 cog = d.getCog();
157
159
160 s.set_x(x);
161 s.set_y(y);
162 } catch (...) {
163 vpERROR_TRACE("Error caught");
164 throw;
165 }
166}
167#endif //#ifdef VISP_HAVE_MODULE_BLOB
168
212{
213 try {
214 double x = 0, y = 0;
215
217
218 s.set_x(x);
219 s.set_y(y);
220 } catch (...) {
221 vpERROR_TRACE("Error caught");
222 throw;
223 }
224}
225
241{
242 try {
243 s.set_x(p.get_x());
244 s.set_y(p.get_y());
245
246 s.set_Z(p.cP[2] / p.cP[3]);
247
248 if (s.get_Z() < 0) {
249 vpERROR_TRACE("Point is behind the camera ");
250 std::cout << "Z = " << s.get_Z() << std::endl;
251
252 throw(vpFeatureException(vpFeatureException::badInitializationError, "Point is behind the camera "));
253 }
254
255 if (fabs(s.get_Z()) < 1e-6) {
256 vpERROR_TRACE("Point Z coordinates is null ");
257 std::cout << "Z = " << s.get_Z() << std::endl;
258
259 throw(vpFeatureException(vpFeatureException::badInitializationError, "Point Z coordinates is null"));
260 }
261
262 } catch (...) {
263 vpERROR_TRACE("Error caught");
264 throw;
265 }
266}
267
300 const vpPoint &p)
301{
302 try {
303 double x = p.p[0];
304 double y = p.p[1];
305
306 s.set_Z(p.cP[2] / p.cP[3]);
307
308 double u = 0, v = 0;
309 vpMeterPixelConversion::convertPoint(goodCam, x, y, u, v);
310 vpPixelMeterConversion::convertPoint(wrongCam, u, v, x, y);
311
312 s.set_x(x);
313 s.set_y(y);
314 } catch (...) {
315 vpERROR_TRACE("Error caught");
316 throw;
317 }
318}
Generic class defining intrinsic camera parameters.
This tracker is meant to track a blob (connex pixels with same gray level) on a vpImage.
Definition vpDot2.h:124
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.
Definition vpDot.h:112
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Error that can be emitted by the vpBasicFeature class and its derivates.
@ badInitializationError
Wrong feature initialization.
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
void set_y(double y)
void set_x(double x)
double get_Z() const
void set_Z(double Z)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition vpPoint.h:77
double get_y() const
Get the point y coordinate in the image plane.
Definition vpPoint.cpp:469
double get_x() const
Get the point x coordinate in the image plane.
Definition vpPoint.cpp:467
vpColVector cP
Definition vpTracker.h:72
vpColVector p
Definition vpTracker.h:68
#define vpERROR_TRACE
Definition vpDebug.h:388