Main MRPT website > C++ reference for 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 }
mrpt::system::os::kbhit
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
Definition: os.cpp:390
os.h
mrpt::io
Definition: img/CImage.h:22
CImageGrabber_FlyCapture2.h
t
GLdouble GLdouble t
Definition: glext.h:3689
mrpt::system::CTicTac
A high-performance stopwatch, with typical resolution of nanoseconds.
Definition: system/CTicTac.h:19
mrpt::hwdrivers::TCaptureOptions_FlyCapture2::videomode
std::string videomode
(Default="", which means default) A string with a video mode, from the list available in FlyCapture2:...
Definition: CImageGrabber_FlyCapture2.h:43
mrpt::hwdrivers::CImageGrabber_FlyCapture2::getObservation
bool getObservation(mrpt::obs::CObservationImage &out_observation)
Grab mono image from the camera.
Definition: CImageGrabber_FlyCapture2.cpp:726
mrpt::hwdrivers::CImageGrabber_FlyCapture2::open
void open(const TCaptureOptions_FlyCapture2 &options, const bool startCapture=true)
Tries to open the camera with the given options, and starts capture.
Definition: CImageGrabber_FlyCapture2.cpp:299
mrpt::hwdrivers::TCaptureOptions_FlyCapture2
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
Definition: CImageGrabber_FlyCapture2.h:21
CFileGZOutputStream.h
mrpt::hwdrivers
Contains classes for various device interfaces.
Definition: C2DRangeFinderAbstract.h:22
mrpt::obs
This namespace contains representation of robot actions and observations.
Definition: CParticleFilter.h:17
mrpt::system::CTicTac::Tac
double Tac() noexcept
Stops the stopwatch.
Definition: CTicTac.cpp:90
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
TestCapture_FlyCapture2
void TestCapture_FlyCapture2()
Definition: vision_stereo_rectify/test.cpp:31
win
mrpt::gui::CDisplayWindow3D::Ptr win
Definition: vision_stereo_rectify/test.cpp:31
mrpt::io::CFileGZOutputStream
Saves data to a file and transparently compress the data using the given compression level.
Definition: io/CFileGZOutputStream.h:26
mrpt::obs::CObservationImage::Ptr
std::shared_ptr< CObservationImage > Ptr
Definition: CObservationImage.h:37
mrpt::hwdrivers::TCaptureOptions_FlyCapture2::framerate
std::string framerate
(Default="", which means default) A string with a framerate, from the list available in FlyCapture2::...
Definition: CImageGrabber_FlyCapture2.h:48
mrpt::system::CTicTac::Tic
void Tic() noexcept
Starts the stopwatch.
Definition: CTicTac.cpp:79
mrpt::gui::CDisplayWindow
This class creates a window as a graphical user interface (GUI) for displaying images to the user.
Definition: CDisplayWindow.h:30
mrpt::serialization
Definition: aligned_serialization.h:14
mrpt::gui
Classes for creating GUI windows for 2D and 3D visualization.
Definition: about_box.h:16
mrpt::hwdrivers::CImageGrabber_FlyCapture2
A wrapper for Point Gray Research (PGR) FlyCapture2 API for capturing images from Firewire,...
Definition: CImageGrabber_FlyCapture2.h:187
mrpt::serialization::archiveFrom
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream,...
Definition: CArchive.h:561
mrpt::hwdrivers::CImageGrabber_FlyCapture2::getFC2version
static std::string getFC2version()
Returns the PGR FlyCapture2 library version.
Definition: CImageGrabber_FlyCapture2.cpp:707
CTicTac.h
CArchive.h
CDisplayWindow.h
mrpt::system
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Definition: math_frwds.h:25



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST