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>
13 #include <iostream>
14 
15 using namespace mrpt::hwdrivers;
16 using namespace mrpt::gui;
17 using namespace mrpt::obs;
18 using namespace mrpt::system;
19 using namespace std;
20 
21 //#define DO_CAPTURE 1
22 #define DO_CAPTURE 0
23 
24 // ------------------------------------------------------
25 // TestCapture
26 // ------------------------------------------------------
27 
28 void TestCapture_1394()
29 {
30  TCaptureOptions_dc1394 options;
31 
32  uint64_t cameraGUID = 0;
33  uint16_t cameraUnit = 0;
34 
35  options.frame_width = 1024; // 640;
36  options.frame_height = 768; // 480;
38 
39  // Other capture options:
40  // options.shutter = 900;
41 
42  // For stereo Bumblebee tests/debugging (Use the Bumblebee class in
43  // mrpt::vision instead!)
44  // options.mode7 = 3;
45  // options.deinterlace_stereo = true;
46 
47  CImageGrabber_dc1394 capture(
48  cameraGUID, cameraUnit, options, true /* Verbose */);
49 
50  CTicTac tictac;
51 
52  cout << "Press any key to stop capture to 'capture.rawlog'..." << endl;
53 
54 #if DO_CAPTURE
55  CFileGZOutputStream fil("./capture.rawlog");
56 #endif
57 
58  CDisplayWindow win("Capturing...");
59 
60  int cnt = 0;
61 
62  while (!mrpt::system::os::kbhit())
63  {
64  if ((cnt++ % 10) == 0)
65  {
66  if (cnt > 0)
67  {
68  double t = tictac.Tac();
69  double FPS = 10 / t;
70  printf("\n %f FPS\n", FPS);
71 
72  // Other capture options:
73  // options.shutter = cnt + 1;
74  // capture.changeCaptureOptions(options);
75  }
76  tictac.Tic();
77  }
78 
80  mrpt::make_aligned_shared<CObservationImage>(); // Memory will be
81  // freed by
82  // SF destructor in each
83  // loop.
84  if (!capture.getObservation(*obs))
85  {
86  cerr << "Error retrieving images!" << endl;
87  break;
88  }
89 
90 #if DO_CAPTURE
91  fil << obs;
92 #endif
93  cout << ".";
94  cout.flush();
95  if (win.isOpen()) win.showImage(obs->image);
96  }
97 }
98 
99 int main(int argc, char** argv)
100 {
101  try
102  {
104 
105  return 0;
106  }
107  catch (std::exception& e)
108  {
109  std::cout << "MRPT exception caught: " << e.what() << std::endl;
110  return -1;
111  }
112  catch (...)
113  {
114  printf("Another exception!!");
115  return -1;
116  }
117 }
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
t
GLdouble GLdouble t
Definition: glext.h:3689
uint16_t
unsigned __int16 uint16_t
Definition: rptypes.h:44
mrpt::system::CTicTac
A high-performance stopwatch, with typical resolution of nanoseconds.
Definition: system/CTicTac.h:19
mrpt::hwdrivers::COLOR_CODING_YUV422
@ COLOR_CODING_YUV422
Definition: CImageGrabber_dc1394.h:36
mrpt::hwdrivers
Contains classes for various device interfaces.
Definition: C2DRangeFinderAbstract.h:22
mrpt::hwdrivers::CImageGrabber_dc1394
A class for grabing images from a IEEE1394 (Firewire) camera using the libdc1394-2 library.
Definition: CImageGrabber_dc1394.h:153
mrpt::obs
This namespace contains representation of robot actions and observations.
Definition: CParticleFilter.h:17
mrpt::utils::CFileGZOutputStream
mrpt::io::CFileGZOutputStream CFileGZOutputStream
Definition: utils/CFileGZOutputStream.h:7
mrpt::hwdrivers::TCaptureOptions_dc1394::frame_height
int frame_height
Definition: CImageGrabber_dc1394.h:80
mrpt::hwdrivers::TCaptureOptions_dc1394::frame_width
int frame_width
Capture resolution (Default: 640x480)
Definition: CImageGrabber_dc1394.h:80
mrpt::system::CTicTac::Tac
double Tac() noexcept
Stops the stopwatch.
Definition: CTicTac.cpp:90
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
CImageGrabber_dc1394.h
win
mrpt::gui::CDisplayWindow3D::Ptr win
Definition: vision_stereo_rectify/test.cpp:31
mrpt::obs::CObservationImage::Ptr
std::shared_ptr< CObservationImage > Ptr
Definition: CObservationImage.h:37
uint64_t
unsigned __int64 uint64_t
Definition: rptypes.h:50
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
TestCapture_1394
void TestCapture_1394()
Definition: vision_stereo_rectify/test.cpp:28
mrpt::hwdrivers::TCaptureOptions_dc1394
Options used when creating an dc1394 capture object All but the frame size, framerate,...
Definition: CImageGrabber_dc1394.h:48
mrpt::gui
Classes for creating GUI windows for 2D and 3D visualization.
Definition: about_box.h:16
mrpt::hwdrivers::TCaptureOptions_dc1394::color_coding
grabber_dc1394_color_coding_t color_coding
Definition: CImageGrabber_dc1394.h:82
CTicTac.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