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)?
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.
if ((!size && !repeat_) || (count_ > 0 && playback_count_ >= count_)) {
HOLOSCAN_LOG_INFO("Reach end of file or playback count reaches to the limit. Stop ticking.");
auto bool_cond = boolean_scheduling_term_.get();
bool_cond->disable_tick();
index_file_stream_.clear();
break;
}
// cast Condition to BooleanCondition
auto bool_cond = window_close_scheduling_term_.get();
if (viz::WindowShouldClose()) {
bool_cond->disable_tick();
return;
}