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 
10 #include <mrpt/opengl/CFBORender.h>
12 #include <mrpt/img/CImage.h>
14 #include <iostream>
15 
16 using namespace std;
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 using namespace mrpt::io;
20 using namespace mrpt::serialization;
21 using namespace mrpt::img;
22 // ------------------------------------------------------
23 // TestOffscreenRender
24 // ------------------------------------------------------
25 int TestOffscreenRender(int argc, char* argv[])
26 {
27  if (argc != 5)
28  {
29  cerr
30  << "Usage: " << argv[0]
31  << " <FILE.3Dscene> <WIDTH> <HEIGHT> <OUTPUT_IMAGE>\n"
32  " Output image can be in many formats: .png, .jpg, .tif, etc.\n";
33  return 1;
34  }
35 
36  const string sFil = argv[1];
37  const int width = atoi(argv[2]);
38  const int height = atoi(argv[3]);
39  const string sOut = argv[4];
40 
41  ASSERT_ABOVE_(width, 0);
43 
44  COpenGLScene scene;
45  CFileGZInputStream f(sFil);
46  archiveFrom(f) >> scene;
47 
48  CFBORender render(width, height);
49  CImage frame(width, height, 3, false);
50 
51  // here you can put your preferred camera rendering position
52  {
53  CCamera& camera = render.getCamera(scene);
54  camera.setOrthogonal(true);
55  camera.setZoomDistance(70);
56  camera.setAzimuthDegrees(-90);
57  camera.setElevationDegrees(90);
58  }
59 
60  // render the scene
61  render.getFrame2(scene, frame);
62  frame.saveToFile(sOut);
63 
64  return 0;
65 }
66 
67 // ------------------------------------------------------
68 // MAIN
69 // ------------------------------------------------------
70 int main(int argc, char* argv[])
71 {
72  try
73  {
74  return TestOffscreenRender(argc, argv);
75  }
76  catch (std::exception& e)
77  {
78  std::cout << "MRPT exception caught: " << e.what() << std::endl;
79  return -1;
80  }
81  catch (...)
82  {
83  printf("Untyped exception!!");
84  return -1;
85  }
86 }
ASSERT_ABOVE_
#define ASSERT_ABOVE_(__A, __B)
Definition: exceptions.h:171
mrpt::opengl::CCamera::setAzimuthDegrees
void setAzimuthDegrees(float ang)
Definition: CCamera.h:76
mrpt::io
Definition: img/CImage.h:22
mrpt::opengl::COpenGLScene
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives.
Definition: COpenGLScene.h:59
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
CFBORender.h
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
mrpt::img
Definition: CCanvas.h:17
mrpt::io::CFileGZInputStream
Transparently opens a compressed "gz" file and reads uncompressed data from it.
Definition: io/CFileGZInputStream.h:26
mrpt::opengl::CCamera
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
Definition: CCamera.h:30
mrpt::opengl::CCamera::setZoomDistance
void setZoomDistance(float z)
Definition: CCamera.h:72
mrpt::serialization
Definition: aligned_serialization.h:14
height
GLenum GLsizei GLsizei height
Definition: glext.h:3554
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
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::opengl::CCamera::setOrthogonal
void setOrthogonal(bool v=true)
Enable/Disable orthogonal mode (vs.
Definition: CCamera.h:81
mrpt::opengl::CCamera::setElevationDegrees
void setElevationDegrees(float ang)
Definition: CCamera.h:77
width
GLenum GLsizei width
Definition: glext.h:3531
TestOffscreenRender
int TestOffscreenRender(int argc, char *argv[])
Definition: vision_stereo_rectify/test.cpp:25
CFileGZInputStream.h
CImage.h
mrpt::opengl::CFBORender
A class for rendering 3D scenes off-screen directly into an image using OpenGL extensions (glext).
Definition: CFBORender.h:30
CArchive.h
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15



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