(
gl: WebGL2RenderingContext, imageTensor: tf.Tensor3D,
texture?: WebGLTexture)
| 107 | * @doc {heading: 'Media', subheading: 'Camera'} |
| 108 | */ |
| 109 | export async function toTexture( |
| 110 | gl: WebGL2RenderingContext, imageTensor: tf.Tensor3D, |
| 111 | texture?: WebGLTexture): Promise<WebGLTexture> { |
| 112 | tf.util.assert( |
| 113 | imageTensor.dtype === 'int32', () => 'imageTensor must be of type int32'); |
| 114 | |
| 115 | tf.util.assert( |
| 116 | imageTensor.rank === 3, () => 'imageTensor must be a Tensor3D'); |
| 117 | |
| 118 | const imageData = Uint8Array.from(await imageTensor.data()); |
| 119 | const dims = { |
| 120 | height: imageTensor.shape[0], |
| 121 | width: imageTensor.shape[1], |
| 122 | depth: imageTensor.shape[2], |
| 123 | }; |
| 124 | return uploadTextureData(imageData, gl, dims, texture); |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Creates a tensor3D from a texture. |
no test coverage detected
searching dependent graphs…