Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpFeatureBuilderPointPolar.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
* Conversion between tracker and visual feature point with
32
* polar coordinates.
33
*/
34
41
#include <visp3/core/vpDebug.h>
42
#include <visp3/core/vpException.h>
43
#include <visp3/visual_features/vpFeatureBuilder.h>
44
#include <visp3/visual_features/vpFeatureException.h>
45
46
BEGIN_VISP_NAMESPACE
47
#ifdef VISP_HAVE_MODULE_BLOB
99
void
vpFeatureBuilder::create
(
vpFeaturePointPolar
&s,
const
vpCameraParameters
&cam,
const
vpDot
&dot)
100
{
101
try
{
102
double
x = 0, y = 0;
103
104
vpImagePoint
cog;
105
cog = dot.
getCog
();
106
107
vpPixelMeterConversion::convertPoint
(cam, cog, x, y);
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
}
115
catch
(...) {
116
vpERROR_TRACE
(
"Error caught"
);
117
throw
;
118
}
119
}
120
172
void
vpFeatureBuilder::create
(
vpFeaturePointPolar
&s,
const
vpCameraParameters
&cam,
const
vpDot2
&dot)
173
{
174
try
{
175
double
x = 0, y = 0;
176
177
vpImagePoint
cog;
178
cog = dot.
getCog
();
179
180
vpPixelMeterConversion::convertPoint
(cam, cog, x, y);
181
182
double
rho = sqrt(x * x + y * y);
183
double
theta = atan2(y, x);
184
185
s.set_rho(rho);
186
s.set_theta(theta);
187
}
188
catch
(...) {
189
vpERROR_TRACE
(
"Error caught"
);
190
throw
;
191
}
192
}
193
#endif
//#ifdef VISP_HAVE_MODULE_BLOB
194
244
void
vpFeatureBuilder::create
(
vpFeaturePointPolar
&s,
const
vpCameraParameters
&cam,
const
vpImagePoint
&iP)
245
{
246
try
{
247
double
x = 0, y = 0;
248
249
vpPixelMeterConversion::convertPoint
(cam, iP, x, y);
250
251
double
rho = sqrt(x * x + y * y);
252
double
theta = atan2(y, x);
253
254
s.set_rho(rho);
255
s.set_theta(theta);
256
}
257
catch
(...) {
258
vpERROR_TRACE
(
"Error caught"
);
259
throw
;
260
}
261
}
262
281
void
vpFeatureBuilder::create
(
vpFeaturePointPolar
&s,
const
vpPoint
&p)
282
{
283
try
{
284
285
double
x = p.get_x();
286
double
y = p.get_y();
287
288
double
rho = sqrt(x * x + y * y);
289
double
theta = atan2(y, x);
290
291
s.set_rho(rho);
292
s.set_theta(theta);
293
294
s.set_Z(p.get_Z());
295
296
if
(s.get_Z() < 0) {
297
vpERROR_TRACE
(
"Point is behind the camera "
);
298
std::cout <<
"Z = "
<< s.get_Z() << std::endl;
299
300
throw
(
vpFeatureException
(
vpFeatureException::badInitializationError
,
"Point is behind the camera "
));
301
}
302
303
if
(fabs(s.get_Z()) < 1e-6) {
304
vpERROR_TRACE
(
"Point Z coordinates is null "
);
305
std::cout <<
"Z = "
<< s.get_Z() << std::endl;
306
307
throw
(
vpFeatureException
(
vpFeatureException::badInitializationError
,
"Point Z coordinates is null"
));
308
}
309
310
}
311
catch
(...) {
312
vpERROR_TRACE
(
"Error caught"
);
313
throw
;
314
}
315
}
316
350
void
vpFeatureBuilder::create
(
vpFeaturePointPolar
&s,
const
vpCameraParameters
&goodCam,
351
const
vpCameraParameters
&wrongCam,
const
vpPoint
&p)
352
{
353
try
{
354
double
x = p.get_x();
355
double
y = p.get_y();
356
357
s.set_Z(p.get_Z());
358
359
double
u = 0, v = 0;
360
vpMeterPixelConversion::convertPoint
(goodCam, x, y, u, v);
361
vpPixelMeterConversion::convertPoint
(wrongCam, u, v, x, y);
362
363
double
rho = sqrt(x * x + y * y);
364
double
theta = atan2(y, x);
365
366
s.set_rho(rho);
367
s.set_theta(theta);
368
}
369
catch
(...) {
370
vpERROR_TRACE
(
"Error caught"
);
371
throw
;
372
}
373
}
374
END_VISP_NAMESPACE
375
/*
376
* Local variables:
377
* c-basic-offset: 2
378
* End:
379
*/
vpCameraParameters
Generic class defining intrinsic camera parameters.
Definition
vpCameraParameters.h:311
vpDot2
This tracker is meant to track a blob (connex pixels with same gray level) on a vpImage.
Definition
vpDot2.h:127
vpDot2::getCog
vpImagePoint getCog() const
Definition
vpDot2.h:183
vpDot
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage.
Definition
vpDot.h:123
vpDot::getCog
vpImagePoint getCog() const
Definition
vpDot.h:255
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
vpFeatureException::badInitializationError
@ badInitializationError
Wrong feature initialization.
Definition
vpFeatureException.h:70
vpFeaturePointPolar
Class that defines 2D image point visual feature with polar coordinates described in corke09a.
Definition
vpFeaturePointPolar.h:262
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpMeterPixelConversion::convertPoint
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
Definition
vpMeterPixelConversion.h:105
vpPixelMeterConversion::convertPoint
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Definition
vpPixelMeterConversion.h:108
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
vpERROR_TRACE
#define vpERROR_TRACE
Definition
vpDebug.h:423
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
visual_features
src
feature-builder
vpFeatureBuilderPointPolar.cpp
Generated by
1.17.0