Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testXmlParserRectOriented.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
* Test vpXmlParserRectOriented parse / save.
32
*/
33
39
40
#include <visp3/core/vpIoTools.h>
41
#include <visp3/core/vpXmlParserRectOriented.h>
42
43
int
main()
44
{
45
#ifdef ENABLE_VISP_NAMESPACE
46
using namespace
VISP_NAMESPACE_NAME
;
47
#endif
48
#if defined(VISP_HAVE_PUGIXML)
49
50
std::string tmp_dir =
vpIoTools::getTempPath
() +
"/test_xml_parser_rect_oriented/"
;
51
52
vpIoTools::remove
(tmp_dir);
53
std::cout <<
"Create: "
<< tmp_dir << std::endl;
54
vpIoTools::makeDirectory
(tmp_dir);
55
56
vpRectOriented
rect_oriented(
vpImagePoint
(124.2489, 251.4513), 254.34, 413.04,
vpMath::rad
(41.367));
57
std::string
filename
= tmp_dir +
"test_write_rect_oriented.xml"
;
58
{
59
vpXmlParserRectOriented
xml;
60
xml.
setRectangle
(rect_oriented);
61
std::cout <<
"Write to: "
<<
filename
<< std::endl;
62
xml.
save
(filename);
63
}
64
65
vpRectOriented
rect_oriented_read;
66
{
67
vpXmlParserRectOriented
xml;
68
xml.
parse
(filename);
69
rect_oriented_read = xml.
getRectangle
();
70
71
double
eps = std::numeric_limits<double>::epsilon();
72
if
(rect_oriented.getCenter() != rect_oriented_read.
getCenter
() ||
73
!
vpMath::equal
(rect_oriented.getWidth(), rect_oriented_read.
getWidth
(), eps) ||
74
!
vpMath::equal
(rect_oriented.getHeight(), rect_oriented_read.
getHeight
(), eps) ||
75
!
vpMath::equal
(rect_oriented.getOrientation(), rect_oriented_read.
getOrientation
(), eps)) {
76
std::cerr <<
"Issue when parsing XML file: "
<<
filename
<< std::endl;
77
return
EXIT_FAILURE;
78
}
79
}
80
81
vpIoTools::remove
(tmp_dir);
82
#endif
83
84
return
EXIT_SUCCESS;
85
}
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpIoTools::getTempPath
static std::string getTempPath()
Definition
vpIoTools.cpp:206
vpIoTools::makeDirectory
static void makeDirectory(const std::string &dirname)
Definition
vpIoTools.cpp:567
vpIoTools::remove
static bool remove(const std::string &filename)
Definition
vpIoTools.cpp:940
vpMath::rad
static double rad(double deg)
Definition
vpMath.h:129
vpMath::equal
static bool equal(double x, double y, double threshold=0.001)
Definition
vpMath.h:470
vpRectOriented
Defines an oriented rectangle in the plane.
Definition
vpRectOriented.h:48
vpRectOriented::getHeight
double getHeight() const
Get the rectangle height.
Definition
vpRectOriented.cpp:206
vpRectOriented::getOrientation
double getOrientation() const
Get the rectangle orientation (rad).
Definition
vpRectOriented.cpp:224
vpRectOriented::getWidth
double getWidth() const
Get the rectangle width.
Definition
vpRectOriented.cpp:203
vpRectOriented::getCenter
vpImagePoint getCenter() const
Get the rectangle center point.
Definition
vpRectOriented.cpp:172
vpXmlParserRectOriented
XML parser to load and save an oriented rectangle in a file.
Definition
vpXmlParserRectOriented.h:100
vpXmlParserRectOriented::getRectangle
vpRectOriented getRectangle() const
Definition
vpXmlParserRectOriented.cpp:199
vpXmlParserRectOriented::setRectangle
void setRectangle(const vpRectOriented &rectangle)
Definition
vpXmlParserRectOriented.cpp:201
vpXmlParserRectOriented::save
void save(const std::string &filename, bool append=false)
Definition
vpXmlParserRectOriented.cpp:197
vpXmlParserRectOriented::parse
void parse(const std::string &filename)
Definition
vpXmlParserRectOriented.cpp:185
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
gen_java.filename
filename
Definition
gen_java.py:1294
modules
core
test
tools
geometry
testXmlParserRectOriented.cpp
Generated by
1.17.0