YOLOViewController class
Controller for interacting with a YOLOView widget.
This controller provides methods to adjust detection thresholds and camera settings for real-time object detection. It manages the communication with the native platform views.
Example:
class MyDetectorScreen extends StatefulWidget {
@override
State<MyDetectorScreen> createState() => _MyDetectorScreenState();
}
class _MyDetectorScreenState extends State<MyDetectorScreen> {
final controller = YOLOViewController();
@override
Widget build(BuildContext context) {
return Column(
children: [
Expanded(
child: YOLOView(
modelPath: 'assets/yolov8n.mlmodel',
task: YOLOTask.detect,
controller: controller,
onResult: (results) {
print('Detected ${results.length} objects');
},
),
),
ElevatedButton(
onPressed: () => controller.switchCamera(),
child: Text('Switch Camera'),
),
],
);
}
}
Constructors
Properties
- confidenceThreshold → double
-
The current confidence threshold for detections.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- iouThreshold → double
-
The current Intersection over Union (IoU) threshold.
no setter
- isInitialized → bool
-
Whether the controller has been initialized with a platform view.
no setter
- numItemsThreshold → int
-
The maximum number of items to detect per frame.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
captureFrame(
) → Future< Uint8List?> - Captures the current camera frame with detection overlays.
-
init(
MethodChannel methodChannel, int viewId) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setConfidenceThreshold(
double threshold) → Future< void> - Sets the confidence threshold for object detection.
-
setIoUThreshold(
double threshold) → Future< void> - Sets the Intersection over Union (IoU) threshold.
-
setNumItemsThreshold(
int numItems) → Future< void> - Sets the maximum number of items to detect per frame.
-
setStreamingConfig(
YOLOStreamingConfig config) → Future< void> - Sets the streaming configuration for real-time detection.
-
setThresholds(
{double? confidenceThreshold, double? iouThreshold, int? numItemsThreshold}) → Future< void> - Sets all thresholds at once.
-
setZoomLevel(
double zoomLevel) → Future< void> - Sets the camera zoom level to a specific value.
-
stop(
) → Future< void> - Stop camera and inference operations.
-
switchCamera(
) → Future< void> - Switches between front and back cameras.
-
switchModel(
String modelPath, YOLOTask task) → Future< void> - Switches to a different YOLO model.
-
toString(
) → String -
A string representation of this object.
inherited
-
zoomIn(
) → Future< void> - Zooms in the camera view.
-
zoomOut(
) → Future< void> - Zooms out the camera view.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited