MRPT  2.0.3
test.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-2020, 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 <mrpt/img/CImage.h>
12 #include <iostream>
13 
14 using namespace mrpt;
15 using namespace mrpt::vision;
16 using namespace mrpt::img;
17 using namespace std;
18 
19 /* ------------------------------------------------------------------------
20  Test_VideoFile
21  ------------------------------------------------------------------------ */
22 void Test_VideoFile()
23 {
24  CVideoFileWriter vid;
25 
26  cout << "Creating test.avi..." << endl;
27 
28  const int W = 352;
29  const int H = 288;
30 
31  vid.open("test.avi", 15, TImageSize(W, H)); // Use default codec
32  // vid.open("test.avi",15,TImageSize(W,H),"XVID");
33 
34  for (int i = 1; i < 100; i++)
35  {
36  CImage img(W, H);
37 
38  img.rectangle(0, 0, 320, 200, TColor::black());
39 
40  img.drawCircle(
41  160 + 50 * cos(0.05 * i), 120 + 50 * sin(0.05 * i), 30,
42  TColor(255, 255, 255));
43 
44  vid << img;
45 
46  cout << "frame " << i << endl;
47  }
48  vid.close();
49 
50  cout << "Video closed " << endl;
51 }
52 
53 // ------------------------------------------------------
54 // MAIN
55 // ------------------------------------------------------
56 int main(int argc, char** argv)
57 {
58  try
59  {
61 
62  return 0;
63  }
64  catch (const std::exception& e)
65  {
66  std::cerr << "MRPT error: " << mrpt::exception_to_str(e) << std::endl;
67  return -1;
68  }
69  catch (...)
70  {
71  printf("Untyped exception!");
72  return -1;
73  }
74 }
mrpt::vision
Copyright (C) 2010 Hauke Strasdat Imperial College London Copyright (c) 2005-2020,...
Definition: bundle_adjustment.h:35
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: BaseAppDataSource.h:15
mrpt::vision::CVideoFileWriter
An output stream which takes a sequence of images and writes a video file in any of a given of compat...
Definition: CVideoFileWriter.h:40
CVideoFileWriter.h
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
mrpt::vision::CVideoFileWriter::close
void close()
Finish the file writing and close the file output.
Definition: CVideoFileWriter.cpp:82
mrpt::img
Definition: CCanvas.h:16
mrpt::img::TColor
A RGB color - 8bit.
Definition: TColor.h:25
argv
const char * argv[]
Definition: RawlogGrabberApp_unittest.cpp:40
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:148
argc
const int argc
Definition: RawlogGrabberApp_unittest.cpp:41
CImage.h
mrpt::exception_to_str
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
Test_VideoFile
void Test_VideoFile()
Definition: vision_stereo_rectify/test.cpp:22
mrpt::img::TImageSize
TPixelCoord TImageSize
A type for image sizes.
Definition: TPixelCoord.h:58
mrpt::vision::CVideoFileWriter::open
bool open(const std::string &out_file, double fps, const mrpt::img::TImageSize &frameSize, const std::string &fourcc=std::string(""), bool isColor=true)
Open a file for writing the video.
Definition: CVideoFileWriter.cpp:38



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 15 15:49:54 UTC 2020