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);
87 mrpt::make_aligned_shared<mrpt::opengl::CPointCloudColoured>();
88 gl_points->setPointSize(4.5);
91 mrpt::make_aligned_shared<mrpt::opengl::CTexturedPlane>(
92 0.5, -0.5, -0.5 * aspect_ratio, 0.5 * aspect_ratio);
94 mrpt::make_aligned_shared<mrpt::opengl::CTexturedPlane>(
95 0.5, -0.5, -0.5 * aspect_ratio, 0.5 * aspect_ratio);
97 mrpt::make_aligned_shared<mrpt::opengl::CTexturedPlane>(
98 0.5, -0.5, -0.5 * aspect_ratio, 0.5 * aspect_ratio);
104 scene->insert(gl_points);
105 scene->insert(mrpt::make_aligned_shared<mrpt::opengl::CGridPlaneXY>());
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 (std::exception& e)
277 std::cout <<
"EXCEPCION: " << e.what() << std::endl;
282 printf(
"Another exception!!");