Skip to content

Correct object tracking control computation - #572

Open
harishthakur52 wants to merge 1 commit into
ob-f:masterfrom
3dwesupport:ios/fix-object-tracking
Open

harishthakur52 wants to merge 1 commit into
ob-f:masterfrom
3dwesupport:ios/fix-object-tracking

Conversation

@harishthakur52

Copy link
Copy Markdown
Contributor

Issue

While testing person-following on iOS, the robot circled with a person in frame and moved with no one in frame.

Fixes

  • Use the camera image size for steering. The old code rescaled boxes by the screen size, so the target centre was off and the robot kept turning.
  • Follow only detections above the confidence slider. MobileNet and YOLOv4 return every detection, so weak false ones moved the robot.
  • Set the busy flag before queuing a frame, so frames don't pile up and the robot acts on the current position.
  • Fix the NMS loop so the last detection isn't dropped.

@thias15 thias15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The detections are already in camera-image pixels, so steering from the image size is right, and setting the busy flag early stops frames from piling up.

One small thing: the drawing block still force-unwraps res!. res is nil when there's no detector, which happens with #570 when a model fails to load, so turning on auto mode would crash. for item in res ?? [] covers it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

With WebRTC active, every camera sample is enqueued on the shared queue before the busy-flag check, so the flag does not bound queued work. During slow inference, capture jobs accumulate and retain camera buffers, delaying subsequent inference and potentially causing tracking control to lag behind the target.

1 open issue
What changed in this PR

This PR corrects iOS person-following controls by using camera coordinates and filtering low-confidence detections.

Changes:

  • Compute steering using camera image dimensions.
  • Filter tracking targets by confidence and mark inference busy before queueing.
  • Include the final detection in non-maximum suppression.
File Description
robot/​ios/​OpenBot/​OpenBot/​tflite/​Detector.swift Fixes the suppression loop’s final-detection omission.
robot/​ios/​OpenBot/​OpenBot/​Controllers/​ObjectTracking/​ObjectTrackingFragment.swift Updates steering coordinates, confidence filtering, and inference queue gating.

Review effort: Balanced

Comment on lines +335 to +336
/// Mark busy before queueing so frames do not pile up
isInferenceQueueBusy = true

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants