Computer vision answers · Object Counting
How do I stop computer vision from double-counting objects that overlap or touch?
Without a count that jumps every time two items touch.
Short answer
Train an object detection model on Roboflow for free with one tight box per object, including objects that touch, then remove duplicate boxes with class-agnostic non-maximum suppression before you count. On video, track each object and count it once when it crosses a line, not once per frame. Measure overlap against the smaller box, so a duplicate box sitting inside an object is removed but two neighbors that only touch both stay.
Skip the setup. Describe your images.
Describe your images and what you need to find. The agent sets up labeling, training and deployment with you.
Key facts
- What you need
- Images or video of the objects, and a detection model trained on them
- What you get
- One detection per object, so each count matches what is there
- Image sources
- Cameras, phone photos, scans and recorded video
- Runs on
- Cloud API, or an edge device or server running Docker

How to build object counting without double counts, step by step
Six steps from images of crowded objects to a count with one entry per object.
Connect Roboflow to your coding agent, ChatGPT or Codex
Label every object, even where objects touch
Train a detection model
Remove duplicate boxes before you count
Pythonimport supervision as sv from collections import Counter from inference import get_model model = get_model("your-project/1") result = model.infer("shelf.jpg", confidence=0.4)[0] detections = sv.Detections.from_inference(result) detections = detections.with_nms( threshold=0.5, class_agnostic=True, overlap_metric=sv.OverlapMetric.IOS ) print(len(detections), Counter(detections.data["class_name"])) # 24 Counter({'carton': 18, 'tote': 6})Rather not write code? Ask the Roboflow agent to set this up for you
Count each object once in video
Check the counts and deploy
Why 2 million engineers build on Roboflow
Label faster
Auto-label with SAM 3 or your own model, then fix the misses instead of drawing every box.
RF-DETR
Roboflow’s open-source real-time detection model, built for accuracy (opens in a new tab) on small objects.
Logic built in
Counting, zones, tracking and alerts are ready-made Workflow blocks, so there is less code to write.
Your model, your weights
Use your trained weights on every plan, including free, through the open-source Inference package.
Run it anywhere
Self-host on a workstation, Docker, an on-prem GPU or an edge device, or call the cloud API.