Section 32.3: Vision-language encoders and open-vocabulary detection

A Careful Control Loop
Technical illustration for Section 32.3: Vision-language encoders and open-vocabulary detection.
Figure 32.3A: Open-vocabulary detection pipeline: a text query (a green bottle) is encoded by a language backbone, matched against region proposals via cross-attention, and the highest-scoring region is returned as a grounded bounding box.

Read the figure as an open-vocabulary detection contract. The model may name objects outside a fixed label set, but the robot still needs boxes, masks, frame transforms, confidence calibration, and a rejection path for ambiguous detections.

Closed-loop interface for Vision-language encoders and open-vocabulary detection A four-stage loop connects input, model reasoning, action, and evidence for this page. Image VLM Grounding Memory Observe, decide, act, measure, then feed failure evidence back into the next decision.
Figure 32.3: A closed-loop map for Vision-language encoders and open-vocabulary detection. The diagram forces the reader to name the input, model boundary, action interface, and evidence record before trusting the system.

Build And Evaluation Checklist

Curriculum, depth, and self-containment. Open-vocabulary detection turns language into candidate boxes and masks, but the robot still needs frame transforms, uncertainty, and action-relevant geometry. For Vision-language encoders and open-vocabulary detection, the practical reading is to pin down the interface, assumptions, concrete example, and failure mode before comparing methods.

Production and evaluation contract. Detection is a proposal stage, not a guarantee that the named object is reachable, safe, or task relevant. For Vision-language encoders and open-vocabulary detection, treat the diagram, code, table, exercise, warning, and references as one evidence packet: boundary, artifact, tool choice, transfer check, failure mode, and source grounding.

Checklist Memory Anchor

Before accepting a Vision-language encoders and open-vocabulary detection result, name the loop variable that changed, the tool that makes it reproducible, the failure that would fool the metric, and the source that backs the claim.

Mini Audit Exercise

Write the evidence row around open-vocabulary grounding: query phrase, detector or segmenter version, box or mask geometry, calibration frame, action consumer, false-positive label, and the recovery behavior when the phrase is underspecified.

Big Picture

Open-vocabulary detection lets language propose where the relevant thing might be, not just what is present. In robotics that matters because "pick the yellow sponge near the sink" is a region-selection problem before it becomes a control problem.

What Open-Vocabulary Detection Actually Produces

A grounded detector does not return "the answer." It returns a set of candidate regions conditioned on language. A prompt such as "red mug" yields boxes or points that are semantically relevant, often before the system knows whether the object is graspable, visible enough for tracking, or safe to approach.

That distinction matters because detectors sit upstream of planning. They are proposal generators, much like how A* and sampling planners propose routes that still have to be checked against dynamics and safety constraints.

Proposal, Then Verification

Language-grounded boxes should trigger verification, not immediate actuation. The robot still needs depth, temporal consistency, and interaction affordance before it commits to a grasp or a navigation subgoal.

Scoring Boxes And Masks

A standard grounding stack scores each candidate box $b_i$ for text query $q$ with a detection score and a language-alignment score. A simple decision rule is

$$ \text{score}(b_i \mid q) = s_{\text{det}}(b_i) \cdot \cos\big(e_{\text{region}}(b_i), e_{\text{text}}(q)\big), $$

followed by thresholding, non-maximum suppression, and optional mask refinement. The multiplicative form is useful because it penalizes boxes that are visually dubious even if the language alignment is high. After a box is selected, a promptable segmentation model can turn it into a mask $m_i$, which is often what the robot actually needs for contact planning or free-space reasoning.

Viewed formally, this is a constrained optimization step under uncertainty: maximize the grounded score over proposals while enforcing overlap, visibility, and reachability constraints before the policy is allowed to act. The detector is therefore part of a state-space estimation pipeline, not merely a captioning front end.

You can also read the post-detection filter as a lightweight Bayes update with an implicit covariance budget: image-space evidence proposes hypotheses, geometric checks shrink the feasible set, and the final policy consumes only the survivors whose uncertainty has been reduced enough for action.

The final proposal set is therefore a filtered set $\mathcal B^\star = \operatorname{NMS}(\{b_i : \text{score}(b_i \mid q) \ge \tau\})$ that respects overlap suppression before any action module sees it. That algorithmic detail matters because embodied failures often come from duplicate or conflicting boxes surviving proposal selection, not from the language query alone.

