Hello World
For our first example, we look at how to create a Hello World example using the Holoscan SDK.
In this example we’ll cover:
- How to define your application class.
- How to define a one-operator workflow.
- How to use a
CountConditionto limit the number of times an operator is executed.
The example source code and run instructions can be found in the examples directory on GitHub, or under /opt/nvidia/holoscan/examples in the NGC container and the Debian package, alongside their executables.
Defining the HelloWorldApp class
For more details, see the Defining an Application Class section.
We define the HelloWorldApp class that inherits from holoscan’s Application base class. An instance of the application is created in main. The run() method will then start the application.
C++
Python
Defining the HelloWorldApp workflow
For more details, see the Application Workflows section.
When defining your application class, the primary task is to define the operators used in your application, and the interconnectivity between them to define the application workflow. The HelloWorldApp uses the simplest form of a workflow which consists of a single operator: HelloWorldOp.
For the sake of this first example, we will ignore the details of defining a custom operator to focus on the highlighted information below: when this operator runs (compute), it will print out Hello World! to the standard output:
C++
Python
Defining the application workflow occurs within the application’s compose() method. In there, we first create an instance of the HelloWorldOp operator defined above, then add it to our simple workflow using add_operator().
C++
Python
Holoscan applications deal with streaming data, so an operator’s compute() method will be called continuously until some situation arises that causes the operator to stop. For our Hello World example, we want to execute the operator only once. We can impose such a condition by passing a CountCondition object as an argument to the operator’s constructor.
For more details, see the Configuring App Operator Conditions section.
Running the Application
Running the application should give you the following output in your terminal:
Congratulations! You have successfully run your first Holoscan SDK application!