Google Vision images REST API Client

Overview

Google Vision images REST API Client

pub package

Native Dart package that integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications.

Build Status github last commit github build github issues

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

New for v1.0.3

The package now includes Product Search functionality. But be warned, it is completely experimental, there has been little to no testing done.

Bonus Feature

This package included a cli utility that can be used to return data for any API call currently supported by the package. If you want to get started quicky with the cli utility run these commands in a termainal session:

pub global activate vision

vision --help

Please see the cli documentation README.md for more detailed usage information.

Getting Started

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

dependencies:
  ...
  google_vsion: ^1.0.3

Obtaining Authorization Credentials

Authenticating to the Cloud Vision API requires a JSON file with the JWT token information, which you can obtain by creating a service account in the API console.

Usage of the Cloud Vision API

  final googleVision =
      await GoogleVision.withJwt('my_jwt_credentials.json');

  final image =
      Image.fromFilePath('example/young-man-smiling-and-thumbs-up.jpg');

  //cropping an image can save time uploading the image to Google
  final cropped = image.copyCrop(70, 30, 640, 480);

  await cropped.writeAsJpeg('example/cropped.jpg');

  final requests = AnnotationRequests(requests: [
    AnnotationRequest(image: cropped, features: [
      Feature(maxResults: 10, type: 'FACE_DETECTION'),
      Feature(maxResults: 10, type: 'OBJECT_LOCALIZATION')
    ])
  ]);

  final annotatedResponses =
      await googleVision.annotate(requests: requests);

  for (var annotatedResponse in annotatedResponses.responses) {
    for (var faceAnnotation in annotatedResponse.faceAnnotations) {
      GoogleVision.drawText(
          cropped,
          faceAnnotation.boundingPoly.vertices.first.x + 2,
          faceAnnotation.boundingPoly.vertices.first.y + 2,
          'Face - ${faceAnnotation.detectionConfidence}');

      GoogleVision.drawAnnotations(
          cropped, faceAnnotation.boundingPoly.vertices);
    }
  }

  for (var annotatedResponse in annotatedResponses.responses) {
    //look only for Person annotations
    annotatedResponse.localizedObjectAnnotations
        .where((localizedObjectAnnotation) =>
            localizedObjectAnnotation.name == 'Person')
        .toList()
        .forEach((localizedObjectAnnotation) {
      GoogleVision.drawText(
          cropped,
          (localizedObjectAnnotation.boundingPoly.normalizedVertices.first.x *
                  cropped.width)
              .toInt(),
          (localizedObjectAnnotation.boundingPoly.normalizedVertices.first.y *
                      cropped.height)
                  .toInt() -
              16,
          'Person - ${localizedObjectAnnotation.score}');

      GoogleVision.drawAnnotationsNormalized(
          cropped, localizedObjectAnnotation.boundingPoly.normalizedVertices);
    });
  }

//output the results as a new image file
await cropped.writeAsJpeg('resulting_image.jpg');
You might also like...

Display images flutter - Simple app to display images in flutter

Display images flutter - Simple app to display images in flutter

Display Images In Flutter Simple app to display images in a flutter. In this dem

Jan 29, 2022

Memebaaz is a video/images sharing app, Anyone can share short videos and images through app, the media will go through admin's approval.

Memebaaz is a video/images sharing app, Anyone can share short videos and images through app, the media will go through admin's approval.

MemeBaaz - Memes & Short Videos App Memebaaz is a Video/images Sharing App, Anyone can share short videos and images through app, the media will go th

Nov 14, 2022

Authentication API client with Flutter (Login, Register, Google Login, Facebook Login, Apple Login)

Authentication API client with Flutter (Login, Register, Google Login, Facebook Login, Apple Login)

Flutter Auth App (Login, Register, Google Login, Facebook Login, Apple Login) To use this client, get the server up and running. Try it out now! App S

Jan 4, 2023

A google browser clone which is made by using flutter and fetching the google search api for the search requests.

A google browser clone which is made by using flutter and fetching the google search api for the search requests.

google_clone A new Flutter project. Project Preview Getting Started This project is a starting point for a Flutter application. A few resources to get

May 31, 2022

Get google api credentials - A Dart CLI app to obtain credentials for accessing Google APIs

get_google_api_credentials A Dart CLI app to obtain credentials for accessing Go