For two proposals $b_i$ and $b_j$, the usual overlap test is $\operatorname{IoU}(b_i, b_j) = \frac{\lvert b_i \cap b_j \rvert}{\lvert b_i \cup b_j \rvert}$, and NMS suppresses the lower-scoring box when $\operatorname{IoU}(b_i, b_j) > \eta$. In robotics that threshold is not a cosmetic hyperparameter, because a too-low $\eta$ can erase small manipulable targets while a too-high $\eta$ can leave duplicate boxes that confuse the grasp selector.

Once a box $b^\star \in \mathcal B^\star$ survives, the embodied handoff is still incomplete until the system derives a world-frame action target, for example $\hat p = \Pi^{-1}(m^\star, D_t, T_{\text{camera}\rightarrow\text{world}})$ from the refined mask $m^\star$, current depth map $D_t$, and camera extrinsics. This makes the contract explicit: open-vocabulary detection proposes image-space regions, while action consumes geometry in a robot frame.

A minimal accept rule is therefore: execute only if $b^\star = \arg\max_{b \in \mathcal B^\star} \text{score}(b \mid q)$, the mask support exceeds a visibility threshold $\lvert m^\star \rvert \ge \kappa$, and the projected target satisfies clearance and reachability checks $c(\hat p) \le 0$. Stated this way, the detector is one stage in a constrained pipeline rather than a oracle.

Algorithm: grounded detection for action

1. Generate candidate boxes from the image and query. 2. Score each box with joint visual and language evidence. 3. Apply non-maximum suppression. 4. Refine the winning boxes into masks. 5. Project the masks into depth or world coordinates. 6. Reject proposals that fail reachability, clearance, or temporal consistency checks.

Written compactly, the pipeline is $$ B_0 = \operatorname{Detect}(I_t, q), \quad s_i = \text{score}(b_i \mid q), \quad B^\star = \operatorname{NMS}(\{b_i \in B_0 : s_i \ge \tau\}), \quad m^\star = \operatorname{Seg}(I_t, b^\star), \quad \hat p = \Pi^{-1}(m^\star, D_t, T_{\text{camera}\rightarrow\text{world}}). $$ That sequence makes the module boundary explicit: language chooses proposals, segmentation sharpens support, and geometry converts the final mask into something a controller can actually use.

Worked Example

Code Fragment 1 compresses that ranking stage into a toy calculation. The goal is to make the selection rule concrete before we hide it behind a maintained GroundingDINO or Grounded-SAM pipeline.

# Rank grounded boxes by combining detector confidence and text alignment.
# This is the minimal decision rule before non-maximum suppression and masking.
# The robot should only pass top-ranked boxes to geometric verification.
import numpy as np

boxes = np.array(["left_box", "center_box", "right_box"])
det_scores = np.array([0.93, 0.74, 0.81], dtype=float)
text_scores = np.array([0.42, 0.89, 0.51], dtype=float)
joint_scores = det_scores * text_scores

best = int(np.argmax(joint_scores))
print({"selected_box": boxes[best], "joint_scores": joint_scores.round(3).tolist()})
{'selected_box': 'center_box', 'joint_scores': [0.391, 0.659, 0.413]}

The expected output is one selected region, center_box, together with three joint scores that show language evidence reshuffling the detector ranking. Reading the trace should make the logic legible: left_box was visually stronger on its own, but after text conditioning the center proposal becomes the correct candidate to pass into NMS, masking, and geometric verification.

Code Fragment 1: The detector alone prefers `left_box`, but once language alignment is included the `center_box` becomes the action candidate. This is exactly why open-vocabulary detection matters in robotics: the system must pick the object the instruction refers to, not merely the most object-like region.

Once the box is selected, the next question is whether the robot needs a rectangle or a pixel-accurate support region. For navigation or rough target selection, a box may be enough. For grasp planning, collision checking, or object-centric memory, a mask is usually much more useful.

Library Shortcut

The hand-built ranking rule takes 8 lines and makes the semantics obvious. In production, the same box-to-mask pipeline can be assembled in roughly 8 to 12 lines using GroundingDINO plus SAM or SAM 2. The maintained libraries handle prompt encoding, proposal generation, and mask refinement internally.

Code Fragment 2 shows the maintained pattern at the point where most builders actually work.

# Ground a phrase to boxes, then refine the boxes into masks.
# pip install groundingdino-py segment-anything
# The detector proposes regions; the segmenter sharpens them for action.
image = load_image("tabletop_scene.png")
boxes, phrases = grounding_dino_predict(image, text_prompt="red mug", box_threshold=0.35)
masks = sam_refine_masks(image=image, boxes=boxes)

