MRPT  1.9.9
test.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
12 #include <mrpt/system/CTicTac.h>
15 #include <mrpt/system/os.h>
16 #include <mrpt/system/CTicTac.h>
17 #include <iostream>
18 
19 using namespace mrpt::hwdrivers;
20 using namespace mrpt::obs;
21 using namespace mrpt::gui;
22 using namespace mrpt::io;
23 using namespace mrpt::serialization;
24 using namespace mrpt::system;
25 using namespace std;
26 
27 // ------------------------------------------------------
28 // TestCapture_FlyCapture2
29 // ------------------------------------------------------
30 
32 {
33  cout << " FlyCapture2 version: "
35 
36  // Create camera object:
38 
39  // Open camera:
40  TCaptureOptions_FlyCapture2 cam_options;
41 
42  cam_options.framerate = "FRAMERATE_30";
43  cam_options.videomode = "VIDEOMODE_1280x960RGB";
44  // cam_options.videomode="VIDEOMODE_1280x960Y8";
45 
46  capture.open(cam_options);
47 
48  CTicTac tictac;
49  cout << "Press any key to stop capture to 'capture.rawlog'..." << endl;
50 
51  CFileGZOutputStream fil("./capture.rawlog");
52 
53  CDisplayWindow win("Capturing...");
54 
55  int cnt = 0;
56 
58  mrpt::make_aligned_shared<CObservationImage>(); // Memory will be freed
59  // by SF
60  // destructor in each loop.
61 
62  while (!mrpt::system::os::kbhit())
63  {
64  if ((cnt++ % 20) == 0)
65  {
66  if (cnt > 0)
67  {
68  double t = tictac.Tac();
69  double FPS = 20 / t;
70  printf("\n %f FPS\n", FPS);
71  }
72  tictac.Tic();
73  }
74 
75  if (!capture.getObservation(*obs))
76  {
77  cerr << "Error retrieving images!" << endl;
78  break;
79  }
80 
81  cout << ".";
82  cout.flush();
83  if (win.isOpen()) win.showImage(obs->image);
84 
85  archiveFrom(fil) << obs;
86  }
87 }
88 
89 int main(int argc, char** argv)
90 {
91  try
92  {
94  return 0;
95  }
96  catch (std::exception& e)
97  {
98  std::cout << "MRPT exception caught: " << e.what() << std::endl;
99  return -1;
100  }
101  catch (...)
102  {
103  printf("Another exception!!");
104  return -1;
105  }
106 }
double Tac() noexcept
Stops the stopwatch.
Definition: CTicTac.cpp:90
bool getObservation(mrpt::obs::CObservationImage &out_observation)
Grab mono image from the camera.
GLdouble GLdouble t
Definition: glext.h:3689
A wrapper for Point Gray Research (PGR) FlyCapture2 API for capturing images from Firewire...
A high-performance stopwatch, with typical resolution of nanoseconds.
Contains classes for various device interfaces.
STL namespace.
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT&#39;s CStream, std::istream, std::ostream, std::stringstream
Definition: CArchive.h:555
void TestCapture_FlyCapture2()
This class creates a window as a graphical user interface (GUI) for displaying images to the user...
std::string videomode
(Default="", which means default) A string with a video mode, from the list available in FlyCapture2:...
This namespace contains representation of robot actions and observations.
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
mrpt::gui::CDisplayWindow3D::Ptr win
static std::string getFC2version()
Returns the PGR FlyCapture2 library version.
std::string framerate
(Default="", which means default) A string with a framerate, from the list available in FlyCapture2::...
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
Definition: os.cpp:390
Classes for creating GUI windows for 2D and 3D visualization.
Definition: about_box.h:14
Saves data to a file and transparently compress the data using the given compression level...
void Tic() noexcept
Starts the stopwatch.
Definition: CTicTac.cpp:79
void open(const TCaptureOptions_FlyCapture2 &options, const bool startCapture=true)
Tries to open the camera with the given options, and starts capture.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020