tests_simple.cpp 18 KB
Newer Older
Anatoly Baksheev's avatar
Anatoly Baksheev committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
/*M///////////////////////////////////////////////////////////////////////////////////////
 //
 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
 //
 //  By downloading, copying, installing or using the software you agree to this license.
 //  If you do not agree to this license, do not download, install,
 //  copy or use the software.
 //
 //
 //                           License Agreement
 //                For Open Source Computer Vision Library
 //
 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
 // Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
 // Third party copyrights are property of their respective owners.
 //
 // Redistribution and use in source and binary forms, with or without modification,
 // are permitted provided that the following conditions are met:
 //
 //   * Redistribution's of source code must retain the above copyright notice,
 //     this list of conditions and the following disclaimer.
 //
 //   * Redistribution's in binary form must reproduce the above copyright notice,
 //     this list of conditions and the following disclaimer in the documentation
 //     and / or other materials provided with the distribution.
 //
 //   * The name of the copyright holders may not be used to endorse or promote products
 //     derived from this software without specific prior written permission.
 //
 // This software is provided by the copyright holders and contributors "as is" and
 // any express or implied warranties, including, but not limited to, the implied
 // warranties of merchantability and fitness for a particular purpose are disclaimed.
 // In no event shall the Intel Corporation or contributors be liable for any direct,
 // indirect, incidental, special, exemplary, or consequential damages
 // (including, but not limited to, procurement of substitute goods or services;
 // loss of use, data, or profits; or business interruption) however caused
 // and on any theory of liability, whether in contract, strict liability,
 // or tort (including negligence or otherwise) arising in any way out of
 // the use of this software, even if advised of the possibility of such damage.
 //
 //M*/

#include "test_precomp.hpp"

using namespace cv;
using namespace cv::viz;

48
TEST(Viz, show_cloud_bluberry)
Anatoly Baksheev's avatar
Anatoly Baksheev committed
49 50 51
{
    Mat dragon_cloud = readCloud(get_dragon_ply_file_path());

52 53
    Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));

Anatoly Baksheev's avatar
Anatoly Baksheev committed
54
    Viz3d viz("show_cloud_bluberry");
55
    viz.setBackgroundColor(Color::black());
Anatoly Baksheev's avatar
Anatoly Baksheev committed
56
    viz.showWidget("coosys", WCoordinateSystem());
57
    viz.showWidget("dragon", WCloud(dragon_cloud, Color::bluberry()), pose);
58 59

    viz.showWidget("text2d", WText("Bluberry cloud", Point(20, 20), 20, Color::green()));
Anatoly Baksheev's avatar
Anatoly Baksheev committed
60 61 62
    viz.spin();
}

63
TEST(Viz, show_cloud_random_color)
Anatoly Baksheev's avatar
Anatoly Baksheev committed
64 65 66 67 68 69
{
    Mat dragon_cloud = readCloud(get_dragon_ply_file_path());

    Mat colors(dragon_cloud.size(), CV_8UC3);
    theRNG().fill(colors, RNG::UNIFORM, 0, 255);

70 71
    Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));

Anatoly Baksheev's avatar
Anatoly Baksheev committed
72
    Viz3d viz("show_cloud_random_color");
73
    viz.setBackgroundMeshLab();
Anatoly Baksheev's avatar
Anatoly Baksheev committed
74
    viz.showWidget("coosys", WCoordinateSystem());
75
    viz.showWidget("dragon", WCloud(dragon_cloud, colors), pose);
76
    viz.showWidget("text2d", WText("Random color cloud", Point(20, 20), 20, Color::green()));
Anatoly Baksheev's avatar
Anatoly Baksheev committed
77 78 79
    viz.spin();
}

80
TEST(Viz, show_cloud_masked)
Anatoly Baksheev's avatar
Anatoly Baksheev committed
81 82 83 84
{
    Mat dragon_cloud = readCloud(get_dragon_ply_file_path());

    Vec3f qnan = Vec3f::all(std::numeric_limits<float>::quiet_NaN());
85
    for(int i = 0; i < (int)dragon_cloud.total(); ++i)
Anatoly Baksheev's avatar
Anatoly Baksheev committed
86 87 88
        if (i % 15 != 0)
            dragon_cloud.at<Vec3f>(i) = qnan;

89 90
    Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));

Anatoly Baksheev's avatar
Anatoly Baksheev committed
91 92
    Viz3d viz("show_cloud_masked");
    viz.showWidget("coosys", WCoordinateSystem());
93
    viz.showWidget("dragon", WCloud(dragon_cloud), pose);
94
    viz.showWidget("text2d", WText("Nan masked cloud", Point(20, 20), 20, Color::green()));
Anatoly Baksheev's avatar
Anatoly Baksheev committed
95 96
    viz.spin();
}
97

98
TEST(Viz, show_cloud_collection)
99 100 101 102
{
    Mat cloud = readCloud(get_dragon_ply_file_path());

    WCloudCollection ccol;
103
    ccol.addCloud(cloud, Color::white(), Affine3d().translate(Vec3d(0, 0, 0)).rotate(Vec3d(CV_PI/2, 0, 0)));
104 105
    ccol.addCloud(cloud, Color::blue(),  Affine3d().translate(Vec3d(1, 0, 0)));
    ccol.addCloud(cloud, Color::red(),   Affine3d().translate(Vec3d(2, 0, 0)));
106
    ccol.finalize();
107 108

    Viz3d viz("show_cloud_collection");
109
    viz.setBackgroundColor(Color::mlab());
110 111
    viz.showWidget("coosys", WCoordinateSystem());
    viz.showWidget("ccol", ccol);
112
    viz.showWidget("text2d", WText("Cloud collection", Point(20, 20), 20, Color::green()));
113 114
    viz.spin();
}
115

116 117 118 119 120 121 122 123
TEST(Viz, show_painted_clouds)
{
    Mat cloud = readCloud(get_dragon_ply_file_path());

    Viz3d viz("show_painted_clouds");
    viz.setBackgroundMeshLab();
    viz.showWidget("coosys", WCoordinateSystem());
    viz.showWidget("cloud1", WPaintedCloud(cloud), Affine3d(Vec3d(0.0, -CV_PI/2, 0.0), Vec3d(-1.5, 0.0, 0.0)));
124
    viz.showWidget("cloud2", WPaintedCloud(cloud, Vec3d(0.0, -0.75, -1.0), Vec3d(0.0, 0.75, 0.0)), Affine3d(Vec3d(0.0, CV_PI/2, 0.0), Vec3d(1.5, 0.0, 0.0)));
125 126
    viz.showWidget("cloud3", WPaintedCloud(cloud, Vec3d(0.0, 0.0, -1.0), Vec3d(0.0, 0.0, 1.0), Color::blue(), Color::red()));
    viz.showWidget("arrow", WArrow(Vec3d(0.0, 1.0, -1.0), Vec3d(0.0, 1.0, 1.0), 0.009, Color::raspberry()));
127
    viz.showWidget("text2d", WText("Painted clouds", Point(20, 20), 20, Color::green()));
128 129 130
    viz.spin();
}

131
TEST(Viz, show_mesh)
132
{
133
    Mesh mesh = Mesh::load(get_dragon_ply_file_path());
134

135 136
    Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));

137 138
    Viz3d viz("show_mesh");
    viz.showWidget("coosys", WCoordinateSystem());
139
    viz.showWidget("mesh", WMesh(mesh), pose);
140
    viz.showWidget("text2d", WText("Just mesh", Point(20, 20), 20, Color::green()));
141 142 143
    viz.spin();
}

144
TEST(Viz, show_mesh_random_colors)
145
{
146
    Mesh mesh = Mesh::load(get_dragon_ply_file_path());
147 148
    theRNG().fill(mesh.colors, RNG::UNIFORM, 0, 255);

149 150
    Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));

151 152
    Viz3d viz("show_mesh_random_color");
    viz.showWidget("coosys", WCoordinateSystem());
153
    viz.showWidget("mesh", WMesh(mesh), pose);
154
    viz.setRenderingProperty("mesh", SHADING, SHADING_PHONG);
155
    viz.showWidget("text2d", WText("Random color mesh", Point(20, 20), 20, Color::green()));
156 157 158
    viz.spin();
}

159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
TEST(Viz, show_widget_merger)
{
    WWidgetMerger merger;
    merger.addWidget(WCube(Vec3d::all(0.0), Vec3d::all(1.0), true, Color::gold()));

    RNG& rng = theRNG();
    for(int i = 0; i < 77; ++i)
    {
        Vec3b c;
        rng.fill(c, RNG::NORMAL, Scalar::all(128), Scalar::all(48), true);
        merger.addWidget(WSphere(Vec3d(c)*(1.0/255.0), 7.0/255.0, 10, Color(c[2], c[1], c[0])));
    }
    merger.finalize();

    Viz3d viz("show_mesh_random_color");
    viz.showWidget("coo", WCoordinateSystem());
    viz.showWidget("merger", merger);
    viz.showWidget("text2d", WText("Widget merger", Point(20, 20), 20, Color::green()));
    viz.spin();
}

180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
TEST(Viz, show_textured_mesh)
{
    Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));

    std::vector<Vec3d> points;
    std::vector<Vec2d> tcoords;
    std::vector<int> polygons;
    for(size_t i = 0; i < 64; ++i)
    {
        double angle = CV_PI/2 * i/64.0;
        points.push_back(Vec3d(0.00, cos(angle), sin(angle))*0.75);
        points.push_back(Vec3d(1.57, cos(angle), sin(angle))*0.75);
        tcoords.push_back(Vec2d(0.0, i/64.0));
        tcoords.push_back(Vec2d(1.0, i/64.0));
    }

196
    for(int i = 0; i < (int)points.size()/2-1; ++i)
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
    {
        int polys[] = {3, 2*i, 2*i+1, 2*i+2, 3, 2*i+1, 2*i+2, 2*i+3};
        polygons.insert(polygons.end(), polys, polys + sizeof(polys)/sizeof(polys[0]));
    }

    cv::viz::Mesh mesh;
    mesh.cloud = Mat(points, true).reshape(3, 1);
    mesh.tcoords = Mat(tcoords, true).reshape(2, 1);
    mesh.polygons = Mat(polygons, true).reshape(1, 1);
    mesh.texture = lena;

    Viz3d viz("show_textured_mesh");
    viz.setBackgroundMeshLab();
    viz.showWidget("coosys", WCoordinateSystem());
    viz.showWidget("mesh", WMesh(mesh));
    viz.setRenderingProperty("mesh", SHADING, SHADING_PHONG);
213
    viz.showWidget("text2d", WText("Textured mesh", Point(20, 20), 20, Color::green()));
214 215 216
    viz.spin();
}

217
TEST(Viz, show_polyline)
Anatoly Baksheev's avatar
Anatoly Baksheev committed
218
{
219 220 221 222
    const Color palette[] = { Color::red(), Color::green(), Color::blue(), Color::gold(), Color::raspberry(), Color::bluberry(), Color::lime() };
    size_t palette_size = sizeof(palette)/sizeof(palette[0]);

    Mat polyline(1, 32, CV_64FC3), colors(1, 32, CV_8UC3);
223
    for(int i = 0; i < (int)polyline.total(); ++i)
224
    {
Anatoly Baksheev's avatar
Anatoly Baksheev committed
225
        polyline.at<Vec3d>(i) = Vec3d(i/16.0, cos(i * CV_PI/6), sin(i * CV_PI/6));
226 227
        colors.at<Vec3b>(i) = palette[i & palette_size];
    }
Anatoly Baksheev's avatar
Anatoly Baksheev committed
228 229

    Viz3d viz("show_polyline");
230
    viz.showWidget("polyline", WPolyLine(polyline, colors));
Anatoly Baksheev's avatar
Anatoly Baksheev committed
231
    viz.showWidget("coosys", WCoordinateSystem());
232
    viz.showWidget("text2d", WText("Polyline", Point(20, 20), 20, Color::green()));
Anatoly Baksheev's avatar
Anatoly Baksheev committed
233 234 235
    viz.spin();
}

236
TEST(Viz, show_sampled_normals)
237
{
238
    Mesh mesh = Mesh::load(get_dragon_ply_file_path());
239 240 241 242 243 244 245 246
    computeNormals(mesh, mesh.normals);

    Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));

    Viz3d viz("show_sampled_normals");
    viz.showWidget("mesh", WMesh(mesh), pose);
    viz.showWidget("normals", WCloudNormals(mesh.cloud, mesh.normals, 30, 0.1f, Color::green()), pose);
    viz.setRenderingProperty("normals", LINE_WIDTH, 2.0);
247
    viz.showWidget("text2d", WText("Cloud or mesh normals", Point(20, 20), 20, Color::green()));
248 249 250
    viz.spin();
}

251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
TEST(Viz, show_cloud_shaded_by_normals)
{
    Mesh mesh = Mesh::load(get_dragon_ply_file_path());
    computeNormals(mesh, mesh.normals);

    Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));

    WCloud cloud(mesh.cloud, Color::white(), mesh.normals);
    cloud.setRenderingProperty(SHADING, SHADING_GOURAUD);

    Viz3d viz("show_cloud_shaded_by_normals");
    viz.showWidget("cloud", cloud, pose);
    viz.showWidget("text2d", WText("Cloud shaded by normals", Point(20, 20), 20, Color::green()));
    viz.spin();
}

267
TEST(Viz, show_trajectories)
268 269
{
    std::vector<Affine3d> path = generate_test_trajectory<double>(), sub0, sub1, sub2, sub3, sub4, sub5;
270 271 272 273 274 275 276 277
    int size =(int)path.size();

    Mat(path).rowRange(0, size/10+1).copyTo(sub0);
    Mat(path).rowRange(size/10, size/5+1).copyTo(sub1);
    Mat(path).rowRange(size/5, 11*size/12).copyTo(sub2);
    Mat(path).rowRange(11*size/12, size).copyTo(sub3);
    Mat(path).rowRange(3*size/4, 33*size/40).copyTo(sub4);
    Mat(path).rowRange(33*size/40, 9*size/10).copyTo(sub5);
278 279 280 281 282 283 284 285
    Matx33d K(1024.0, 0.0, 320.0, 0.0, 1024.0, 240.0, 0.0, 0.0, 1.0);

    Viz3d viz("show_trajectories");
    viz.showWidget("coos", WCoordinateSystem());
    viz.showWidget("sub0", WTrajectorySpheres(sub0, 0.25, 0.07));
    viz.showWidget("sub1", WTrajectory(sub1, WTrajectory::PATH, 0.2, Color::brown()));
    viz.showWidget("sub2", WTrajectory(sub2, WTrajectory::FRAMES, 0.2));
    viz.showWidget("sub3", WTrajectory(sub3, WTrajectory::BOTH, 0.2, Color::green()));
Anatoly Baksheev's avatar
Anatoly Baksheev committed
286
    viz.showWidget("sub4", WTrajectoryFrustums(sub4, K, 0.3, Color::yellow()));
287
    viz.showWidget("sub5", WTrajectoryFrustums(sub5, Vec2d(0.78, 0.78), 0.15));
288
    viz.showWidget("text2d", WText("Different kinds of supported trajectories", Point(20, 20), 20, Color::green()));
289 290 291 292 293 294 295 296 297

    int i = 0;
    while(!viz.wasStopped())
    {
        double a = --i % 360;
        Vec3d pose(sin(a * CV_PI/180), 0.7, cos(a * CV_PI/180));
        viz.setViewerPose(makeCameraPose(pose * 7.5, Vec3d(0.0, 0.5, 0.0), Vec3d(0.0, 0.1, 0.0)));
        viz.spinOnce(20, true);
    }
298
    viz.resetCamera();
299
    viz.spin();
300 301
}

302
TEST(Viz, show_trajectory_reposition)
303 304 305 306 307
{
    std::vector<Affine3f> path = generate_test_trajectory<float>();

    Viz3d viz("show_trajectory_reposition_to_origin");
    viz.showWidget("coos", WCoordinateSystem());
308
    viz.showWidget("sub3", WTrajectory(Mat(path).rowRange(0, (int)path.size()/3), WTrajectory::BOTH, 0.2, Color::brown()), path.front().inv());
309
    viz.showWidget("text2d", WText("Trajectory resposition to origin", Point(20, 20), 20, Color::green()));
310 311 312
    viz.spin();
}

313
TEST(Viz, show_camera_positions)
314 315
{
    Matx33d K(1024.0, 0.0, 320.0, 0.0, 1024.0, 240.0, 0.0, 0.0, 1.0);
316 317
    Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));
    Mat gray = make_gray(lena);
318 319 320 321 322 323 324 325 326

    Affine3d poses[2];
    for(int i = 0; i < 2; ++i)
    {
        Vec3d pose = 5 * Vec3d(sin(3.14 + 2.7 + i*60 * CV_PI/180), 0.4 - i*0.3, cos(3.14 + 2.7 + i*60 * CV_PI/180));
        poses[i] = makeCameraPose(pose, Vec3d(0.0, 0.0, 0.0), Vec3d(0.0, -0.1, 0.0));
    }

    Viz3d viz("show_camera_positions");
Anatoly Baksheev's avatar
Anatoly Baksheev committed
327
    viz.showWidget("sphe", WSphere(Point3d(0,0,0), 1.0, 10, Color::orange_red()));
328 329 330 331 332
    viz.showWidget("coos", WCoordinateSystem(1.5));
    viz.showWidget("pos1", WCameraPosition(0.75), poses[0]);
    viz.showWidget("pos2", WCameraPosition(Vec2d(0.78, 0.78), lena, 2.2, Color::green()), poses[0]);
    viz.showWidget("pos3", WCameraPosition(0.75), poses[1]);
    viz.showWidget("pos4", WCameraPosition(K, gray, 3, Color::indigo()), poses[1]);
333
    viz.showWidget("text2d", WText("Camera positions with images", Point(20, 20), 20, Color::green()));
334 335 336
    viz.spin();
}

337
TEST(Viz, show_overlay_image)
338 339 340 341
{
    Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));
    Mat gray = make_gray(lena);

342 343
    Size2d half_lsize = Size2d(lena.size()) * 0.5;

344
    Viz3d viz("show_overlay_image");
345
    viz.setBackgroundMeshLab();
346 347
    Size vsz = viz.getWindowSize();

348
    viz.showWidget("coos", WCoordinateSystem());
349
    viz.showWidget("cube", WCube());
350 351 352 353
    viz.showWidget("img1", WImageOverlay(lena, Rect(Point(10, 10), half_lsize)));
    viz.showWidget("img2", WImageOverlay(gray, Rect(Point(vsz.width-10-lena.cols/2, 10), half_lsize)));
    viz.showWidget("img3", WImageOverlay(gray, Rect(Point(10, vsz.height-10-lena.rows/2), half_lsize)));
    viz.showWidget("img5", WImageOverlay(lena, Rect(Point(vsz.width-10-lena.cols/2, vsz.height-10-lena.rows/2), half_lsize)));
354
    viz.showWidget("text2d", WText("Overlay images", Point(20, 20), 20, Color::green()));
Anatoly Baksheev's avatar
Anatoly Baksheev committed
355 356 357 358 359 360 361 362 363 364

    int i = 0;
    while(!viz.wasStopped())
    {
        double a = ++i % 360;
        Vec3d pose(sin(a * CV_PI/180), 0.7, cos(a * CV_PI/180));
        viz.setViewerPose(makeCameraPose(pose * 3, Vec3d(0.0, 0.5, 0.0), Vec3d(0.0, 0.1, 0.0)));
        viz.getWidget("img1").cast<WImageOverlay>().setImage(lena * pow(sin(i*10*CV_PI/180) * 0.5 + 0.5, 1.0));
        viz.spinOnce(1, true);
    }
365 366
    viz.showWidget("text2d", WText("Overlay images (stopped)", Point(20, 20), 20, Color::green()));
    viz.spin();
367 368
}

Anatoly Baksheev's avatar
Anatoly Baksheev committed
369

370
TEST(Viz, show_image_method)
Anatoly Baksheev's avatar
Anatoly Baksheev committed
371 372 373 374 375 376 377 378 379 380 381 382
{
    Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));

    Viz3d viz("show_image_method");
    viz.showImage(lena);
    viz.spinOnce(1500, true);
    viz.showImage(lena, lena.size());
    viz.spinOnce(1500, true);

    cv::viz::imshow("show_image_method", make_gray(lena)).spin();
}

383
TEST(Viz, show_image_3d)
384 385 386 387 388
{
    Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));
    Mat gray = make_gray(lena);

    Viz3d viz("show_image_3d");
389
    viz.setBackgroundMeshLab();
Anatoly Baksheev's avatar
Anatoly Baksheev committed
390
    viz.showWidget("coos", WCoordinateSystem());
391
    viz.showWidget("cube", WCube());
Anatoly Baksheev's avatar
Anatoly Baksheev committed
392 393 394 395
    viz.showWidget("arr0", WArrow(Vec3d(0.5, 0.0, 0.0), Vec3d(1.5, 0.0, 0.0), 0.009, Color::raspberry()));
    viz.showWidget("img0", WImage3D(lena, Size2d(1.0, 1.0)), Affine3d(Vec3d(0.0, CV_PI/2, 0.0), Vec3d(.5, 0.0, 0.0)));
    viz.showWidget("arr1", WArrow(Vec3d(-0.5, -0.5, 0.0), Vec3d(0.2, 0.2, 0.0), 0.009, Color::raspberry()));
    viz.showWidget("img1", WImage3D(gray, Size2d(1.0, 1.0), Vec3d(-0.5, -0.5, 0.0), Vec3d(1.0, 1.0, 0.0), Vec3d(0.0, 1.0, 0.0)));
396

Anatoly Baksheev's avatar
Anatoly Baksheev committed
397 398
    viz.showWidget("arr3", WArrow(Vec3d::all(-0.5), Vec3d::all(0.5), 0.009, Color::raspberry()));

399 400
    viz.showWidget("text2d", WText("Images in 3D", Point(20, 20), 20, Color::green()));

Anatoly Baksheev's avatar
Anatoly Baksheev committed
401 402 403 404 405 406
    int i = 0;
    while(!viz.wasStopped())
    {
        viz.getWidget("img0").cast<WImage3D>().setImage(lena * pow(sin(i++*7.5*CV_PI/180) * 0.5 + 0.5, 1.0));
        viz.spinOnce(1, true);
    }
407
    viz.showWidget("text2d", WText("Images in 3D (stopped)", Point(20, 20), 20, Color::green()));
408
    viz.spin();
409 410
}

Anatoly Baksheev's avatar
Anatoly Baksheev committed
411 412 413
TEST(Viz, show_simple_widgets)
{
    Viz3d viz("show_simple_widgets");
414
    viz.setBackgroundMeshLab();
415

Anatoly Baksheev's avatar
Anatoly Baksheev committed
416 417
    viz.showWidget("coos", WCoordinateSystem());
    viz.showWidget("cube", WCube());
418
    viz.showWidget("cub0", WCube(Vec3d::all(-1.0), Vec3d::all(-0.5), false, Color::indigo()));
Anatoly Baksheev's avatar
Anatoly Baksheev committed
419 420 421
    viz.showWidget("arro", WArrow(Vec3d::all(-0.5), Vec3d::all(0.5), 0.009, Color::raspberry()));
    viz.showWidget("cir1", WCircle(0.5, 0.01, Color::bluberry()));
    viz.showWidget("cir2", WCircle(0.5, Point3d(0.5, 0.0, 0.0), Vec3d(1.0, 0.0, 0.0), 0.01, Color::apricot()));
422 423

    viz.showWidget("cyl0", WCylinder(Vec3d(-0.5, 0.5, -0.5), Vec3d(0.5, 0.5, -0.5), 0.125, 30, Color::brown()));
424 425
    viz.showWidget("con0", WCone(0.25, 0.125, 6, Color::azure()));
    viz.showWidget("con1", WCone(0.125, Point3d(0.5, -0.5, 0.5), Point3d(0.5, -1.0, 0.5), 6, Color::turquoise()));
426

427
    viz.showWidget("text2d", WText("Different simple widgets", Point(20, 20), 20, Color::green()));
428 429
    viz.showWidget("text3d", WText3D("Simple 3D text", Point3d( 0.5,  0.5, 0.5), 0.125, false, Color::green()));

Anatoly Baksheev's avatar
Anatoly Baksheev committed
430 431 432
    viz.showWidget("plane1", WPlane(Size2d(0.25, 0.75)));
    viz.showWidget("plane2", WPlane(Vec3d(0.5, -0.5, -0.5), Vec3d(0.0, 1.0, 1.0), Vec3d(1.0, 1.0, 0.0), Size2d(1.0, 0.5), Color::gold()));

Anatoly Baksheev's avatar
Anatoly Baksheev committed
433 434
    viz.showWidget("grid1", WGrid(Vec2i(7,7), Vec2d::all(0.75), Color::gray()), Affine3d().translate(Vec3d(0.0, 0.0, -1.0)));

435
    viz.spin();
436
    viz.getWidget("text2d").cast<WText>().setText("Different simple widgets (updated)");
437 438 439 440
    viz.getWidget("text3d").cast<WText3D>().setText("Updated text 3D");
    viz.spin();
}

441
TEST(Viz, show_follower)
442 443 444 445 446 447
{
    Viz3d viz("show_follower");

    viz.showWidget("coos", WCoordinateSystem());
    viz.showWidget("cube", WCube());
    viz.showWidget("t3d_2", WText3D("Simple 3D follower", Point3d(-0.5, -0.5, 0.5), 0.125, true,  Color::green()));
448
    viz.showWidget("text2d", WText("Follower: text always facing camera", Point(20, 20), 20, Color::green()));
449
    viz.setBackgroundMeshLab();
450
    viz.spin();
451
    viz.getWidget("t3d_2").cast<WText3D>().setText("Updated follower 3D");
452 453
    viz.spin();
}