NVIDIA Holoscan SDK v1.0.3
v1.0.3

Class FormatConverterOp

class FormatConverterOp : public holoscan::Operator

Operator class to convert the data format of the input data.

Named inputs:

  • source_video: nvidia::gxf::Tensor or nvidia::gxf::VideoBuffer

    • The input video frame to process. If the input is a VideoBuffer it must be in format GXF_VIDEO_FORMAT_RGBA, GXF_VIDEO_FORMAT_RGB or GXF_VIDEO_FORMAT_NV12. This video buffer may be in either host or device memory (a host->device copy is performed if needed). If a video buffer is not found, the input port message is searched for a tensor with the name specified by in_tensor_name. This must be a device tensor in one of several supported formats (unsigned 8-bit int or float32 graycale, unsigned 8-bit int RGB or RGBA YUV420 or NV12).

Named outputs:

  • tensor: nvidia::gxf::Tensor

    • The output video frame after processing. The shape, data type and number of channels of this output tensor will depend on the specific parameters that were set for this operator. The name of the Tensor transmitted on this port is determined by out_tensor_name.

Public Functions

HOLOSCAN_OPERATOR_FORWARD_ARGS (FormatConverterOp) FormatConverterOp()=default

virtual void setup(OperatorSpec &spec) override

Define the operator specification.

Parameters

spec – The reference to the operator specification.

virtual void initialize() override

Initialize the operator.

This function is called when the fragment is initialized by Executor::initialize_fragment().

virtual void start() override

Implement the startup logic of the operator.

This method is called multiple times over the lifecycle of the operator according to the order defined in the lifecycle, and used for heavy initialization tasks such as allocating memory resources.

virtual void compute(InputContext &op_input, OutputContext &op_output, ExecutionContext &context) override

Implement the compute method.

This method is called by the runtime multiple times. The runtime calls this method until the operator is stopped.

Parameters
  • op_input – The input context of the operator.

  • op_output – The output context of the operator.

  • context – The execution context of the operator.

virtual void stop() override

Implement the shutdown logic of the operator.

This method is called multiple times over the lifecycle of the operator according to the order defined in the lifecycle, and used for heavy deinitialization tasks such as deallocation of all resources previously assigned in start.

nvidia::gxf::Expected<void*> resizeImage(const void *in_tensor_data, const std::vector<nvidia::gxf::ColorPlane> &in_color_planes, const int32_t rows, const int32_t columns, const int16_t channels, const nvidia::gxf::PrimitiveType primitive_type, const int32_t resize_width, const int32_t resize_height)

void convertTensorFormat(const void *in_tensor_data, const std::vector<nvidia::gxf::ColorPlane> &in_color_planes, void *out_tensor_data, const int32_t rows, const int32_t columns, const int16_t out_channels)

Previous Class BayerDemosaicOp
Next Class ForwardOp
© Copyright 2022-2023, NVIDIA. Last updated on Apr 19, 2024.