MRPT  1.9.9
RawlogGrabberApp_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
12 #include <mrpt/config.h>
13 #include <mrpt/system/filesystem.h>
14 #include <test_mrpt_common.h>
15 
16 #if MRPT_HAS_FFMPEG && MRPT_HAS_OPENCV
17 TEST(RawlogGrabberApp, CGenericCamera_AVI)
18 #else
19 TEST(RawlogGrabberApp, DISABLED_CGenericCamera_AVI)
20 #endif
21 {
22  using namespace std::string_literals;
23 
25  mrpt::UNITTEST_BASEDIR +
26  "/share/mrpt/config_files/rawlog-grabber/camera_ffmpeg_video_file.ini"s;
28 
30  mrpt::UNITTEST_BASEDIR + "/share/mrpt/datasets/dummy_video.avi"s;
32 
33  try
34  {
37 
38  const char* argv[] = {"rawlog-grabber", ini_fil.c_str()};
39  const int argc = sizeof(argv) / sizeof(argv[0]);
40 
41  app.initialize(argc, argv);
42 
43  // Create output dir:
44  const auto out_dir = mrpt::system::getTempFileName() + "_dir"s;
46  THROW_EXCEPTION_FMT("Could not mkdir: `%s`", out_dir.c_str());
47 
48  app.params.write("global", "rawlog_prefix", out_dir + "/dataset"s);
49  app.params.write("Camera1", "ffmpeg_url", video_fil);
50 
51  // Run slowly, so we have time to capture a few frames from the
52  // (otherwise really short) test video file:
53  app.params.write("Camera1", "process_rate", "3.0");
54 
55  // Max. run time.
56  // Should end much sooner when the video file is entirely processed.
57  app.run_for_seconds = 20.0;
58 
59  // Less verbose output in tests:
61 
62  // Run:
63  app.run();
64 
65  // Check expected results:
66  EXPECT_GE(app.rawlog_saved_objects, 2U);
67  }
68  catch (const std::exception& e)
69  {
70  std::cerr << mrpt::exception_to_str(e);
71  GTEST_FAIL();
72  }
73 }
bool createDirectory(const std::string &dirName)
Creates a directory.
Definition: filesystem.cpp:161
const auto out_dir
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
Definition: filesystem.cpp:128
void setMinLoggingLevel(const VerbosityLevel level)
Set the minimum logging level for which the incoming logs are going to be taken into account...
const std::string video_fil
GLdouble s
Definition: glext.h:3682
bool show_sensor_thread_exceptions
If enabled (default), exceptions in sensor threads will be reported to std::cerr. ...
TEST(ICP_SLAM_App, MapFromRawlog_PointMap)
std::string getTempFileName()
Returns the name of a proposed temporary file name.
Definition: filesystem.cpp:283
void initialize(int argc, const char **argv)
Initializes the application from CLI parameters.
void run()
Runs with the current parameter set.
const std::string ini_fil
GLsizei const GLchar ** string
Definition: glext.h:4116
void write(const std::string &section, const std::string &name, enum_t value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string())
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
double run_for_seconds
If >0, run() will return after this period (in seconds)
const char * argv[]
std::size_t rawlog_saved_objects
Counter of saved objects.
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
Definition: exceptions.cpp:59
const int argc
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
Definition: exceptions.h:69
mrpt::config::CConfigFileMemory params
Populated in initialize().
RawlogGrabber application wrapper class.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ce444d842 Fri Dec 6 19:35:10 2019 +0100 at vie dic 6 19:45:12 CET 2019