Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
catchGenericTrackerCAOParsing.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 MBT CAO parsing.
32  */
33 
38 #include <visp3/core/vpConfig.h>
39 
40 #if defined(VISP_HAVE_CATCH2) && (VISP_HAVE_DATASET_VERSION >= 0x030400)
41 
42 #include <visp3/core/vpIoTools.h>
43 #include <visp3/mbt/vpMbGenericTracker.h>
44 
45 #include <catch_amalgamated.hpp>
46 
47 #ifdef ENABLE_VISP_NAMESPACE
48 using namespace VISP_NAMESPACE_NAME;
49 #endif
50 
51 static std::string ipath = vpIoTools::getViSPImagesDataPath();
52 
53 TEST_CASE("vpMbGenericTracker load CAO model Linux line ending", "[vpMbGenericTracker CAO parsing]")
54 {
55  const std::string cao_filename = vpIoTools::createFilePath(ipath, "mbt-cao/cylinder_cao_model_linux_line_ending.cao");
56  vpMbGenericTracker tracker;
57  const bool verbose = true;
58  REQUIRE_NOTHROW(tracker.loadModel(cao_filename, verbose));
59 
60  std::list<vpMbtDistanceCylinder *> cylinders;
61  tracker.getLcylinder(cylinders);
62  CHECK(cylinders.size() == 1);
63 
64  std::list<vpMbtDistanceCircle *> circles;
65  tracker.getLcircle(circles);
66  CHECK(circles.size() == 1);
67 }
68 
69 TEST_CASE("vpMbGenericTracker load CAO model Windows line ending", "[vpMbGenericTracker CAO parsing]")
70 {
71  const std::string cao_filename =
72  vpIoTools::createFilePath(ipath, "mbt-cao/cylinder_cao_model_windows_line_ending.cao");
73  vpMbGenericTracker tracker;
74  const bool verbose = true;
75  REQUIRE_NOTHROW(tracker.loadModel(cao_filename, verbose));
76 
77  std::list<vpMbtDistanceCylinder *> cylinders;
78  tracker.getLcylinder(cylinders);
79  CHECK(cylinders.size() == 1);
80 
81  std::list<vpMbtDistanceCircle *> circles;
82  tracker.getLcircle(circles);
83  CHECK(circles.size() == 1);
84 }
85 
86 int main(int argc, char *argv[])
87 {
88  Catch::Session session;
89  session.applyCommandLine(argc, argv);
90  int numFailed = session.run();
91  return numFailed;
92 }
93 
94 #else
95 #include <iostream>
96 
97 int main() { return EXIT_SUCCESS; }
98 #endif
static std::string getViSPImagesDataPath()
Definition: vpIoTools.cpp:1053
static std::string createFilePath(const std::string &parent, const std::string &child)
Definition: vpIoTools.cpp:1427
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()) VP_OVERRIDE