1 Launching Viz {#tutorial_launching_viz}
4 @next_tutorial{tutorial_widget_pose}
9 In this tutorial you will learn how to
11 - Open a visualization window.
12 - Access a window by its name.
14 - Start event loop for a given amount of time.
19 You can download the code from [here ](https://github.com/opencv/opencv/tree/3.4/samples/cpp/tutorial_code/viz/launching_viz.cpp).
20 @include samples/cpp/tutorial_code/viz/launching_viz.cpp
25 Here is the general structure of the program:
30 viz::Viz3d myWindow("Viz Demo");
32 - Start event loop. This event loop will run until user terminates it by pressing **e**, **E**,
38 - Access same window via its name. Since windows are implicitly shared, **sameWindow** is exactly
39 the same with **myWindow**. If the name does not exist, a new window is created.
41 /// Access window via its name
42 viz::Viz3d sameWindow = viz::getWindowByName("Viz Demo");
44 - Start a controlled event loop. Once it starts, **wasStopped** is set to false. Inside the while
45 loop, in each iteration, **spinOnce** is called to prevent event loop from completely stopping.
46 Inside the while loop, user can execute other statements including those which interact with the
49 /// Event loop is over when pressed q, Q, e, E
50 /// Start event loop once for 1 millisecond
51 sameWindow.spinOnce(1, true);
52 while(!sameWindow.wasStopped())
54 /// Interact with window
56 /// Event loop for 1 millisecond
57 sameWindow.spinOnce(1, true);
64 Here is the result of the program.
66 ![](images/window_demo.png)