unified_apple_vision 1.3.0-preview.1 copy "unified_apple_vision: ^1.3.0-preview.1" to clipboard
unified_apple_vision: ^1.3.0-preview.1 copied to clipboard

retracted

A plugin for using Apple Vision Framework with Flutter, designed to integrate multiple APIs into one plugin and process multiple analysis requests at once.

example/lib/main.dart

import 'package:camerawesome/camerawesome_plugin.dart';
import 'package:flutter/material.dart';
import 'package:unified_apple_vision/unified_apple_vision.dart';

import 'extension/vision_request_type.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(const MaterialApp(
    home: MyApp(),
  ));
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _unifiedAppleVision = UnifiedAppleVision()
    ..executionPriority = VisionExecutionPriority.high
    ..setLogLevel(VisionLogLevel.error);

  VisionRequestType selectedType = VisionRequestType.recognizeText;
  VisionResults? results;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          CameraAwesomeBuilder.awesome(
            saveConfig: SaveConfig.photo(),
            imageAnalysisConfig: AnalysisConfig(maxFramesPerSecond: 1),
            topActionsBuilder: (state) => AwesomeTopActions(
              state: state,
              children: [
                AwesomeCameraSwitchButton(state: state, scale: 1.0),
                Expanded(
                  child: DropdownMenu<VisionRequestType>(
                    initialSelection: selectedType,
                    onSelected: (value) => setState(() {
                      results = null;
                      if (value != null) selectedType = value;
                    }),
                    dropdownMenuEntries: [
                      for (final type in VisionRequestType.values)
                        type.dropdownMenuEntry,
                    ],
                  ),
                ),
              ],
            ),
            middleContentBuilder: (_) => const SizedBox(),
            bottomActionsBuilder: (_) => const SizedBox(),
            onImageForAnalysis: (image) async {
              image.when(
                bgra8888: (image) {
                  final input = VisionInputImage(
                    bytes: image.bytes,
                    size: image.size,
                  );
                  try {
                    _unifiedAppleVision.analyze(
                      image: input,
                      requests: selectedType.requests(
                        (res) => setState(() => results = res),
                      ),
                    );
                  } catch (e) {
                    debugPrint('$e');
                  }
                },
              );
            },
          ),
          ...?selectedType.widgets(results),
        ],
      ),
    );
  }
}
4
likes
0
points
33
downloads

Publisher

verified publisherdrdng.dev

Weekly Downloads

A plugin for using Apple Vision Framework with Flutter, designed to integrate multiple APIs into one plugin and process multiple analysis requests at once.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on unified_apple_vision