Class TextureConverter
Provides methods for converting between textures and tensors.
Inherited Members
Namespace: Unity.InferenceEngine
Assembly: Unity.InferenceEngine.dll
Syntax
[MovedFrom("Unity.Sentis")]
public static class TextureConverter
Methods
RenderToScreen(Tensor<float>, TextureTransform)
Write the float data in a tensor to the frame buffer. Inference Engine only writes batch == 0 to the frame buffer.
If the width and height of the tensor don't match the width and height of the frame buffer, Inference Engine applies linear resampling.
Declaration
public static void RenderToScreen(Tensor<float> tensor, TextureTransform transform = default)
Parameters
Type | Name | Description |
---|---|---|
Tensor<float> | tensor | The input tensor. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
RenderToScreen(CommandBuffer, Tensor<float>, TextureTransform)
Appends the write the float data in a tensor to the frame buffer texture in a CommandBuffer. Inference Engine only writes batch == 0 to the frame buffer.
If the width and height of the tensor don't match the width and height of the frame buffer, Inference Engine applies linear resampling.
Declaration
public static void RenderToScreen(this CommandBuffer cb, Tensor<float> tensor, TextureTransform transform = default)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
Tensor<float> | tensor | The input tensor. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
RenderToScreen(CommandBuffer, Tensor<float>, RenderTargetIdentifier, TextureTransform)
Appends the write the float data in a tensor to the render target identifier in a CommandBuffer. Inference Engine only writes batch == 0 to the frame buffer.
If the width and height of the tensor don't match the width and height of the frame buffer, Inference Engine applies linear resampling.
Declaration
public static void RenderToScreen(this CommandBuffer cb, Tensor<float> tensor, RenderTargetIdentifier rte, TextureTransform transform = default)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
Tensor<float> | tensor | The input tensor. |
RenderTargetIdentifier | rte | The render target identifier to write to. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
RenderToTexture(Tensor<float>, RenderTexture, TextureTransform)
Write the float data in a tensor to a render texture. Inference Engine only writes batch == 0 to the render texture.
If the width and height of the tensor don't match the width and height of the render texture, Inference Engine applies linear resampling.
Declaration
public static void RenderToTexture(Tensor<float> tensor, RenderTexture renderTexture, TextureTransform transform = default)
Parameters
Type | Name | Description |
---|---|---|
Tensor<float> | tensor | The input tensor. |
RenderTexture | renderTexture | The render texture to write to. If the value is |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
RenderToTexture(CommandBuffer, Tensor<float>, RenderTexture, TextureTransform)
Appends the write the float data in a tensor to a render texture in a CommandBuffer. Inference Engine only writes batch == 0 to the render texture.
If the width and height of the tensor don't match the width and height of the render texture, Inference Engine applies linear resampling.
Declaration
public static void RenderToTexture(this CommandBuffer cb, Tensor<float> tensor, RenderTexture renderTexture, TextureTransform transform = default)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
Tensor<float> | tensor | The input tensor. |
RenderTexture | renderTexture | The render texture to write to. If the value is |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
ToTensor(CommandBuffer, RenderTargetIdentifier, Tensor<float>, TextureTransform)
Appends the conversion of a RenderTargetIdentifier to a Tensor<float>
to a CommandBuffer. The number of channels of the output tensor can be at most the number of channels in the input texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
public static void ToTensor(this CommandBuffer cb, RenderTargetIdentifier rte, Tensor<float> tensor, TextureTransform transform = default)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
RenderTargetIdentifier | rte | The RenderTargetIdentifier to convert. |
Tensor<float> | tensor | The output tensor. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
ToTensor(CommandBuffer, RenderTargetIdentifier, TextureTransform)
Appends the conversion of a RenderTargetIdentifier to a Tensor<float>
to a CommandBuffer. The number of channels of the output tensor can be at most the number of channels in the input texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
[Obsolete("`Tensor<float> ToTensor(this CommandBuffer cb, RenderTargetIdentifier rte, TextureTransform transform = default)` is deprecated, please use `void ToTensor(this CommandBuffer cb, RenderTargetIdentifier rte, Tensor<float> tensor, TextureTransform transform = default)` instead.")]
public static Tensor<float> ToTensor(this CommandBuffer cb, RenderTargetIdentifier rte, TextureTransform transform = default)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
RenderTargetIdentifier | rte | The RenderTargetIdentifier to convert. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
Returns
Type | Description |
---|---|
Tensor<float> | The converted tensor. |
ToTensor(CommandBuffer, Texture, int, int, int)
Appends the conversion of a texture to a Tensor<float>
to a CommandBuffer`. The number of channels of the output tensor can be at most the number of channels in the input texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
[Obsolete("`Tensor<float> ToTensor(this CommandBuffer cb, Texture texture, int width = -1, int height = -1, int channels = -1)` is deprecated, please use `void ToTensor(this CommandBuffer cb, Texture texture, Tensor<float> tensor, TextureTransform transform)` instead.")]
public static Tensor<float> ToTensor(this CommandBuffer cb, Texture texture, int width = -1, int height = -1, int channels = -1)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
Texture | texture | The texture to convert. Must be a Texture2D. |
int | width | The width of the output tensor. If the value is -1, Inference Engine uses the texture to infer the width. |
int | height | The height of the output tensor. If the value is -1, Inference Engine uses the texture to infer the height. |
int | channels | The numbers of channels of the output tensor. If the value is -1, Inference Engine uses the texture to infer the number of channels. |
Returns
Type | Description |
---|---|
Tensor<float> | The converted tensor. |
ToTensor(CommandBuffer, Texture, Tensor<float>, TextureTransform)
Appends the conversion of a texture to a Tensor<float>
to a CommandBuffer. The number of channels of the output tensor can be at most the number of channels in the input texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
public static void ToTensor(this CommandBuffer cb, Texture texture, Tensor<float> tensor, TextureTransform transform = default)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
Texture | texture | The texture to convert. Must be a Texture2D. |
Tensor<float> | tensor | The output tensor. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
ToTensor(CommandBuffer, Texture, TextureTransform)
Appends the conversion of a texture to a Tensor<float>
to a CommandBuffer. The number of channels of the output tensor can be at most the number of channels in the input texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
[Obsolete("`Tensor<float> ToTensor(this CommandBuffer cb, Texture texture, TextureTransform transform)` is deprecated, please use `void ToTensor(this CommandBuffer cb, Texture texture, Tensor<float> tensor, TextureTransform transform)` instead.")]
public static Tensor<float> ToTensor(this CommandBuffer cb, Texture texture, TextureTransform transform)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
Texture | texture | The texture to convert. Must be a Texture2D. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
Returns
Type | Description |
---|---|
Tensor<float> | The converted tensor. |
ToTensor(Texture, int, int, int)
Converts a texture to a Tensor<float>
. The number of channels of the output tensor can be at most the number of channels in the input texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
[Obsolete("`Tensor<float> ToTensor(Texture texture, int width = -1, int height = -1, int channels = -1)` is deprecated, please use `void ToTensor(Texture texture, Tensor<float> tensor, TextureTransform transform)` instead.")]
public static Tensor<float> ToTensor(Texture texture, int width = -1, int height = -1, int channels = -1)
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | The texture to convert. Must be a Texture2D. |
int | width | The width of the output tensor. If the value is -1, Inference Engine uses the texture to infer the width. |
int | height | The height of the output tensor. If the value is -1, Inference Engine uses the texture to infer the height. |
int | channels | The numbers of channels of the output tensor. If the value is -1, Inference Engine uses the texture to infer the number of channels. |
Returns
Type | Description |
---|---|
Tensor<float> | The converted tensor. |
ToTensor(Texture, Tensor<float>, TextureTransform)
Converts a texture to a Tensor<float>
. The number of channels of the output tensor can be at most the number of channels in the input texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
public static void ToTensor(Texture texture, Tensor<float> tensor, TextureTransform transform = default)
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | The texture to convert. Must be a Texture2D. |
Tensor<float> | tensor | The output tensor. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
ToTensor(Texture, TextureTransform)
Converts a texture to a Tensor<float>
. The number of channels of the output tensor can be at most the number of channels in the input texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
[Obsolete("`Tensor<float> ToTensor(Texture texture, TextureTransform transform)` is deprecated, please use `void ToTensor(Texture texture, Tensor<float> tensor, TextureTransform transform)` instead.")]
public static Tensor<float> ToTensor(Texture texture, TextureTransform transform)
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | The texture to convert. Must be a Texture2D. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
Returns
Type | Description |
---|---|
Tensor<float> | The converted tensor. |
ToTexture(Tensor<float>, int, int, int, bool)
Converts the data in a tensor to a render texture. Inference Engine only writes batch == 0 to the render texture.
If the width and height of the render texture don't match the width and height of the tensor, Inference Engine applies linear resampling.
Declaration
[Obsolete("`RenderTexture ToTexture(Tensor<float> tensor, int width = -1, int height = -1, int channels = -1, bool broadcastChannels = false)` is deprecated, please use `void RenderToTexture(Tensor<float> tensor, RenderTexture renderTexture, TextureTransform transform = default)` instead.")]
public static RenderTexture ToTexture(Tensor<float> tensor, int width = -1, int height = -1, int channels = -1, bool broadcastChannels = false)
Parameters
Type | Name | Description |
---|---|---|
Tensor<float> | tensor | The input tensor. |
int | width | The width of the output render texture. If the value is -1, Inference Engine uses the tensor to infer the width. |
int | height | The height of the output render texture. If the value is -1, Inference Engine uses the tensor to infer the height. |
int | channels | The numbers of channels of the output render texture. If the value is -1, Inference Engine uses the tensor to infer the number of channels. |
bool | broadcastChannels | When the value is |
Returns
Type | Description |
---|---|
RenderTexture | The created render texture. |
ToTexture(Tensor<float>, TextureTransform)
Converts the data in a tensor to a render texture. Inference Engine only writes batch == 0 to the render texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
[Obsolete("`RenderTexture ToTexture(Tensor<float> tensor, TextureTransform transform)` is deprecated, please use `RenderToTexture(Tensor<float> tensor, RenderTexture renderTexture, TextureTransform transform = default)` instead.")]
public static RenderTexture ToTexture(Tensor<float> tensor, TextureTransform transform)
Parameters
Type | Name | Description |
---|---|---|
Tensor<float> | tensor | The input tensor. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
Returns
Type | Description |
---|---|
RenderTexture | The created render texture. |
ToTexture(CommandBuffer, Tensor<float>, int, int, int, bool)
Appends the conversion of the data in a tensor to a render texture to a CommandBuffer. Inference Engine only writes batch == 0 to the render texture.
If the width and height of the render texture don't match the width and height of the tensor, Inference Engine applies linear resampling.
Declaration
[Obsolete("`RenderTexture ToTexture(this CommandBuffer cb, Tensor<float> tensor, int width = -1, int height = -1, int channels = -1, bool broadcastChannels = false)` is deprecated, please use `RenderToTexture(this CommandBuffer cb, Tensor<float> tensor, RenderTexture renderTexture, TextureTransform transform = default)` instead.")]
public static RenderTexture ToTexture(this CommandBuffer cb, Tensor<float> tensor, int width = -1, int height = -1, int channels = -1, bool broadcastChannels = false)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
Tensor<float> | tensor | The input tensor. |
int | width | The width of the output render texture. If the value is -1, Inference Engine uses the tensor to infer the width. |
int | height | The height of the output render texture. If the value is -1, Inference Engine uses the tensor to infer the height. |
int | channels | The numbers of channels of the output render texture. If the value is -1, Inference Engine uses the tensor to infer the number of channels. |
bool | broadcastChannels | When the value is |
Returns
Type | Description |
---|---|
RenderTexture | The created render texture. |
ToTexture(CommandBuffer, Tensor<float>, TextureTransform)
Appends the conversion of the data in a tensor to a render texture in a CommandBuffer. Inference Engine only writes batch == 0 to the render texture.
If the width and height of the output tensor don't match the width and height of the texture, Inference Engine applies linear resampling.
Declaration
[Obsolete("`RenderTexture ToTexture(this CommandBuffer cb, Tensor<float> tensor, TextureTransform transform)` is deprecated, please use `void RenderToTexture(this CommandBuffer cb, Tensor<float> tensor, RenderTexture renderTexture, TextureTransform transform = default)` instead.")]
public static RenderTexture ToTexture(this CommandBuffer cb, Tensor<float> tensor, TextureTransform transform)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cb | The CommandBuffer buffer to append graphics command to. |
Tensor<float> | tensor | The input tensor. |
TextureTransform | transform | The optional settings for the conversion. Refer to TextureTransform for more information. |
Returns
Type | Description |
---|---|
RenderTexture | The created render texture. |