print({"num_boxes": len(boxes), "num_masks": len(masks), "top_phrase": phrases[0]})
{'num_boxes': 2, 'num_masks': 2, 'top_phrase': 'red mug'}

The expected output is a small proposal set where the number of masks matches the surviving number of boxes and the top phrase remains tied to the user query. In a healthy GroundingDINO plus SAM-style pipeline, this tells the builder the semantic proposal stage and the geometric refinement stage stayed synchronized; if the counts diverged or the phrase changed, the handoff between detection and segmentation would need inspection.

Code Fragment 2: This maintained pipeline shows the actual division of labor in open-vocabulary perception: GroundingDINO proposes text-conditioned boxes, and SAM-style segmentation sharpens them into masks. That shortcut saves substantial implementation effort while preserving the explicit interface between semantics and geometry.

Promptable Segmentation And 3D Follow-Through

A box is rarely the end of the story. If the robot must grasp, avoid, or remember the object, it often needs the mask to intersect with depth. The mask can be lifted into a point cloud, used to fit a 3D extent, or stored as a memory key for later re-identification. This is one of the clearest bridges from Chapter 32 to occupancy and neural scene representations.

Common Failure Mode

A grounded detector can return a semantically correct box around the wrong physical instance, such as the reflection of a mug in glass or a poster of a door instead of the real door. If the pipeline does not check depth, motion, or interaction affordance, the controller may act confidently on a non-actionable target.

Practical Example

A home robot asked to "pick up the sponge next to the sink" can use grounded detection to rank candidate regions, segmentation to isolate the object pixels, and depth projection to decide which sponge is actually on the counter rather than in the mirrored backsplash. The grounded box starts the reasoning, but the geometry finishes it.

Memory Hook

Open-vocabulary detection is like a good stage manager. It points the spotlight at the actor the script refers to, but the rest of the crew still has to make sure that actor is really on stage and not just in the backdrop.

Research Frontier

Grounded SAM and Grounded SAM 2 push this pipeline from single images toward video grounding and tracking. The active frontier is maintaining identity and actionable masks across time so a robot can keep following the same object while the camera and scene both move.

Self Check

Would your current pipeline know what to do if two boxes both match the phrase "red mug" but only one is reachable? If the answer is no, your detector still lacks the verification stage that embodiment requires.

The most useful diagnostic artifact for this section is a four-panel record: original image, top grounded boxes with scores, selected mask over depth, and the final action decision. That artifact lets you see whether the failure arose from phrase grounding, box ranking, mask quality, or geometric follow-through. It also stops teams from reporting open-vocabulary success on screenshots while the physical robot still grasps the wrong object.

Tool Choices For Grounded Detection
ToolRoleUse It When
GroundingDINOText-conditioned box proposalsYou need open-vocabulary region proposals from natural language.
SAM or SAM 2Promptable mask refinementYou need pixel support for grasping, collision checks, or memory.
OpenCVCrop logic and geometric post-processingYou need explicit image-space checks before world projection.
ROS 2 tf and depth topicsProjection to world and timing checksYou need the mask to survive into a frame-aware action interface.
Key Takeaway

Open-vocabulary detection is powerful because it turns language into candidate action regions. It becomes embodied only after those regions are verified, segmented, and projected into the geometry the robot can actually use.

Exercise 32.3.1

Design a box-to-mask-to-action pipeline for one household task. State the text prompt, the grounded proposal rule, the geometric verification step, and the condition under which the robot should ask for another view instead of acting.

Bibliography and Further Reading
Primary Sources and Tools

Liu et al. (2023). "Grounding DINO: Marrying DINO with Grounded Pre-Training for Open-Set Object Detection."

The central open-vocabulary detection reference for text-conditioned boxes.

Paper

Kirillov et al. (2023). "Segment Anything."

The promptable segmentation baseline that turns boxes or points into masks usable for robotics.

Paper

Ren et al. (2024). "Grounded SAM: Assembling Open-World Models for Diverse Visual Tasks."

A practical integration paper showing how grounding and segmentation can be composed into a wider open-world perception pipeline.

Paper

IDEA Research (2024-2026). "Grounded SAM 2" GitHub repository.

Useful for current video-grounding and track-anything workflows, especially when Chapter 32 ideas must survive across time rather than only on one image.

Repository