Skip to main content

flutter_vision 3.0.0 copy "flutter_vision: ^3.0.0" to clipboard
flutter_vision: ^3.0.0 copied to clipboard

Real-time object detection and instance segmentation with YOLO models (YOLOv5, v8, v9, v10, v11, v12, YOLO26) on Android and iOS, powered by LiteRT with CPU, GPU and NPU acceleration.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_vision/flutter_vision.dart';

import 'image_screen.dart';
import 'live_screen.dart';
import 'model_catalog.dart';

void main() {
  runApp(const FlutterVisionExample());
}

class FlutterVisionExample extends StatelessWidget {
  const FlutterVisionExample({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'flutter_vision',
      theme: ThemeData(colorSchemeSeed: Colors.indigo, useMaterial3: true),
      darkTheme: ThemeData(
        colorSchemeSeed: Colors.indigo,
        brightness: Brightness.dark,
        useMaterial3: true,
      ),
      home: const HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  const HomeScreen({super.key});

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  ModelOption _model = bundledModels.first;
  Accelerator _accelerator = Accelerator.cpu;

  void _open(Widget screen) {
    Navigator.of(context).push(MaterialPageRoute<void>(builder: (_) => screen));
  }

  @override
  Widget build(BuildContext context) {
    final textTheme = Theme.of(context).textTheme;
    return Scaffold(
      appBar: AppBar(title: const Text('flutter_vision 3')),
      body: ListView(
        padding: const EdgeInsets.all(16),
        children: [
          Text('Model', style: textTheme.titleMedium),
          const SizedBox(height: 8),
          RadioGroup<ModelOption>(
            groupValue: _model,
            onChanged: (value) => setState(() => _model = value!),
            child: Column(
              children: [
                for (final option in bundledModels)
                  RadioListTile<ModelOption>(
                    value: option,
                    title: Text(option.name),
                    subtitle: Text(option.task == YoloTask.segment
                        ? 'Segmentation'
                        : 'Detection'),
                  ),
              ],
            ),
          ),
          const SizedBox(height: 16),
          Text('Hardware', style: textTheme.titleMedium),
          const SizedBox(height: 8),
          SegmentedButton<Accelerator>(
            segments: const [
              ButtonSegment(value: Accelerator.cpu, label: Text('CPU')),
              ButtonSegment(value: Accelerator.gpu, label: Text('GPU')),
              ButtonSegment(value: Accelerator.npu, label: Text('NPU')),
            ],
            selected: {_accelerator},
            onSelectionChanged: (value) =>
                setState(() => _accelerator = value.single),
          ),
          const SizedBox(height: 32),
          FilledButton.icon(
            icon: const Icon(Icons.videocam),
            label: const Text('Live camera'),
            onPressed: () =>
                _open(LiveScreen(model: _model, accelerator: _accelerator)),
          ),
          const SizedBox(height: 12),
          FilledButton.tonalIcon(
            icon: const Icon(Icons.photo),
            label: const Text('Photo from gallery'),
            onPressed: () =>
                _open(ImageScreen(model: _model, accelerator: _accelerator)),
          ),
        ],
      ),
    );
  }
}
116
likes
0
points
356
downloads

Publisher

verified publisheryurihuallpa.com

Weekly Downloads

Real-time object detection and instance segmentation with YOLO models (YOLOv5, v8, v9, v10, v11, v12, YOLO26) on Android and iOS, powered by LiteRT with CPU, GPU and NPU acceleration.

Repository (GitHub)
View/report issues

Topics

#yolo #object-detection #segmentation #tflite #computer-vision

License

unknown (license)

Dependencies

flutter, meta

More

Packages that depend on flutter_vision

Packages that implement flutter_vision