Doxygen tutorials: cpp done
This commit is contained in:
@@ -15,36 +15,35 @@ Code
|
||||
----
|
||||
|
||||
You can download the code from [here ](samples/cpp/tutorial_code/viz/launching_viz.cpp).
|
||||
@code{.cpp}
|
||||
#include <opencv2/viz.hpp>
|
||||
#include <iostream>
|
||||
@includelineno samples/cpp/tutorial_code/viz/launching_viz.cpp
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
Explanation
|
||||
-----------
|
||||
|
||||
/*
|
||||
* @function main
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
Here is the general structure of the program:
|
||||
|
||||
- Create a window.
|
||||
@code{.cpp}
|
||||
/// Create a window
|
||||
viz::Viz3d myWindow("Viz Demo");
|
||||
|
||||
@endcode
|
||||
- Start event loop. This event loop will run until user terminates it by pressing **e**, **E**,
|
||||
**q**, **Q**.
|
||||
@code{.cpp}
|
||||
/// Start event loop
|
||||
myWindow.spin();
|
||||
|
||||
/// Event loop is over when pressed q, Q, e, E
|
||||
cout << "First event loop is over" << endl;
|
||||
|
||||
@endcode
|
||||
- Access same window via its name. Since windows are implicitly shared, **sameWindow** is exactly
|
||||
the same with **myWindow**. If the name does not exist, a new window is created.
|
||||
@code{.cpp}
|
||||
/// Access window via its name
|
||||
viz::Viz3d sameWindow = viz::getWindowByName("Viz Demo");
|
||||
|
||||
/// Start event loop
|
||||
sameWindow.spin();
|
||||
|
||||
/// Event loop is over when pressed q, Q, e, E
|
||||
cout << "Second event loop is over" << endl;
|
||||
|
||||
viz::Viz3d sameWindow = viz::get("Viz Demo");
|
||||
@endcode
|
||||
- Start a controlled event loop. Once it starts, **wasStopped** is set to false. Inside the while
|
||||
loop, in each iteration, **spinOnce** is called to prevent event loop from completely stopping.
|
||||
Inside the while loop, user can execute other statements including those which interact with the
|
||||
window.
|
||||
@code{.cpp}
|
||||
/// Event loop is over when pressed q, Q, e, E
|
||||
/// Start event loop once for 1 millisecond
|
||||
sameWindow.spinOnce(1, true);
|
||||
@@ -55,54 +54,11 @@ int main()
|
||||
/// Event loop for 1 millisecond
|
||||
sameWindow.spinOnce(1, true);
|
||||
}
|
||||
@endcode
|
||||
|
||||
/// Once more event loop is stopped
|
||||
cout << "Last event loop is over" << endl;
|
||||
return 0;
|
||||
}
|
||||
@endcode
|
||||
Explanation
|
||||
-----------
|
||||
|
||||
Here is the general structure of the program:
|
||||
|
||||
- Create a window.
|
||||
@code{.cpp}
|
||||
/// Create a window
|
||||
viz::Viz3d myWindow("Viz Demo");
|
||||
@endcode
|
||||
- Start event loop. This event loop will run until user terminates it by pressing **e**, **E**,
|
||||
**q**, **Q**.
|
||||
@code{.cpp}
|
||||
/// Start event loop
|
||||
myWindow.spin();
|
||||
@endcode
|
||||
- Access same window via its name. Since windows are implicitly shared, **sameWindow** is exactly
|
||||
the same with **myWindow**. If the name does not exist, a new window is created.
|
||||
@code{.cpp}
|
||||
/// Access window via its name
|
||||
viz::Viz3d sameWindow = viz::get("Viz Demo");
|
||||
@endcode
|
||||
- Start a controlled event loop. Once it starts, **wasStopped** is set to false. Inside the while
|
||||
loop, in each iteration, **spinOnce** is called to prevent event loop from completely stopping.
|
||||
Inside the while loop, user can execute other statements including those which interact with the
|
||||
window.
|
||||
@code{.cpp}
|
||||
/// Event loop is over when pressed q, Q, e, E
|
||||
/// Start event loop once for 1 millisecond
|
||||
sameWindow.spinOnce(1, true);
|
||||
while(!sameWindow.wasStopped())
|
||||
{
|
||||
/// Interact with window
|
||||
|
||||
/// Event loop for 1 millisecond
|
||||
sameWindow.spinOnce(1, true);
|
||||
}
|
||||
@endcode
|
||||
Results
|
||||
-------
|
||||
|
||||
Here is the result of the program.
|
||||
|
||||

|
||||
|
||||

|
||||
|
Reference in New Issue
Block a user