Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpFeatureBuilderPointPolar.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 with
33 * polar coordinates.
34 *
35*****************************************************************************/
36
43#include <visp3/core/vpException.h>
44#include <visp3/visual_features/vpFeatureBuilder.h>
45#include <visp3/visual_features/vpFeatureException.h>
46
47#ifdef VISP_HAVE_MODULE_BLOB
100{
101 try {
102 double x = 0, y = 0;
103
104 vpImagePoint cog;
105 cog = dot.getCog();
106
108
109 double rho = sqrt(x * x + y * y);
110 double theta = atan2(y, x);
111
112 s.set_rho(rho);
113 s.set_theta(theta);
114 } catch (...) {
115 vpERROR_TRACE("Error caught");
116 throw;
117 }
118}
119
172{
173 try {
174 double x = 0, y = 0;
175
176 vpImagePoint cog;
177 cog = dot.getCog();
178
180
181 double rho = sqrt(x * x + y * y);
182 double theta = atan2(y, x);
183
184 s.set_rho(rho);
185 s.set_theta(theta);
186 } catch (...) {
187 vpERROR_TRACE("Error caught");
188 throw;
189 }
190}
191#endif //#ifdef VISP_HAVE_MODULE_BLOB
192
243{
244 try {
245 double x = 0, y = 0;
246
248
249 double rho = sqrt(x * x + y * y);
250 double theta = atan2(y, x);
251
252 s.set_rho(rho);
253 s.set_theta(theta);
254 } catch (...) {
255 vpERROR_TRACE("Error caught");
256 throw;
257 }
258}
259
279{
280 try {
281
282 double x = p.get_x();
283 double y = p.get_y();
284
285 double rho = sqrt(x * x + y * y);
286 double theta = atan2(y, x);
287
288 s.set_rho(rho);
289 s.set_theta(theta);
290
291 s.set_Z(p.get_Z());
292
293 if (s.get_Z() < 0) {
294 vpERROR_TRACE("Point is behind the camera ");
295 std::cout << "Z = " << s.get_Z() << std::endl;
296
297 throw(vpFeatureException(vpFeatureException::badInitializationError, "Point is behind the camera "));
298 }
299
300 if (fabs(s.get_Z()) < 1e-6) {
301 vpERROR_TRACE("Point Z coordinates is null ");
302 std::cout << "Z = " << s.get_Z() << std::endl;
303
304 throw(vpFeatureException(vpFeatureException::badInitializationError, "Point Z coordinates is null"));
305 }
306
307 } catch (...) {
308 vpERROR_TRACE("Error caught");
309 throw;
310 }
311}
312
347 const vpCameraParameters &wrongCam, const vpPoint &p)
348{
349 try {
350 double x = p.get_x();
351 double y = p.get_y();
352
353 s.set_Z(p.get_Z());
354
355 double u = 0, v = 0;
356 vpMeterPixelConversion::convertPoint(goodCam, x, y, u, v);
357 vpPixelMeterConversion::convertPoint(wrongCam, u, v, x, y);
358
359 double rho = sqrt(x * x + y * y);
360 double theta = atan2(y, x);
361
362 s.set_rho(rho);
363 s.set_theta(theta);
364 } catch (...) {
365 vpERROR_TRACE("Error caught");
366 throw;
367 }
368}
369
370/*
371 * Local variables:
372 * c-basic-offset: 2
373 * End:
374 */
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
vpImagePoint getCog() const
Definition vpDot2.h:177
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.
Definition vpDot.h:112
vpImagePoint getCog() const
Definition vpDot.h:243
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 2D image point visual feature with polar coordinates described in .
void set_theta(double theta)
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
double get_Z() const
Get the point cZ coordinate in the camera frame.
Definition vpPoint.cpp:453
#define vpERROR_TRACE
Definition vpDebug.h:388