ADC Value icon ADC Value — Display ADC port voltage and 0-255 linear values (0-3.3/5V); configurable board/port, units, multiplier and sample interval. Try it →
Asked
1 Participant
Tiny Yolo2 tracking filter and jitter

Tiny Yolo2 Tracking Filter And Jitter

Running an AdventureBot (EZ-Robot) over Wi-Fi with ARC on Windows and the EZ-Robot camera. I’ve got Camera Device set to 320x240, servo tracking enabled with only a horizontal pan servo on D12 (vertical set to None), and added the Tiny Yolo2 skill. When I check Active, detections look good in the Tiny Yolo2 log (e.g., person 0.78, bottle 0.65), but the pan servo hunts a lot as YOLO bounces between multiple classes in view.

What I want: only track "bottle" and maintain lock for a short period so the pan doesn’t twitch when the confidence dips or another object briefly scores higher. I tried increasing Tiny Yolo2’s confidence threshold and lowering the camera FPS, which helped a bit but didn’t solve the oscillation. I also tried filtering in the Camera Device’s On Tracking Start script by name:

if ($CameraObjectName != "bottle")
  return
endif

That stops non-bottle responses from triggering my follow logic, but the built-in servo tracking still moves first (before my script returns) and I get rapid On Tracking Start/Stop toggling if detection flickers. I then disabled servo tracking and tried my own smoothing using $CameraObjectCenterX, doing a small proportional nudge toward center each frame, which works better but I’m not sure I’m using the right variables/events for the cleanest result.

  • Is there a built-in way in Tiny Yolo2 or Camera Device to limit tracking to a specific class before servo tracking engages, or to add a persistence window (e.g., require N consecutive frames) so On Tracking Start/Stop doesn’t thrash, or is custom smoothing with $CameraObjectCenterX/$CameraObjectCenterY the recommended approach?


Related Hardware (view all EZB hardware)
Adventurebot by EZ-Robot
AdventureBot with Synthiam ARCx: drive, stream live video, follow faces and colors, use speech, AI, and browser control.
Wi-Fi / USB
Servos 24
Camera
Audio
UART 3
I2C
ADC 8
Digital 24

Related Robot Skills (view all robot skills)
Camera Device by Synthiam
Use PC or robot cameras for vision tracking: color, QR, glyph, face, object, motion; record video/data, control servos and movement, run scripts
Tiny Yolo2 by Synthiam
Real-time TinyYolo object detection for ARC Camera Device: tracks 20 classes, populates camera variables, triggers tracking scripts, 30+ FPS in HD.

ARC Pro

Upgrade to ARC Pro

Unlock the true power of automation and robotics by becoming a proud subscriber of Synthiam ARC Pro.

Author Avatar
PRO
Canada
Twitter YouTube GitHub
#1  

Yes - the better approach in ARC is to keep the camera/tracking pipeline clean and do the class filtering/persistence in script, rather than letting servo tracking react to every transient detection.

What’s happening

With Tiny Yolo2, detections can legitimately switch between nearby classes frame-to-frame, especially when multiple objects are in view or confidence is near the threshold. If Camera Device servo tracking is enabled, it will respond immediately to whatever the active tracked object is before your On Tracking Start script gets a chance to filter it.

So your observation is correct: filtering in the script alone does not prevent the built-in servo tracking from twitching first.


Option 1 - Best practice: disable built-in servo tracking and use your own "locked target" script

This is the most stable solution for what you want.

  • Disable servo Tracking in Camera Device
  • Keep Tiny Yolo2 active
  • In a Script skill or Camera Device scripts, only accept:
    • bottle
    • and only after it has been seen for several consecutive frames
  • Keep that target "locked" for a short time even if one frame drops out

This gives you:

  • class filtering before motion
  • persistence/hysteresis
  • smoother servo behavior
  • no start/stop thrash

Why this is the right way

ARC’s camera tracking is designed for detection, but "track only this class with lockout/persistence" is better handled by a custom script because it lets you define robot behavior exactly.

If you want that feature as a reusable control, you could even build a custom robot skill later: https://synthiam.com/Support/Create-Robot-Skill/Overview


Simple smoothing pattern in JavaScript

Use this pattern with:

  • Camera Device + Tiny Yolo2
  • servo tracking disabled
  • a Script skill that runs on a timer or from a tracking event

The idea:

  • only accept bottle
  • require it to appear for N frames
  • hold the target for a short timeout
  • only nudge the servo in small steps
var lastSeenMs = 0;
var lockMs = 500;
var minConsecutive = 3;
var seenCount = 0;
var targetName = "bottle";
var centerDeadband = 20; // pixels
var step = 2; // servo degrees per update
var panPort = d12;

var currentName = getVar("$CameraObjectName", "");
var isTracking = getVar("$CameraIsTracking", "0") == "1";

if (isTracking && currentName == targetName) {
  seenCount += 1;
  lastSeenMs = new Date().getTime();
} else {
  // keep lock briefly even if detection flickers
  if ((new Date().getTime() - lastSeenMs) > lockMs) {
    seenCount = 0;
  }
}

if (seenCount < minConsecutive) {
  return;
}

var cx = parseInt(getVar("$CameraObjectCenterX", "0"));
var camW = parseInt(getVar("$CameraResolutionWidth", "320"));
var centerX = camW / 2;
var error = cx - centerX;

if (Math.abs(error) <= centerDeadband) {
  return;
}

if (error > 0) {
  Servo.increment(panPort, step);
} else {
  Servo.decrement(panPort, step);
}

Notes

  • Servo.increment() / Servo.decrement() are a good fit for small corrections.
  • The deadband prevents constant micro-correction.
  • The lock timeout prevents twitching when YOLO briefly misses the object.

Even better: use a state-based tracker

If your goal is "follow the bottle until I lose it for a bit," then use a simple state machine:

  • SEARCHING: ignore everything except bottle
  • LOCKED: continue following bottle even if one or two frames miss it
  • LOST: if gone too long, stop moving and return to searching

That’s more stable than reacting directly to every frame.


About the built-in filters

From what you described:

  • Tiny Yolo2 does not give you a clean "only detect class X before tracking" switch that prevents the camera/servo pipeline from reacting first.
  • Camera Device tracking scripts can filter afterward, but by then servo tracking may already have acted.
  • So custom smoothing is the recommended approach.

Important detail

If you do keep built-in servo tracking on, it will always be more "reactive" than "stable." That is expected. For object-following behavior, especially with a single target like bottle, scripting is the proven route.


Suggested ARC workflow

  1. Camera Device
    • 320x240
    • Tiny Yolo2 active
    • Servo Tracking OFF
  2. Script skill
    • poll $CameraObjectName, $CameraObjectCenterX, $CameraIsTracking
    • only act on "bottle"
    • require N consecutive frames
    • hold lock for 300-700 ms
    • nudge the pan servo in small increments
  3. Tune:
    • deadband
    • hold time
    • step size

Follow-up

If you want, I can write you a clean ARC JavaScript script that implements:

  • bottle-only tracking
  • consecutive-frame confirmation
  • lock timeout
  • servo smoothing
  • optional stop behavior when the bottle is lost

Also, what’s your bigger goal overall - follow a bottle, pick it up, or just keep it centered in view? That will change the best control strategy.

I am a customer support AI and still learning. Please verify important answers in our support documentation. For advanced AI features, use the AI Script Agent built into ARC.