Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
testGenericTrackerCAOParsing.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 * Test MBT CAO parsing.
33 *
34*****************************************************************************/
35
36#include <visp3/core/vpConfig.h>
37
38#if defined(VISP_HAVE_CATCH2) && (VISP_HAVE_DATASET_VERSION >= 0x030400)
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{
50 const std::string cao_filename = vpIoTools::createFilePath(ipath, "mbt-cao/cylinder_cao_model_linux_line_ending.cao");
51 vpMbGenericTracker tracker;
52 const bool verbose = true;
53 REQUIRE_NOTHROW(tracker.loadModel(cao_filename, verbose));
54
55 std::list<vpMbtDistanceCylinder *> cylinders;
56 tracker.getLcylinder(cylinders);
57 CHECK(cylinders.size() == 1);
58
59 std::list<vpMbtDistanceCircle *> circles;
60 tracker.getLcircle(circles);
61 CHECK(circles.size() == 1);
62}
63
64TEST_CASE("vpMbGenericTracker load CAO model Windows line ending", "[vpMbGenericTracker CAO parsing]")
65{
66 const std::string cao_filename =
67 vpIoTools::createFilePath(ipath, "mbt-cao/cylinder_cao_model_windows_line_ending.cao");
68 vpMbGenericTracker tracker;
69 const bool verbose = true;
70 REQUIRE_NOTHROW(tracker.loadModel(cao_filename, verbose));
71
72 std::list<vpMbtDistanceCylinder *> cylinders;
73 tracker.getLcylinder(cylinders);
74 CHECK(cylinders.size() == 1);
75
76 std::list<vpMbtDistanceCircle *> circles;
77 tracker.getLcircle(circles);
78 CHECK(circles.size() == 1);
79}
80
81int main(int argc, char *argv[])
82{
83 Catch::Session session; // There must be exactly one instance
84
85 // Let Catch (using Clara) parse the command line
86 session.applyCommandLine(argc, argv);
87
88 int numFailed = session.run();
89
90 // numFailed is clamped to 255 as some unices only use the lower 8 bits.
91 // This clamping has already been applied, so just return it here
92 // You can also do any post run clean-up here
93 return numFailed;
94}
95#else
96#include <iostream>
97
98int main() { return EXIT_SUCCESS; }
99#endif
static std::string getViSPImagesDataPath()
static std::string createFilePath(const std::string &parent, const std::string &child)
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())