BooleanCondition / Condition to Stop Operator

We have written a custom replayer operator in Holoscan SDK v0.5.1 with the Python API and want the operator to stop emitting frames when we detect the end of the video file.

We do not want to use a CountCondition because we are replaying at variable speeds and do not know the timing of the end of the video when the operator is instantiated. Is there documentation or sample code on how to use BooleanCondition in the Python API? Is there another way that we can directly communicate with the scheduler to stop the operator (based on a condition that we check within the running operator)?

Hello, thank you for your question and we will take the feedback to add an example on how to user BooleanCondition in the Python API in the future.

(1) We can create an instance of a BooleanCondition like this and use it in an Operator

myCondition = BooleanCondition(self, enable_tick= true, name="specialBoolCondition")
myOp = MyOperator(self, myCondition, name ="mySpecialOp")

At some point later you can change the bool value of the condition with myCondition.disable_tick() and myCondition.enable_tick(). For more details on disable_tick() please see Creating an Application - NVIDIA Docs.

(2) In addition to the method shown above of explicitly creating and passing a BooleanCondition to an operator, in the SDK there are also examples in C++ of defining the boolean condition as a Parameter in the class (but it can also just be a private member) and creating it by default during operator initialization. There are two operators for this: VideoStreamReplayerOp and HolovizOp.

1 Like

We were able to get this working with your help! Thank you very much for pointing us to the right resources and for your detailed guidance.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.