Path: blob/master/modules/viz/test/test_tutorial2.cpp
16354 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.3#include "test_precomp.hpp"45namespace opencv_test { namespace {67static void tutorial2()8{9/// Create a window10viz::Viz3d myWindow("Coordinate Frame");1112/// Add coordinate axes13myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());1415/// Add line to represent (1,1,1) axis16viz::WLine axis(Point3f(-1.0, -1.0, -1.0), Point3d(1.0, 1.0, 1.0));17axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);18myWindow.showWidget("Line Widget", axis);1920/// Construct a cube widget21viz::WCube cube_widget(Point3d(0.5, 0.5, 0.0), Point3d(0.0, 0.0, -0.5), true, viz::Color::blue());22cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);2324/// Display widget (update if already displayed)25myWindow.showWidget("Cube Widget", cube_widget);2627/// Rodrigues vector28Vec3d rot_vec = Vec3d::all(0);29double translation_phase = 0.0, translation = 0.0;30while(!myWindow.wasStopped())31{32/* Rotation using rodrigues */33/// Rotate around (1,1,1)34rot_vec[0] += CV_PI * 0.01;35rot_vec[1] += CV_PI * 0.01;36rot_vec[2] += CV_PI * 0.01;3738/// Shift on (1,1,1)39translation_phase += CV_PI * 0.01;40translation = sin(translation_phase);4142/// Construct pose43Affine3d pose(rot_vec, Vec3d(translation, translation, translation));4445myWindow.setWidgetPose("Cube Widget", pose);4647myWindow.spinOnce(1, true);48}49}505152TEST(Viz, DISABLED_tutorial2_pose_of_widget)53{54tutorial2();55}5657}} // namespace585960