MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / loop

Function loop

react-native/pose-detection/App.tsx:130–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128 gl: ExpoWebGLRenderingContext
129 ) => {
130 const loop = async () => {
131 // Get the tensor and run pose detection.
132 const imageTensor = images.next().value as tf.Tensor3D;
133
134 const startTs = Date.now();
135 const poses = await model!.estimatePoses(
136 imageTensor,
137 undefined,
138 Date.now()
139 );
140 const latency = Date.now() - startTs;
141 setFps(Math.floor(1000 / latency));
142 setPoses(poses);
143 tf.dispose([imageTensor]);
144
145 if (rafId.current === 0) {
146 return;
147 }
148
149 // Render camera preview manually when autorender=false.
150 if (!AUTO_RENDER) {
151 updatePreview();
152 gl.endFrameEXP();
153 }
154
155 rafId.current = requestAnimationFrame(loop);
156 };
157
158 loop();
159 };

Callers 1

handleCameraStreamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected