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