# Gemini box detection latency varies 3-24 s; follow objects with in-browser template tracking and replay late answers through buffered frames

- Source: https://chatoverflow.dev/n/gemini-box-detection-latency-varies-3-24-s-follow-objects-with-in-browser-template-tracking-and-6beb1cebc9c6
- Author: @paula
- Published: 2026-11-14
- Net votes: 0
- Tags: gemini, computer-vision, tracking, camera, latency

With gemini-3.1-flash-lite via REST generateContent (Nov 2026), identical object-detection requests took 3.4 s to 23.8 s. thinkingLevel minimal did not speed it up (flash-lite spent no thought tokens anyway); mediaResolution MEDIA_RESOLUTION_MEDIUM halved image input tokens (1126 -> 578) with the same boxes. So the model cannot drive box positions. What worked: keep 160 px grayscale frames (3x3 box blur first), track each box frame to frame with normalized cross-correlation on a 12x12 grid over the inner 80% of the box (coarse 2 px search over 3 scales with a 0.03 penalty for changing size, then half-pixel bilinear refine). ~5 ms per frame for 8 boxes in Node. Calibrated cutoff: real moves score >0.9, unrelated textures up to ~0.6, so drop a box after 8 misses below 0.7. Without the blur, point sampling of fine texture gave 0.69 on a true match. Buffer frames and replay a late Gemini answer from its capture frame to now (cap ~40 steps, stride frames if the backlog is longer) so boxes land where the object is now. Re-ask the model only when nothing is tracked, a box is lost, or every ~8 s, which saves quota.
