tests_simple.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
  14. // Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
  15. // Third party copyrights are property of their respective owners.
  16. //
  17. // Redistribution and use in source and binary forms, with or without modification,
  18. // are permitted provided that the following conditions are met:
  19. //
  20. // * Redistribution's of source code must retain the above copyright notice,
  21. // this list of conditions and the following disclaimer.
  22. //
  23. // * Redistribution's in binary form must reproduce the above copyright notice,
  24. // this list of conditions and the following disclaimer in the documentation
  25. // and / or other materials provided with the distribution.
  26. //
  27. // * The name of the copyright holders may not be used to endorse or promote products
  28. // derived from this software without specific prior written permission.
  29. //
  30. // This software is provided by the copyright holders and contributors "as is" and
  31. // any express or implied warranties, including, but not limited to, the implied
  32. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  33. // In no event shall the Intel Corporation or contributors be liable for any direct,
  34. // indirect, incidental, special, exemplary, or consequential damages
  35. // (including, but not limited to, procurement of substitute goods or services;
  36. // loss of use, data, or profits; or business interruption) however caused
  37. // and on any theory of liability, whether in contract, strict liability,
  38. // or tort (including negligence or otherwise) arising in any way out of
  39. // the use of this software, even if advised of the possibility of such damage.
  40. //
  41. //M*/
  42. #include "test_precomp.hpp"
  43. namespace opencv_test { namespace {
  44. TEST(Viz, show_cloud_bluberry)
  45. {
  46. Mat dragon_cloud = readCloud(get_dragon_ply_file_path());
  47. Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
  48. Viz3d viz("show_cloud_bluberry");
  49. viz.setBackgroundColor(Color::black());
  50. viz.showWidget("coosys", WCoordinateSystem());
  51. viz.showWidget("dragon", WCloud(dragon_cloud, Color::bluberry()), pose);
  52. viz.showWidget("text2d", WText("Bluberry cloud", Point(20, 20), 20, Color::green()));
  53. viz.spinOnce(500, true);
  54. }
  55. TEST(Viz, show_cloud_random_color)
  56. {
  57. Mat dragon_cloud = readCloud(get_dragon_ply_file_path());
  58. Mat colors(dragon_cloud.size(), CV_8UC3);
  59. theRNG().fill(colors, RNG::UNIFORM, 0, 255);
  60. Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
  61. Viz3d viz("show_cloud_random_color");
  62. viz.setBackgroundMeshLab();
  63. viz.showWidget("coosys", WCoordinateSystem());
  64. viz.showWidget("dragon", WCloud(dragon_cloud, colors), pose);
  65. viz.showWidget("text2d", WText("Random color cloud", Point(20, 20), 20, Color::green()));
  66. viz.spinOnce(500, true);
  67. }
  68. TEST(Viz, show_cloud_masked)
  69. {
  70. Mat dragon_cloud = readCloud(get_dragon_ply_file_path());
  71. Vec3f qnan = Vec3f::all(std::numeric_limits<float>::quiet_NaN());
  72. for(int i = 0; i < (int)dragon_cloud.total(); ++i)
  73. if (i % 15 != 0)
  74. dragon_cloud.at<Vec3f>(i) = qnan;
  75. Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
  76. Viz3d viz("show_cloud_masked");
  77. viz.showWidget("coosys", WCoordinateSystem());
  78. viz.showWidget("dragon", WCloud(dragon_cloud), pose);
  79. viz.showWidget("text2d", WText("Nan masked cloud", Point(20, 20), 20, Color::green()));
  80. viz.spinOnce(500, true);
  81. }
  82. TEST(Viz, show_cloud_collection)
  83. {
  84. Mat cloud = readCloud(get_dragon_ply_file_path());
  85. WCloudCollection ccol;
  86. ccol.addCloud(cloud, Color::white(), Affine3d().translate(Vec3d(0, 0, 0)).rotate(Vec3d(CV_PI/2, 0, 0)));
  87. ccol.addCloud(cloud, Color::blue(), Affine3d().translate(Vec3d(1, 0, 0)));
  88. ccol.addCloud(cloud, Color::red(), Affine3d().translate(Vec3d(2, 0, 0)));
  89. ccol.finalize();
  90. Viz3d viz("show_cloud_collection");
  91. viz.setBackgroundColor(Color::mlab());
  92. viz.showWidget("coosys", WCoordinateSystem());
  93. viz.showWidget("ccol", ccol);
  94. viz.showWidget("text2d", WText("Cloud collection", Point(20, 20), 20, Color::green()));
  95. viz.spinOnce(500, true);
  96. }
  97. TEST(Viz, show_painted_clouds)
  98. {
  99. Mat cloud = readCloud(get_dragon_ply_file_path());
  100. Viz3d viz("show_painted_clouds");
  101. viz.setBackgroundMeshLab();
  102. viz.showWidget("coosys", WCoordinateSystem());
  103. viz.showWidget("cloud1", WPaintedCloud(cloud), Affine3d(Vec3d(0.0, -CV_PI/2, 0.0), Vec3d(-1.5, 0.0, 0.0)));
  104. 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)));
  105. viz.showWidget("cloud3", WPaintedCloud(cloud, Vec3d(0.0, 0.0, -1.0), Vec3d(0.0, 0.0, 1.0), Color::blue(), Color::red()));
  106. viz.showWidget("arrow", WArrow(Vec3d(0.0, 1.0, -1.0), Vec3d(0.0, 1.0, 1.0), 0.009, Color::raspberry()));
  107. viz.showWidget("text2d", WText("Painted clouds", Point(20, 20), 20, Color::green()));
  108. viz.spinOnce(500, true);
  109. }
  110. TEST(Viz, show_mesh)
  111. {
  112. Mesh mesh = Mesh::load(get_dragon_ply_file_path());
  113. Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
  114. Viz3d viz("show_mesh");
  115. viz.showWidget("coosys", WCoordinateSystem());
  116. viz.showWidget("mesh", WMesh(mesh), pose);
  117. viz.showWidget("text2d", WText("Just mesh", Point(20, 20), 20, Color::green()));
  118. viz.spinOnce(500, true);
  119. }
  120. TEST(Viz, show_mesh_random_colors)
  121. {
  122. Mesh mesh = Mesh::load(get_dragon_ply_file_path());
  123. theRNG().fill(mesh.colors, RNG::UNIFORM, 0, 255);
  124. Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
  125. Viz3d viz("show_mesh_random_color");
  126. viz.showWidget("coosys", WCoordinateSystem());
  127. viz.showWidget("mesh", WMesh(mesh), pose);
  128. viz.setRenderingProperty("mesh", SHADING, SHADING_PHONG);
  129. viz.showWidget("text2d", WText("Random color mesh", Point(20, 20), 20, Color::green()));
  130. viz.spinOnce(500, true);
  131. }
  132. TEST(Viz, show_widget_merger)
  133. {
  134. WWidgetMerger merger;
  135. merger.addWidget(WCube(Vec3d::all(0.0), Vec3d::all(1.0), true, Color::gold()));
  136. RNG& rng = theRNG();
  137. for(int i = 0; i < 77; ++i)
  138. {
  139. Vec3b c;
  140. rng.fill(c, RNG::NORMAL, Scalar::all(128), Scalar::all(48), true);
  141. merger.addWidget(WSphere(Vec3d(c)*(1.0/255.0), 7.0/255.0, 10, Color(c[2], c[1], c[0])));
  142. }
  143. merger.finalize();
  144. Viz3d viz("show_mesh_random_color");
  145. viz.showWidget("coo", WCoordinateSystem());
  146. viz.showWidget("merger", merger);
  147. viz.showWidget("text2d", WText("Widget merger", Point(20, 20), 20, Color::green()));
  148. viz.spinOnce(500, true);
  149. }
  150. TEST(Viz, show_textured_mesh)
  151. {
  152. Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));
  153. std::vector<Vec3d> points;
  154. std::vector<Vec2d> tcoords;
  155. std::vector<int> polygons;
  156. for(size_t i = 0; i < 64; ++i)
  157. {
  158. double angle = CV_PI/2 * i/64.0;
  159. points.push_back(Vec3d(0.00, cos(angle), sin(angle))*0.75);
  160. points.push_back(Vec3d(1.57, cos(angle), sin(angle))*0.75);
  161. tcoords.push_back(Vec2d(0.0, i/64.0));
  162. tcoords.push_back(Vec2d(1.0, i/64.0));
  163. }
  164. for(int i = 0; i < (int)points.size()/2-1; ++i)
  165. {
  166. int polys[] = {3, 2*i, 2*i+1, 2*i+2, 3, 2*i+1, 2*i+2, 2*i+3};
  167. polygons.insert(polygons.end(), polys, polys + sizeof(polys)/sizeof(polys[0]));
  168. }
  169. cv::viz::Mesh mesh;
  170. mesh.cloud = Mat(points, true).reshape(3, 1);
  171. mesh.tcoords = Mat(tcoords, true).reshape(2, 1);
  172. mesh.polygons = Mat(polygons, true).reshape(1, 1);
  173. mesh.texture = lena;
  174. Viz3d viz("show_textured_mesh");
  175. viz.setBackgroundMeshLab();
  176. viz.showWidget("coosys", WCoordinateSystem());
  177. viz.showWidget("mesh", WMesh(mesh));
  178. viz.setRenderingProperty("mesh", SHADING, SHADING_PHONG);
  179. viz.showWidget("text2d", WText("Textured mesh", Point(20, 20), 20, Color::green()));
  180. viz.spinOnce(500, true);
  181. }
  182. TEST(Viz, show_polyline)
  183. {
  184. const Color palette[] = { Color::red(), Color::green(), Color::blue(), Color::gold(), Color::raspberry(), Color::bluberry(), Color::lime() };
  185. size_t palette_size = sizeof(palette)/sizeof(palette[0]);
  186. Mat polyline(1, 32, CV_64FC3), colors(1, 32, CV_8UC3);
  187. for(int i = 0; i < (int)polyline.total(); ++i)
  188. {
  189. polyline.at<Vec3d>(i) = Vec3d(i/16.0, cos(i * CV_PI/6), sin(i * CV_PI/6));
  190. colors.at<Vec3b>(i) = palette[i & palette_size];
  191. }
  192. Viz3d viz("show_polyline");
  193. viz.showWidget("polyline", WPolyLine(polyline, colors));
  194. viz.showWidget("coosys", WCoordinateSystem());
  195. viz.showWidget("text2d", WText("Polyline", Point(20, 20), 20, Color::green()));
  196. viz.spinOnce(500, true);
  197. }
  198. TEST(Viz, show_sampled_normals)
  199. {
  200. Mesh mesh = Mesh::load(get_dragon_ply_file_path());
  201. computeNormals(mesh, mesh.normals);
  202. Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
  203. Viz3d viz("show_sampled_normals");
  204. viz.showWidget("mesh", WMesh(mesh), pose);
  205. viz.showWidget("normals", WCloudNormals(mesh.cloud, mesh.normals, 30, 0.1f, Color::green()), pose);
  206. viz.setRenderingProperty("normals", LINE_WIDTH, 2.0);
  207. viz.showWidget("text2d", WText("Cloud or mesh normals", Point(20, 20), 20, Color::green()));
  208. viz.spinOnce(500, true);
  209. }
  210. TEST(Viz, show_cloud_shaded_by_normals)
  211. {
  212. Mesh mesh = Mesh::load(get_dragon_ply_file_path());
  213. computeNormals(mesh, mesh.normals);
  214. Affine3d pose = Affine3d().rotate(Vec3d(0, 0.8, 0));
  215. WCloud cloud(mesh.cloud, Color::white(), mesh.normals);
  216. cloud.setRenderingProperty(SHADING, SHADING_GOURAUD);
  217. Viz3d viz("show_cloud_shaded_by_normals");
  218. viz.showWidget("cloud", cloud, pose);
  219. viz.showWidget("text2d", WText("Cloud shaded by normals", Point(20, 20), 20, Color::green()));
  220. viz.spinOnce(500, true);
  221. }
  222. TEST(Viz, show_trajectories)
  223. {
  224. std::vector<Affine3d> path = generate_test_trajectory<double>(), sub0, sub1, sub2, sub3, sub4, sub5;
  225. int size =(int)path.size();
  226. Mat(path).rowRange(0, size/10+1).copyTo(sub0);
  227. Mat(path).rowRange(size/10, size/5+1).copyTo(sub1);
  228. Mat(path).rowRange(size/5, 11*size/12).copyTo(sub2);
  229. Mat(path).rowRange(11*size/12, size).copyTo(sub3);
  230. Mat(path).rowRange(3*size/4, 33*size/40).copyTo(sub4);
  231. Mat(path).rowRange(33*size/40, 9*size/10).copyTo(sub5);
  232. Matx33d K(1024.0, 0.0, 320.0, 0.0, 1024.0, 240.0, 0.0, 0.0, 1.0);
  233. Viz3d viz("show_trajectories");
  234. viz.showWidget("coos", WCoordinateSystem());
  235. viz.showWidget("sub0", WTrajectorySpheres(sub0, 0.25, 0.07));
  236. viz.showWidget("sub1", WTrajectory(sub1, WTrajectory::PATH, 0.2, Color::brown()));
  237. viz.showWidget("sub2", WTrajectory(sub2, WTrajectory::FRAMES, 0.2));
  238. viz.showWidget("sub3", WTrajectory(sub3, WTrajectory::BOTH, 0.2, Color::green()));
  239. viz.showWidget("sub4", WTrajectoryFrustums(sub4, K, 0.3, Color::yellow()));
  240. viz.showWidget("sub5", WTrajectoryFrustums(sub5, Vec2d(0.78, 0.78), 0.15));
  241. viz.showWidget("text2d", WText("Different kinds of supported trajectories", Point(20, 20), 20, Color::green()));
  242. int i = 0;
  243. for(unsigned num = 0; num < 50; ++num)
  244. {
  245. double a = --i % 360;
  246. Vec3d pose(sin(a * CV_PI/180), 0.7, cos(a * CV_PI/180));
  247. viz.setViewerPose(makeCameraPose(pose * 7.5, Vec3d(0.0, 0.5, 0.0), Vec3d(0.0, 0.1, 0.0)));
  248. viz.spinOnce(100, true);
  249. }
  250. viz.resetCamera();
  251. viz.spinOnce(500, true);
  252. }
  253. TEST(Viz, show_trajectory_reposition)
  254. {
  255. std::vector<Affine3f> path = generate_test_trajectory<float>();
  256. Viz3d viz("show_trajectory_reposition_to_origin");
  257. viz.showWidget("coos", WCoordinateSystem());
  258. viz.showWidget("sub3", WTrajectory(Mat(path).rowRange(0, (int)path.size()/3), WTrajectory::BOTH, 0.2, Color::brown()), path.front().inv());
  259. viz.showWidget("text2d", WText("Trajectory resposition to origin", Point(20, 20), 20, Color::green()));
  260. viz.spinOnce(500, true);
  261. }
  262. TEST(Viz, show_camera_positions)
  263. {
  264. Matx33d K(1024.0, 0.0, 320.0, 0.0, 1024.0, 240.0, 0.0, 0.0, 1.0);
  265. Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));
  266. Mat gray = make_gray(lena);
  267. Affine3d poses[2];
  268. for(int i = 0; i < 2; ++i)
  269. {
  270. 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));
  271. poses[i] = makeCameraPose(pose, Vec3d(0.0, 0.0, 0.0), Vec3d(0.0, -0.1, 0.0));
  272. }
  273. Viz3d viz("show_camera_positions");
  274. viz.showWidget("sphe", WSphere(Point3d(0,0,0), 1.0, 10, Color::orange_red()));
  275. viz.showWidget("coos", WCoordinateSystem(1.5));
  276. viz.showWidget("pos1", WCameraPosition(0.75), poses[0]);
  277. viz.showWidget("pos2", WCameraPosition(Vec2d(0.78, 0.78), lena, 2.2, Color::green()), poses[0]);
  278. viz.showWidget("pos3", WCameraPosition(0.75), poses[1]);
  279. viz.showWidget("pos4", WCameraPosition(K, gray, 3, Color::indigo()), poses[1]);
  280. viz.showWidget("text2d", WText("Camera positions with images", Point(20, 20), 20, Color::green()));
  281. viz.spinOnce(500, true);
  282. }
  283. TEST(Viz, show_overlay_image)
  284. {
  285. Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));
  286. Mat gray = make_gray(lena);
  287. Size2d half_lsize = Size2d(lena.size()) * 0.5;
  288. Viz3d viz("show_overlay_image");
  289. viz.setBackgroundMeshLab();
  290. Size vsz = viz.getWindowSize();
  291. viz.showWidget("coos", WCoordinateSystem());
  292. viz.showWidget("cube", WCube());
  293. viz.showWidget("img1", WImageOverlay(lena, Rect(Point(10, 10), half_lsize)));
  294. viz.showWidget("img2", WImageOverlay(gray, Rect(Point(vsz.width-10-lena.cols/2, 10), half_lsize)));
  295. viz.showWidget("img3", WImageOverlay(gray, Rect(Point(10, vsz.height-10-lena.rows/2), half_lsize)));
  296. viz.showWidget("img5", WImageOverlay(lena, Rect(Point(vsz.width-10-lena.cols/2, vsz.height-10-lena.rows/2), half_lsize)));
  297. viz.showWidget("text2d", WText("Overlay images", Point(20, 20), 20, Color::green()));
  298. int i = 0;
  299. for(unsigned num = 0; num < 50; ++num)
  300. {
  301. double a = ++i % 360;
  302. Vec3d pose(sin(a * CV_PI/180), 0.7, cos(a * CV_PI/180));
  303. viz.setViewerPose(makeCameraPose(pose * 3, Vec3d(0.0, 0.5, 0.0), Vec3d(0.0, 0.1, 0.0)));
  304. viz.getWidget("img1").cast<WImageOverlay>().setImage(lena * pow(sin(i*10*CV_PI/180) * 0.5 + 0.5, 1.0));
  305. viz.spinOnce(100, true);
  306. }
  307. viz.showWidget("text2d", WText("Overlay images (stopped)", Point(20, 20), 20, Color::green()));
  308. viz.spinOnce(500, true);
  309. }
  310. TEST(Viz, show_image_method)
  311. {
  312. Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));
  313. Viz3d viz("show_image_method");
  314. viz.showImage(lena);
  315. viz.spinOnce(1500, true);
  316. viz.showImage(lena, lena.size());
  317. viz.spinOnce(1500, true);
  318. cv::viz::imshow("show_image_method", make_gray(lena)).spinOnce(500, true);
  319. }
  320. TEST(Viz, show_image_3d)
  321. {
  322. Mat lena = imread(Path::combine(cvtest::TS::ptr()->get_data_path(), "lena.png"));
  323. Mat gray = make_gray(lena);
  324. Viz3d viz("show_image_3d");
  325. viz.setBackgroundMeshLab();
  326. viz.showWidget("coos", WCoordinateSystem());
  327. viz.showWidget("cube", WCube());
  328. viz.showWidget("arr0", WArrow(Vec3d(0.5, 0.0, 0.0), Vec3d(1.5, 0.0, 0.0), 0.009, Color::raspberry()));
  329. 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)));
  330. viz.showWidget("arr1", WArrow(Vec3d(-0.5, -0.5, 0.0), Vec3d(0.2, 0.2, 0.0), 0.009, Color::raspberry()));
  331. 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)));
  332. viz.showWidget("arr3", WArrow(Vec3d::all(-0.5), Vec3d::all(0.5), 0.009, Color::raspberry()));
  333. viz.showWidget("text2d", WText("Images in 3D", Point(20, 20), 20, Color::green()));
  334. int i = 0;
  335. for(unsigned num = 0; num < 50; ++num)
  336. {
  337. viz.getWidget("img0").cast<WImage3D>().setImage(lena * pow(sin(i++*7.5*CV_PI/180) * 0.5 + 0.5, 1.0));
  338. viz.spinOnce(100, true);
  339. }
  340. viz.showWidget("text2d", WText("Images in 3D (stopped)", Point(20, 20), 20, Color::green()));
  341. viz.spinOnce(500, true);
  342. }
  343. TEST(Viz, show_simple_widgets)
  344. {
  345. Viz3d viz("show_simple_widgets");
  346. viz.setBackgroundMeshLab();
  347. viz.showWidget("coos", WCoordinateSystem());
  348. viz.showWidget("cube", WCube());
  349. viz.showWidget("cub0", WCube(Vec3d::all(-1.0), Vec3d::all(-0.5), false, Color::indigo()));
  350. viz.showWidget("arro", WArrow(Vec3d::all(-0.5), Vec3d::all(0.5), 0.009, Color::raspberry()));
  351. viz.showWidget("cir1", WCircle(0.5, 0.01, Color::bluberry()));
  352. viz.showWidget("cir2", WCircle(0.5, Point3d(0.5, 0.0, 0.0), Vec3d(1.0, 0.0, 0.0), 0.01, Color::apricot()));
  353. viz.showWidget("cyl0", WCylinder(Vec3d(-0.5, 0.5, -0.5), Vec3d(0.5, 0.5, -0.5), 0.125, 30, Color::brown()));
  354. viz.showWidget("con0", WCone(0.25, 0.125, 6, Color::azure()));
  355. viz.showWidget("con1", WCone(0.125, Point3d(0.5, -0.5, 0.5), Point3d(0.5, -1.0, 0.5), 6, Color::turquoise()));
  356. viz.showWidget("text2d", WText("Different simple widgets", Point(20, 20), 20, Color::green()));
  357. viz.showWidget("text3d", WText3D("Simple 3D text", Point3d( 0.5, 0.5, 0.5), 0.125, false, Color::green()));
  358. viz.showWidget("plane1", WPlane(Size2d(0.25, 0.75)));
  359. 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()));
  360. viz.showWidget("grid1", WGrid(Vec2i(7,7), Vec2d::all(0.75), Color::gray()), Affine3d().translate(Vec3d(0.0, 0.0, -1.0)));
  361. viz.spinOnce(500, true);
  362. viz.getWidget("text2d").cast<WText>().setText("Different simple widgets (updated)");
  363. viz.getWidget("text3d").cast<WText3D>().setText("Updated text 3D");
  364. viz.spinOnce(500, true);
  365. }
  366. TEST(Viz, show_follower)
  367. {
  368. Viz3d viz("show_follower");
  369. viz.showWidget("coos", WCoordinateSystem());
  370. viz.showWidget("cube", WCube());
  371. viz.showWidget("t3d_2", WText3D("Simple 3D follower", Point3d(-0.5, -0.5, 0.5), 0.125, true, Color::green()));
  372. viz.showWidget("text2d", WText("Follower: text always facing camera", Point(20, 20), 20, Color::green()));
  373. viz.setBackgroundMeshLab();
  374. viz.spinOnce(500, true);
  375. viz.getWidget("t3d_2").cast<WText3D>().setText("Updated follower 3D");
  376. viz.spinOnce(500, true);
  377. }
  378. }} // namespace