Jan 28, 2022

Flutter Cryptocurrency App with Riverpod & Freezed + Dio for API REST

Flutter Cryptocurrency App with Riverpod & Freezed + Dio for API REST

Flutter Crypto APP Complete Flutter Application with Riverpod & Freezed + Dio for API REST. Features API REST (CryptoWatch) Linear Graph View (Hour, D

Jan 2, 2023

Rest Api Crud funtion . Created, Update, Delete , Read

flutter_application_10 A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you s

Nov 30, 2022

Flutter Viral News App using : Flutter + Rest Api + Bloc / Cubit

Flutter Viral News App using : Flutter + Rest Api + Bloc / Cubit

Intro Viral News App on Flutter. The tech used: Flutter widgets + Flutter Bloc / Cubit + Rest Api Check the screenshot : P.S Make sure to upgrade your

Nov 2, 2022

The Simplest way to Authenticate and make Rest API calls in .Net

Simple Auth Every API needs authentication, yet no developer wants to deal with authentication. Simple Auth embeds authentication into the API so you

Dec 22, 2022
Comments
  • Unhandled Exception: FileSystemException: Cannot open file

    Unhandled Exception: FileSystemException: Cannot open file

    I use the credentials json file (which I downloaded when creating Service Account). It has the following format { "type": "service_account", "project_id": "", "private_key_id": "", "private_key": "", "client_email": "", "client_id": "", "auth_uri": "", "token_uri": "", "auth_provider_x509_cert_url": "", "client_x509_cert_url": "" } I put the file in "assets/a.json" and use the following code to read.

    final String response = await rootBundle.loadString('assets/a.json');
    final data = await json.decode(response);
    
    final googleVision = await GoogleVision.withJwt("assets/a.json");
    print(googleVision.toString());
    

    then, the rootBundle can read the json file well, but GoogleVision.withJwt has error "Unhandled Exception: FileSystemException: Cannot open file"

    opened by KennyTC 9
Releases(v1.0.5+6)
Owner
C Davis
C Davis
This example uses a ScrollView, JSON Rest API, Navigation, Alert Pop Up, Progress Indicator, Globals, Images in a shared asset folder, and 100% Shared Code

This example uses a ScrollView, JSON Rest API, Navigation, Alert Pop Up, Progress Indicator, Globals, Images in a shared asset folder, and 100% Shared Code. Now with the ability to login with FaceID, TouchID, and Fingerprint Reader on Android.

Rody Davis 672 Jan 6, 2023
Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Gita Bhagavad Gita flutter app. Download App - Playstore Web Application About Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight No

Ravi Kovind 7 Apr 5, 2022
FLutter Api Integration - Flutter Rest API Integration

Flutter_Rest_Api_integration Flutter_Rest_Api_integration. Preview How To Use To

Rahul Ranjan Singh 0 Feb 17, 2022
Movie API Use Rest And Restful API

movie_api use rest and restful api The home screen fetches data from the Episodate API and shows a list of popular shows. The details screen and the s

Le Gia Huy 1 Dec 5, 2022
In this video we will learn how to Create CRUD Rest API for our Flutter application using NODEJS API.

Flutter CRUD Using NodeJS API In this video we will learn how to Create CRUD Rest API for our Flutter application using NODEJS API. ?? Packages Used h

SnippetCoder 14 Dec 30, 2022
Netflix app UI clone using bloc,Rest API and TMDB for API key

netflix_flutter project_using_bloc packages Used flutter_bloc json_serializable get_it dio A few resources to get you started if this is your first Fl

Pranav Pv 16 Nov 25, 2022
Codeflow 19 Sep 29, 2022
Simple face recognition authentication (Sign up + Sign in) written in Flutter using Tensorflow Lite and Firebase ML vision library.

FaceNetAuthentication Simple face recognition authentication (Sign up + Sign in) written in Flutter using Tensorflow Lite and Google ML Kit library. S

Marcos Carlomagno 279 Jan 9, 2023
In this repo you will see how to pick images from the image library and also, see how to store the selected images on Firebase.

flutterimageapp Flutter Tutorial - Upload Images using Firebase Storage. Flutter Tutorial - Upload Images using Firebase Storage Video series can be w

Whatsupcoders 60 Nov 4, 2022
camilo velandia 69 Dec 30, 2022