MCPcopy Index your code
hub / github.com/tensorflow/tfjs / toTexture

Function toTexture

tfjs-react-native/src/camera/camera.ts:109–125  ·  view source on GitHub ↗
(
    gl: WebGL2RenderingContext, imageTensor: tf.Tensor3D,
    texture?: WebGLTexture)

Source from the content-addressed store, hash-verified

107 * @doc {heading: 'Media', subheading: 'Camera'}
108 */
109export 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.

Callers 1

camera_test.tsFile · 0.90

Calls 2

uploadTextureDataFunction · 0.90
dataMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…