Visual Servoing Platform version 3.5.0
testGenericTrackerCAOParsing.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 * Test MBT CAO parsing.
33 *
34 *****************************************************************************/
35
36#include <visp3/core/vpConfig.h>
37
38#ifdef VISP_HAVE_CATCH2
39
40#include <visp3/core/vpIoTools.h>
41#include <visp3/mbt/vpMbGenericTracker.h>
42
43#define CATCH_CONFIG_RUNNER
44#include <catch.hpp>
45
46static std::string ipath = vpIoTools::getViSPImagesDataPath();
47
48TEST_CASE("vpMbGenericTracker load CAO model Linux line ending", "[vpMbGenericTracker CAO parsing]") {
49 const std::string cao_filename = vpIoTools::createFilePath(ipath, "mbt-cao/cylinder_cao_model_linux_line_ending.cao");
50 vpMbGenericTracker tracker;
51 const bool verbose = true;
52 REQUIRE_NOTHROW(tracker.loadModel(cao_filename, verbose));
53
54 std::list<vpMbtDistanceCylinder *> cylinders;
55 tracker.getLcylinder(cylinders);
56 CHECK(cylinders.size() == 1);
57
58 std::list<vpMbtDistanceCircle *> circles;
59 tracker.getLcircle(circles);
60 CHECK(circles.size() == 1);
61}
62
63TEST_CASE("vpMbGenericTracker load CAO model Windows line ending", "[vpMbGenericTracker CAO parsing]") {
64 const std::string cao_filename = vpIoTools::createFilePath(ipath, "mbt-cao/cylinder_cao_model_windows_line_ending.cao");
65 vpMbGenericTracker tracker;
66 const bool verbose = true;
67 REQUIRE_NOTHROW(tracker.loadModel(cao_filename, verbose));
68
69 std::list<vpMbtDistanceCylinder *> cylinders;
70 tracker.getLcylinder(cylinders);
71 CHECK(cylinders.size() == 1);
72
73 std::list<vpMbtDistanceCircle *> circles;
74 tracker.getLcircle(circles);
75 CHECK(circles.size() == 1);
76}
77
78int main(int argc, char *argv[])
79{
80 Catch::Session session; // There must be exactly one instance
81
82 // Let Catch (using Clara) parse the command line
83 session.applyCommandLine(argc, argv);
84
85 int numFailed = session.run();
86
87 // numFailed is clamped to 255 as some unices only use the lower 8 bits.
88 // This clamping has already been applied, so just return it here
89 // You can also do any post run clean-up here
90 return numFailed;
91}
92#else
93#include <iostream>
94
95int main()
96{
97 return 0;
98}
99#endif
static std::string getViSPImagesDataPath()
Definition: vpIoTools.cpp:1365
static std::string createFilePath(const std::string &parent, const std::string &child)
Definition: vpIoTools.cpp:1670
Real-time 6D object pose tracking using its CAD model.
virtual void getLcircle(std::list< vpMbtDistanceCircle * > &circlesList, unsigned int level=0) const
virtual void getLcylinder(std::list< vpMbtDistanceCylinder * > &cylindersList, unsigned int level=0) const
virtual void loadModel(const std::string &modelFile, bool verbose=false, const vpHomogeneousMatrix &T=vpHomogeneousMatrix())