54 cout <<
"[Test_SwissRanger] Camera open, serial #" 59 const double aspect_ratio = cam.
rows() / double(cam.
cols());
64 cout <<
"[Test_SwissRanger] Version: " << ver <<
"\n";
68 bool there_is_obs =
true, hard_error;
72 win3D.setCameraAzimuthDeg(140);
73 win3D.setCameraElevationDeg(20);
74 win3D.setCameraZoom(6.0);
75 win3D.setCameraPointingToPoint(2.5, 0, 0);
88 gl_points->setPointSize(4.5);
92 0.5, -0.5, -0.5 * aspect_ratio, 0.5 * aspect_ratio);
95 0.5, -0.5, -0.5 * aspect_ratio, 0.5 * aspect_ratio);
98 0.5, -0.5, -0.5 * aspect_ratio, 0.5 * aspect_ratio);
104 scene->insert(gl_points);
108 const int VW_WIDTH = 200;
109 const int VW_HEIGHT = 150;
110 const int VW_GAP = 10;
114 win3D.addTextMessage(
115 30, -10 - 1 * (VW_GAP + VW_HEIGHT),
"Range data",
TColorf(1, 1, 1),
118 scene->createViewport(
"view2d_range");
119 scene->insert(gl_img_range,
"view2d_range");
120 viewRange->setViewportPosition(
121 5, -10 - 1 * (VW_GAP + VW_HEIGHT), VW_WIDTH, VW_HEIGHT);
122 viewRange->setTransparent(
true);
123 viewRange->getCamera().setOrthogonal(
true);
124 viewRange->getCamera().setAzimuthDegrees(90);
125 viewRange->getCamera().setElevationDegrees(90);
126 viewRange->getCamera().setZoomDistance(1.0);
128 win3D.addTextMessage(
129 30, -10 - 2 * (VW_GAP + VW_HEIGHT),
"Intensity data",
132 scene->createViewport(
"view2d_int");
133 scene->insert(gl_img_intensity,
"view2d_int");
134 viewInt->setViewportPosition(
135 5, -10 - 2 * (VW_GAP + VW_HEIGHT), VW_WIDTH, VW_HEIGHT);
136 viewInt->setTransparent(
true);
137 viewInt->getCamera().setOrthogonal(
true);
138 viewInt->getCamera().setAzimuthDegrees(90);
139 viewInt->getCamera().setElevationDegrees(90);
140 viewInt->getCamera().setZoomDistance(1.0);
142 win3D.addTextMessage(
143 30, -10 - 3 * (VW_GAP + VW_HEIGHT),
"Intensity data (undistorted)",
146 scene->createViewport(
"view2d_intrect");
147 scene->insert(gl_img_intensity_rect,
"view2d_intrect");
148 viewIntRect->setViewportPosition(
149 5, -10 - 3 * (VW_GAP + VW_HEIGHT), VW_WIDTH, VW_HEIGHT);
150 viewIntRect->setTransparent(
true);
151 viewIntRect->getCamera().setOrthogonal(
true);
152 viewIntRect->getCamera().setAzimuthDegrees(90);
153 viewIntRect->getCamera().setElevationDegrees(90);
154 viewIntRect->getCamera().setZoomDistance(1.0);
156 win3D.unlockAccess3DScene();
163 bool endLoop =
false;
165 while (there_is_obs && !endLoop && win3D.isOpen())
177 img.setFromMatrix(range2D);
179 win3D.get3DSceneAndLock();
180 gl_img_range->assignImage_fast(
img);
181 win3D.unlockAccess3DScene();
187 win3D.get3DSceneAndLock();
192 gl_img_intensity_rect->assignImage(undistortImg);
193 win3D.unlockAccess3DScene();
202 CColouredPointsMap::cmFromIntensityImage;
205 win3D.get3DSceneAndLock();
206 gl_points->loadFromPointsMap(&pntsMap);
207 win3D.unlockAccess3DScene();
214 win3D.get3DSceneAndLock();
215 win3D.addTextMessage(
216 0.01, 0.01,
format(
"%.02f Hz", nImgs / tictac.
Tac()),
218 win3D.unlockAccess3DScene();
227 const int key = tolower(win3D.getPushedKey());
251 win3D.get3DSceneAndLock();
252 win3D.addTextMessage(
255 "Keyboard switches: H (hist.equal: %s) | G (convGray: %s) | D " 256 "(denoise: %s) | F (medianFilter: %s)",
262 win3D.unlockAccess3DScene();
264 std::this_thread::sleep_for(1ms);
268 int main(
int argc,
char** argv)
275 catch (
const std::exception& e)
282 printf(
"Another exception!!");
double Tac() noexcept
Stops the stopwatch.
static Ptr Create(Args &&... args)
mrpt::img::TCamera cameraParams
Projection parameters of the depth camera.
static Ptr Create(Args &&... args)
void setOpenFromUSB(bool USB)
true: open from USB, false: open from ethernet.
void enableConvGray(bool enable)
bool isEnabledImageHistEqualization() const
A class for grabing "range images" from a MESA imaging SwissRanger 3D cameras (SR-2, SR-3000, SR-4k).
mrpt::math::CMatrixF rangeImage
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters) ...
A high-performance stopwatch, with typical resolution of nanoseconds.
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement, as from a time-of-flight range camera or any other RGBD sensor.
double getMaxRange() const
Returns the maximum camera range, as deduced from its operating frequency.
Contains classes for various device interfaces.
void setSave3D(bool save)
TColourOptions colorScheme
The options employed when inserting laser scans in the map.
void initialize() override
Initializes the 3D camera - should be invoked after calling loadConfig()
void enableDenoiseANF(bool enable)
This base provides a set of functions for maths stuff.
bool getMesaLibVersion(std::string &out_version) const
Get the version of the MESA library.
size_t rows() const
Get the row count in the camera images, loaded automatically upon camera open().
mrpt::img::CImage intensityImage
If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage"...
This namespace contains representation of robot actions and observations.
bool hasRangeImage
true means the field rangeImage contains valid data
A map of 2D/3D points with individual colours (RGB).
void setSaveIntensityImage(bool save)
bool hasPoints3D
true means the field points3D contains valid data.
GLsizei const GLchar ** string
bool isEnabledDenoiseANF() const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool isOpen() const
whether the camera is open and comms work ok.
CSetOfObjects::Ptr CornerXYZ(float scale=1.0)
Returns three arrows representing a X,Y,Z 3D corner.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void loadFromRangeScan(const mrpt::obs::CObservation2DRangeScan &rangeScan, const mrpt::poses::CPose3D *robotPose=nullptr) override
See CPointsMap::loadFromRangeScan()
bool hasIntensityImage
true means the field intensityImage contains valid data
A RGB color - floats in the range [0,1].
void enableMedianFilter(bool enable)
void getNextObservation(mrpt::obs::CObservation3DRangeScan &out_obs, bool &there_is_obs, bool &hardware_error)
The main data retrieving function, to be called after calling loadConfig() and initialize().
The namespace for 3D scene representation and rendering.
void setSaveConfidenceImage(bool save)
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
bool isEnabledConvGray() const
Classes for creating GUI windows for 2D and 3D visualization.
unsigned int getCameraSerialNumber() const
Get the camera serial number, loaded automatically upon camera open().
void Tic() noexcept
Starts the stopwatch.
void undistort(CImage &out_img, const mrpt::img::TCamera &cameraParams) const
Undistort the image according to some camera parameters, and returns an output undistorted image...
size_t cols() const
Get the col count in the camera images, loaded automatically upon camera open().
This template class provides the basic functionality for a general 2D any-size, resizable container o...
void enableImageHistEqualization(bool enable)
static Ptr Create(Args &&... args)
void setSaveRangeImage(bool save)
A class for storing images as grayscale or RGB bitmaps.
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
bool isEnabledMedianFilter() const