-
-
Notifications
You must be signed in to change notification settings - Fork 125
feat: custom image source for YOLOOverlay #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
👋 Hello @onuralpszr, thank you for submitting a To ensure a seamless integration of your work, please review the following checklist:
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! 🚀 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
UltralyticsAssistant
left a comment
There was a problem hiding this 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
Overall the PR is well-structured and keeps the existing API backward compatible while adding flexible support for custom image sources. The coordinate transform and hit-testing logic are consistent between tap handling and painting, and shouldRepaint correctly accounts for the new fields.
Main follow-ups:
- Strengthen the
imageRect/imageSizepairing guarantee with a runtime check, not only a debugassert. - Clarify in the documentation that detection bounding boxes must be in original image coordinates when using custom images and that
imageRectmust match the displayed image area. - Consider deduplicating the
_transformRectlogic betweenYOLOOverlayandYOLODetectionPainterand optionally precomputing scale factors in the painter for minor performance gains.
💬 Posted 4 inline comments
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 PR Review 2
Made with ❤️ by Ultralytics Actions
Please add a runtime guard so mismatched imageRect/imageSize pairs are rejected outside debug builds, and update YOLODetectionPainter.shouldRepaint to react to content changes instead of only list identity to avoid stale overlays when detection lists are mutated in place.
💬 Posted 2 inline comments
| oldDelegate.showConfidence != showConfidence || | ||
| oldDelegate.showClassName != showClassName || | ||
| oldDelegate.theme != theme); | ||
| oldDelegate.theme != theme || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oldDelegate.detections != detections compares list identity, so if callers mutate an existing detections list in place (common when reusing buffers) the painter will think nothing changed and skip repainting, leaving stale boxes on screen. Consider comparing contents (e.g., !listEquals(oldDelegate.detections, detections)) or passing an immutable copy so the painter reliably invalidates when detection data changes.
| }) : assert( | ||
| (imageRect == null && imageSize == null) || | ||
| (imageRect != null && imageSize != null), | ||
| 'imageRect and imageSize must be provided together or both be null', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 MEDIUM: assert only runs in debug, so a production build can supply only imageRect or only imageSize and the overlay will silently fall back to the original coordinates, producing badly aligned drawings and tap hit-testing with no signal to the caller. Please replace the debug assert with a runtime guard (e.g., throw an ArgumentError) so invalid input is rejected in release builds as well.
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Adds flexible support for rendering YOLO detections over custom image sources (e.g., HTTP/RTSP, local files) by extending
YOLOOverlaywith optional image geometry parameters and updating the package version and changelog.📊 Key Changes
YOLOOverlayto support custom image sources in addition to the camera view.imageRectandimageSizeparameters toYOLOOverlay, with an assertion to ensure they are provided together.YOLOOverlayandYOLODetectionPainterto map detections from original image space to on-screen positions.shouldRepaintinYOLODetectionPainterto account forimageRectandimageSizechanges.YOLOOverlaydocs and added a new0.1.42entry toCHANGELOG.md.pubspec.yamlversion from0.1.40to0.1.42to publish the new feature.🎯 Purpose & Impact
YOLOOverlayusage without additional parameters.