google_vision_flutter 1.3.0+3 copy "google_vision_flutter: ^1.3.0+3" to clipboard
google_vision_flutter: ^1.3.0+3 copied to clipboard

Add Google Visions image labeling, face, logo, and landmark detection into your Flutter applications.

Google Vision Images Flutter Widget #

pub package License: MIT

Native Dart package that integrates Google Vision features, including image labeling, face, logo, and landmark detection into Flutter applications.

Please feel free to submit PRs for any additional helper methods, or report an issue for a missing helper method and I'll add it if I have time available.

Table of Contents #

Build Status github last commit github build github issues

Buy me a coffee

Getting Started #

pubspec.yaml #

To use this package, add the dependency to your pubspec.yaml file:

dependencies:
  ...
  google_vision_flutter: ^1.3.0+3

Obtaining Authorization Credentials #

Authenticating to the Cloud Vision API requires an API key or a JSON file with the JWT token information. The JWT token can obtained by creating a service account in the Google API console.

Usage of the GoogleVisionBuilder Widget #

See the example app for the full code.

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

class LabelDetection extends StatefulWidget {
  const LabelDetection({super.key, required this.title});

  final String title;

  @override
  State<LabelDetection> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<LabelDetection> {
  final _processImage = Image.asset(
    'assets/setagaya_small.jpg',
    fit: BoxFit.fitWidth,
  );

  @override
  Widget build(BuildContext context) => SafeArea(
        child: Scaffold(
          appBar: AppBar(
            leading: IconButton(
              icon: const Icon(Icons.arrow_back, color: Colors.black),
              onPressed: () => Navigator.of(context).pop(),
            ),
            title: Text(widget.title),
          ),
          body: SingleChildScrollView(
            child: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                children: <Widget>[
                  const Padding(
                    padding: EdgeInsets.all(8.0),
                    child: Text('assets/setagaya_small.jpg'),
                  ),
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: _processImage,
                  ),
                  const Padding(
                    padding: EdgeInsets.all(8.0),
                    child: Text(
                      'Process result will appear below:',
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: GoogleVisionBuilder.labelDetection(
                      googleVision: GoogleVision.withAsset(
                          'assets/service_credentials.json'),
                      imageProvider: _processImage.image,
                      builder: (
                        BuildContext context,
                        List<EntityAnnotation>? entityAnnotations,
                      ) =>
                          Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Column(
                            children: entityAnnotations!
                                .map((entity) => Text(
                                    '${(entity.score! * 100).toStringAsFixed(2)}% - ${entity.description}'))
                                .toList()),
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        ),
      );
}

/// See the example project for all the necessary code.

Contributing #

Any help from the open-source community is always welcome and needed:

  • Found an issue?
    • Please fill a bug report with details.
  • Need a feature?
    • Open a feature request with use cases.
  • Are you using and liking the project?
    • Promote the project: create an article or post about it
    • Make a donation
  • Do you have a project that uses this package
    • let's cross promote, let me know and I'll add a link to your project
  • Are you a developer?
    • Fix a bug and send a pull request.
    • Implement a new feature.
    • Improve the Unit Tests.
  • Have you already helped in any way?
    • Many thanks from me, the contributors and everybody that uses this project!

If you donate 1 hour of your time, you can contribute a lot, because others will do the same, just be part and start with your 1 hour.

10
likes
0
pub points
71%
popularity

Publisher

verified publishermuayid.com

Add Google Visions image labeling, face, logo, and landmark detection into your Flutter applications.

Homepage
Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

www.buymeacoffee.com

License

unknown (license)

Dependencies

flutter, flutter_image_converter, google_vision

More

Packages that depend on google_vision_flutter