Resources from the book

2D Intercept Function

Section 21.5 · Test whether two inference boxes overlap by a positive area.

Section 21.5.1

Purpose

Determine whether two bounding boxes produced during inference intersect. This helper is used in Qualified Detections, where the relationship between detections contributes to a condition.

Section 21.5.2

Why It Exists

A detection’s presence alone may not establish the condition you need. The book gives the example of a cable end and a plug connection point: intersecting boxes can be used as the overlap condition for identifying a plugged-in cable.

This function supplies the geometric test. Your application decides which labels to compare and what that overlap means.

Section 21.5.3

Input

The book provides two versions of bounding_box_2d_intercept:

  • Individual box components: pass the upper-left X and Y positions, width, and height for each box as eight integers.
  • BoundingBox objects: pass two object handles; the function reads x, y, width, and height.
Use upper-left pixel coordinates.

These are inference coordinates, not normalized center-based training annotations. Both boxes must use the same image coordinate system. Supply valid boxes with positive widths and heights, and valid objects for the handle version.

Class IDs, label names, confidence, and display colors are not part of the overlap calculation.

Review 21.1 · Inference Data & BoundingBox →

Section 21.5.4

Output

The return value is true or false. A true result requires overlap with positive width and positive height. Merely touching an edge or corner returns false.

Positive overlaptrueEdge contactfalseCorner contactfalse
RelationshipResult
Partial overlaptrue
One box fully inside the othertrue
Identical valid boxestrue
Separated boxesfalse
Edge-only or corner-only contactfalse

The strict > comparisons implement that positive-area rule. Changing them to >= would change the treatment of touching boxes.

The guide behind the codeFrom the page
to the plant floor.
Practical Guide to AI Computer Vision Integration in Industrial ManufacturingExplore the Book