Skip to content

Add OBB angle to platform responses and fix usage example#461

Open
yukihiratype2 wants to merge 2 commits intoultralytics:mainfrom
yukihiratype2:main
Open

Add OBB angle to platform responses and fix usage example#461
yukihiratype2 wants to merge 2 commits intoultralytics:mainfrom
yukihiratype2:main

Conversation

@yukihiratype2
Copy link
Copy Markdown

@yukihiratype2 yukihiratype2 commented Mar 25, 2026

I have read the CLA Document and I sign the CLA

Summary

This PR adds OBB rotation angle support to native platform responses and updates the Flutter-side parsing so the angle is available in detections. It also fixes the OBB usage example in doc/usage.md so it reads the actual obb payload instead of the generic boxes result.

What changed

  • Added angle to OBB responses on iOS in YOLOInstanceManager.swift
  • Added angle to OBB responses on Android in YOLOPlugin.kt
  • Updated Dart OBB parsing in YOLOInference to:
    • use angle when present
    • fall back to angleDegrees and convert to radians when needed
  • Added tests covering:
    • direct angle passthrough
    • angleDegrees fallback conversion
    • default angle behavior when missing
  • Fixed the OBB example in doc/usage.md to:
    • read results['obb']
    • use the native OBB field names
    • show the angle as radians

Validation

flutter test test/yolo_inference_test.dart

Notes

  • The OBB angle exposed through Dart is now normalized to radians.
  • The usage example now matches the actual platform payload shape and should be copy-paste correct.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

This PR adds OBB angle data to Android and iOS platform responses, fixes the Flutter OBB usage example, and updates inference parsing with backward-compatible angle handling. 📦📐

📊 Key Changes

  • Added angle to OBB prediction responses in android/src/main/kotlin/com/ultralytics/yolo/YOLOPlugin.kt and ios/Classes/YOLOInstanceManager.swift.
  • Updated lib/core/yolo_inference.dart to read OBB angles directly from platform output.
  • Added a fallback for legacy angleDegrees values and converts them to radians for consistent downstream usage.
  • Fixed the documentation example in doc/usage.md to use results['obb'] instead of results['boxes'].
  • Clarified in docs that OBB rotation is reported in radians.
  • Added tests covering direct angle, fallback angleDegrees, and missing-angle default behavior in test/yolo_inference_test.dart.

🎯 Purpose & Impact

  • Improves OBB result completeness by exposing rotation metadata from native platforms. 🎯
  • Fixes a documentation mismatch that could cause confusion or incorrect integration for Flutter users. 📘
  • Preserves compatibility with older response formats while standardizing angle handling in Dart. 🔄
  • Increases reliability with targeted test coverage for key OBB parsing scenarios. ✅

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

All Contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@UltralyticsAssistant UltralyticsAssistant added documentation Improvements or additions to documentation fixed Bug has been resolved OBB Oriented Bounding Box (OBB) models labels Mar 25, 2026
@UltralyticsAssistant
Copy link
Copy Markdown
Member

👋 Hello @yukihiratype2, thank you for submitting a ultralytics/yolo-flutter-app 🚀 PR! This is an automated message to help with review readiness—an engineer will assist you soon 😊 Please review the checklist below to help ensure a smooth integration:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/yolo-flutter-app main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

Copy link
Copy Markdown
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

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

🔍 PR Review

Made with ❤️ by Ultralytics Actions

The native angle plumbing and backward-compatible parsing look good overall, but the updated usage example still appears to document the raw platform payload instead of the normalized Dart API, so it would mislead users and likely fail as written.

💬 Posted 1 inline comment


// Process oriented bounding boxes
final boxes = results['boxes'] as List<dynamic>;
final boxes = results['obb'] as List<dynamic>? ?? [];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

⚠️ HIGH: yolo.predict() is normalized by YOLOInference.predict, which returns OBB results under results['detections'], not the raw platform key results['obb']. As written, this example still won't match the Flutter API shape users receive, and the subsequent field accessors (class vs className) will be out of sync as well.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

documentation Improvements or additions to documentation fixed Bug has been resolved OBB Oriented Bounding Box (OBB) models

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants