Computer vision answers · Manufacturing

How do I use computer vision to detect when a part has stopped moving before inspecting it?

So every inspection runs on a sharp, settled frame.

Short answer

Train a detection model to find the part with Roboflow for free, then track it across video frames and inspect only once its position has held still for a set number of frames. Waiting for the part to settle gives the inspection a sharp image with the part in the same place every time. Set the stop threshold in pixels just above the camera's jitter, and require several still frames in a row, so a brief pause on a moving conveyor does not trigger an inspection.

Roboflow agent · free to start

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
A fixed camera on the station and a model that finds the part
What you get
A trigger the moment each part settles, ready to inspect
Image sources
IP, RTSP, USB and machine vision cameras
Runs on
Cloud API, or an edge device or server running Docker
Automated factory inspection system showing metal parts on a conveyor belt and under a camera, with real-time status overlays.

How to build stopped-part detection, step by step

Six steps from a camera on the station to an inspection that waits for each part to settle.

  1. Connect Roboflow to your coding agent, ChatGPT or Codex

    Add the Roboflow MCP server to Claude, Cursor or Gemini CLI, or install the Roboflow plugin in ChatGPT or Codex. Your assistant can then upload and auto-label video frames, start training, build the Workflow and run the model from a prompt, at no extra cost beyond your Roboflow plan.

  2. Record video of parts arriving at the station

    Mount a fixed camera on the inspection station and record parts as they arrive. Capture parts moving, slowing, settling and sitting still, in the lighting you will run in.

  3. Label the part in frames from that video

    Pull frames from the video and draw a box around the part in each one, including frames where it is blurred by motion. Roboflow Annotate can pre-label frames with SAM 3, so you correct boxes instead of drawing each one.

  4. Train a detection model

    Train an object detection model such as RF-DETR on your labeled frames with Roboflow Train.

  5. Track each part and wait until it stops

    Track each part across frames, measure how far its center moves from one frame to the next, and trigger the inspection once it has moved less than 2 pixels for 15 frames in a row, about half a second at 30 frames per second.

    Python
    import numpy as np
    import supervision as sv
    from inference import get_model
    from trackers import ByteTrackTracker
    
    model = get_model("your-project/1")
    tracker = ByteTrackTracker()
    last_center, still_frames = {}, {}
    
    for frame in sv.get_video_frames_generator("station.mp4"):
        detections = tracker.update(sv.Detections.from_inference(model.infer(frame, confidence=0.4)[0]))
        for track_id, center in zip(detections.tracker_id, detections.get_anchors_coordinates(sv.Position.CENTER)):
            moved = np.linalg.norm(center - last_center.get(track_id, center))
            still_frames[track_id] = still_frames.get(track_id, 0) + 1 if moved < 2 else 0
            last_center[track_id] = center
            if still_frames[track_id] == 15:
                print(f"part {track_id} stopped, inspect now")
    # part 4 stopped, inspect now

    Rather not write code? Ask the Roboflow agent to set this up for you

  6. Build the stop check into a Workflow

    In a Workflow, add Byte Tracker and the Velocity block, which gives every tracked part a speed, then use Continue If to run the inspection only when that speed is near zero. For a fixed spot such as a fixture, the Motion Detection block with a detection zone reports whether anything in that zone is still moving. Run it on the camera stream with Roboflow 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.