Go to the documentation of this file.
40 if (argc != 1 && argc != 2)
45 <<
" ==> Run with default camera parameters (from rawlog file)\n"
47 <<
"[params.cfg] ==> Load stereo camera parameters from cfg file\n";
51 const string sCfgFile = argv[1];
60 timlog.
enter(
"rectifyMap.setFromCamParams");
62 timlog.
leave(
"rectifyMap.setFromCamParams");
67 cout <<
"Please, select the input stereo camera or rawlog file (with "
68 "stereo images)...\n";
74 cout <<
"Video stream open OK\n";
80 std::vector<COpenGLViewport::Ptr> gl_views(2);
83 gl_views[0] = theScene->getViewport(
"main");
85 gl_views[1] = theScene->createViewport(
"right_image");
88 gl_views[0]->setViewportPosition(0, 0, .5, 1.);
89 gl_views[1]->setViewportPosition(.5, 0, .5, 1.);
92 win.unlockAccess3DScene();
98 bool enable_rectify =
true;
99 bool enable_draw_epipolar_lines =
true;
104 cout <<
"Close the window to end.\n";
112 "'r': Switch rectify (Now is: %s) | '+'/'-': Modify "
113 "alpha (Now is: %.02f)",
114 enable_rectify ?
"ON" :
"OFF", rectifyMap.
getAlpha()),
119 "'s': Switch resize output to 320x240 (Now is: %s) | 'c': "
120 "Switch no-disparity (Now is: %s) | 'e': Switch epipolar lines",
125 std::this_thread::sleep_for(1ms);
135 std::dynamic_pointer_cast<CObservationStereoImages>(obs);
139 if (!rectifyMap.
isSet())
141 timlog.
enter(
"rectifyMap.setFromCamParams");
143 timlog.
leave(
"rectifyMap.setFromCamParams");
155 timlog.
enter(
"rectifyMap.rectify()");
158 o->imageLeft, o->imageRight, img_left_rectified,
159 img_right_rectified);
161 timlog.
leave(
"rectifyMap.rectify()");
166 img_left_rectified = o->imageLeft;
167 img_right_rectified = o->imageRight;
171 if (enable_draw_epipolar_lines)
173 const unsigned int LINES_SEP = 40;
174 const unsigned int w = img_left_rectified.
getWidth();
175 const unsigned int h = img_left_rectified.
getHeight();
176 for (
unsigned int y = 0;
y < h;
y += LINES_SEP)
178 img_left_rectified.
line(
180 img_right_rectified.line(
185 gl_views[0]->setImageView(img_left_rectified);
186 gl_views[1]->setImageView(img_right_rectified);
192 win.unlockAccess3DScene();
199 int key =
win.getPushedKey(&kmods);
202 if (key ==
'r' || key ==
'R') enable_rectify = !enable_rectify;
203 if (key ==
'e' || key ==
'E')
204 enable_draw_epipolar_lines = !enable_draw_epipolar_lines;
205 if (key ==
'+' || key ==
'-')
208 rectifyMap.
getAlpha() + (key ==
'-' ? -0.1 : 0.1);
212 if (key ==
's' || key ==
'S')
217 if (key ==
'c' || key ==
'C')
230 int main(
int argc,
char** argv)
237 catch (std::exception& e)
239 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
244 printf(
"Untyped exception!!");
std::shared_ptr< CObservation > Ptr
void TestStereoRectify(int argc, char **argv)
size_t getWidth() const override
Returns the width of the image in pixels.
static constexpr TColor red()
Predefined colors.
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X),...
void setAlpha(double alpha)
Sets the alpha parameter which controls the zoom in/out of the rectified images, such that:
double getAlpha() const
Return the alpha parameter.
Classes for computer vision, detectors, features, etc.
std::string timeToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (UTC): HH:MM:SS.MMMMMM.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLubyte GLubyte GLubyte GLubyte w
#define ASSERT_(f)
Defines an assertion mechanism.
GLclampf GLclampf GLclampf alpha
void enter(const char *func_name)
Start of a named section.
Use this class to rectify stereo images if the same distortion maps are reused over and over again.
This namespace contains representation of robot actions and observations.
double leave(const char *func_name)
End of a named section.
std::shared_ptr< CObservationStereoImages > Ptr
CCameraSensor::Ptr prepareVideoSourceFromUserSelection()
Show to the user a list of possible camera drivers and creates and open the selected camera.
bool isEnabledResizeOutput() const
Returns whether resizing is enabled (default=false)
Structure to hold the parameters of a pinhole stereo camera model.
mrpt::gui::CDisplayWindow3D::Ptr win
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
A RGB color - floats in the range [0,1].
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::rtti::CObject) is of the give...
void line(int x0, int y0, int x1, int y1, const mrpt::img::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid) override
Draws a line.
bool isEnabledBothCentersCoincide() const
void enableResizeOutput(bool enable, unsigned int target_width=0, unsigned int target_height=0)
If enabled, the computed maps will rectify images to a size different than their original size.
Classes for creating GUI windows for 2D and 3D visualization.
@ FILL
renders glyphs as filled polygons
A class for storing images as grayscale or RGB bitmaps.
void setFromCamParams(const mrpt::img::TStereoCamera ¶ms)
Prepares the mapping from the intrinsic, distortion and relative pose parameters of a stereo camera.
size_t getHeight() const override
Returns the height of the image in pixels.
void rectify(const mrpt::img::CImage &in_left_image, const mrpt::img::CImage &in_right_image, mrpt::img::CImage &out_left_image, mrpt::img::CImage &out_right_image) const
Rectify the input image pair and save the result in a different output images - setFromCamParams() mu...
This class allows loading and storing values and vectors of different types from "....
bool isSet() const
Returns true if setFromCamParams() has been already called, false otherwise.
std::shared_ptr< COpenGLScene > Ptr
std::shared_ptr< CCameraSensor > Ptr
void enableBothCentersCoincide(bool enable=true)
If enabled (default=false), the principal points in both output images will coincide.
#define ASSERT_FILE_EXISTS_(FIL)
The namespace for 3D scene representation and rendering.
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
Observation class for either a pair of left+right or left+disparity images from a stereo camera.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
GLenum const GLfloat * params
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 | |