23
23
#include < holoscan/operators/holoviz/holoviz.hpp>
24
24
#include < holoscan/operators/inference/inference.hpp>
25
25
#include < holoscan/operators/inference_processor/inference_processor.hpp>
26
+ #include < holoscan/operators/video_stream_recorder/video_stream_recorder.hpp>
26
27
#include < holoscan/operators/video_stream_replayer/video_stream_replayer.hpp>
28
+
27
29
#include < holoscan/version_config.hpp>
28
30
29
31
#include < visualizer_icardio.hpp>
@@ -37,12 +39,25 @@ class App : public holoscan::Application {
37
39
if (source == " aja" ) { is_aja_source_ = true ; }
38
40
}
39
41
42
+ enum class Record { NONE, INPUT, VISUALIZER };
43
+
44
+ void set_record (const std::string& record) {
45
+ if (record == " input" ) {
46
+ record_type_ = Record::INPUT;
47
+ } else if (record == " visualizer" ) {
48
+ record_type_ = Record::VISUALIZER;
49
+ }
50
+ }
51
+
40
52
void set_datapath (const std::string& path) { datapath = path; }
41
53
42
54
void compose () override {
43
55
using namespace holoscan ;
44
56
45
57
std::shared_ptr<Operator> source;
58
+ std::shared_ptr<Operator> recorder;
59
+ std::shared_ptr<Operator> recorder_format_converter;
60
+
46
61
const std::shared_ptr<CudaStreamPool> cuda_stream_pool =
47
62
make_resource<CudaStreamPool>(" cuda_stream" );
48
63
@@ -143,10 +158,34 @@ class App : public holoscan::Application {
143
158
Arg (" cuda_stream_pool" ) = cuda_stream_pool);
144
159
145
160
auto holoviz = make_operator<ops::HolovizOp>(
146
- " holoviz" , from_config (" holoviz" ), Arg (" cuda_stream_pool" ) = cuda_stream_pool);
161
+ " holoviz" , from_config (" holoviz" ),
162
+ Arg (" enable_render_buffer_output" ) = (record_type_ == Record::VISUALIZER),
163
+ Arg (" allocator" ) =
164
+ make_resource<BlockMemoryPool>(" visualizer_allocator" ,
165
+ (int32_t )nvidia::gxf::MemoryStorageType::kDevice ,
166
+ // max from VisualizerICardioOp::tensor_to_shape_
167
+ 320 * 320 * 4 * sizeof (uint8_t ),
168
+ 1 * 8 ),
169
+ Arg (" cuda_stream_pool" ) = cuda_stream_pool);
147
170
148
- // Flow definition
149
171
172
+ // Add recording operators
173
+ if (record_type_ != Record::NONE) {
174
+ if (((record_type_ == Record::INPUT) && is_aja_source_) ||
175
+ (record_type_ == Record::VISUALIZER)) {
176
+ recorder_format_converter = make_operator<ops::FormatConverterOp>(
177
+ " recorder_format_converter" ,
178
+ from_config (" recorder_format_converter" ),
179
+ Arg (" pool" ) =
180
+ make_resource<BlockMemoryPool>(" pool" ,
181
+ (int32_t )nvidia::gxf::MemoryStorageType::kDevice ,
182
+ 320 * 320 * 4 * sizeof (uint8_t ),
183
+ 1 * 8 ));
184
+ }
185
+ recorder = make_operator<ops::VideoStreamRecorderOp>(" recorder" , from_config (" recorder" ));
186
+ }
187
+
188
+ // Flow definition
150
189
const std::string source_port_name = is_aja_source_ ? " video_buffer_output" : " " ;
151
190
add_flow (source, plax_cham_pre, {{source_port_name, " " }});
152
191
add_flow (source, aortic_ste_pre, {{source_port_name, " " }});
@@ -168,10 +207,26 @@ class App : public holoscan::Application {
168
207
add_flow (visualizer_icardio, holoviz, {{" keyarea_5" , " receivers" }});
169
208
add_flow (visualizer_icardio, holoviz, {{" lines" , " receivers" }});
170
209
add_flow (visualizer_icardio, holoviz, {{" logo" , " receivers" }});
210
+
211
+
212
+ if (record_type_ == Record::INPUT) {
213
+ if (is_aja_source_) {
214
+ add_flow (source, recorder_format_converter, {{source_port_name, " source_video" }});
215
+ add_flow (recorder_format_converter, recorder);
216
+ } else {
217
+ add_flow (source, recorder);
218
+ }
219
+ } else if (record_type_ == Record::VISUALIZER) {
220
+ add_flow (holoviz,
221
+ recorder_format_converter,
222
+ {{" render_buffer_output" , " source_video" }});
223
+ add_flow (recorder_format_converter, recorder);
224
+ }
171
225
}
172
226
173
227
private:
174
228
bool is_aja_source_ = false ;
229
+ Record record_type_ = Record::NONE;
175
230
std::string datapath = " data/multiai_ultrasound" ;
176
231
};
177
232
@@ -214,6 +269,10 @@ int main(int argc, char** argv) {
214
269
215
270
auto source = app->from_config (" source" ).as <std::string>();
216
271
app->set_source (source);
272
+
273
+ auto record_type = app->from_config (" record_type" ).as <std::string>();
274
+ app->set_record (record_type);
275
+
217
276
if (data_path != " " ) app->set_datapath (data_path);
218
277
app->run ();
219
278
0 commit comments