Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
faithoflifedev committed Sep 27, 2024
1 parent 9599ac4 commit d51e7da
Show file tree
Hide file tree
Showing 39 changed files with 348 additions and 898 deletions.
8 changes: 8 additions & 0 deletions packages/google_vision/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 2.0.0+3

* dependency bump

## 2.0.0+2

* dependency bump

## 2.0.0

* added web platform support
Expand Down
2 changes: 1 addition & 1 deletion packages/google_vision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ To use this package, add the dependency to your `pubspec.yaml` file:
```yaml
dependencies:
...
google_vision: ^2.0.0
google_vision: ^2.0.0+3
```
### Obtaining Authentication/Authorization Credentials
Expand Down
3 changes: 2 additions & 1 deletion packages/google_vision/bin/vision.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:google_vision/google_vision_cli.dart';
import 'package:universal_io/io.dart';

/// Attempt to retrieve the 'home' folder of the user if running on a desktop.
String? get _userHome =>
Expand Down
2 changes: 1 addition & 1 deletion packages/google_vision/lib/google_vision.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Integrates Google Vision features, including image labeling, face, logo, and
/// landmark detection, optical character recognition (OCR), and detection of
/// explicit content, into applications.
library google_vision;
library;

export 'src/google_vision_base.dart';
export 'src/google_vision_file.dart';
Expand Down
2 changes: 1 addition & 1 deletion packages/google_vision/lib/google_vision_cli.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library google_vision_cli;
library;

export 'src/cmd/vision_crop_hint_command.dart';
export 'src/cmd/vision_detect_command.dart';
Expand Down
4 changes: 2 additions & 2 deletions packages/google_vision/lib/meta.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// app metadata
library meta;
library;

// DO NOT EDIT THIS FILE
// THIS FILE IS AUTOMATICALLY OVER WRITTEN BY PublishTools
import 'dart:convert' show json;

final pubSpec = json.decode(
'{"name":"google_vision","version":"2.0.0","homepage":"https://github.com/faithoflifedev/google_vision/tree/main/packages/google_vision","environment":{"sdk":">=3.2.0 <4.0.0"},"description":"Allows you to add Google Visions image labeling, face, logo, and landmark detection, OCR, and detection of explicit content, into cross platform applications.","dependencies":{"args":"^2.5.0","collection":"^1.18.0","crypto_keys_plus":"^0.4.0","dio":"^5.7.0","flutter_loggy_dio":"^3.1.0","http":"^1.2.2","image":"^4.1.7","jose_plus":"^0.4.6","json_annotation":"^4.9.0","loggy":"^2.0.3","mime":"^1.0.6","retrofit":"^4.4.0","universal_io":"^2.2.2","universal_platform":"^1.1.0"},"dev_dependencies":{"build_runner":"^2.4.11","grinder":"^0.9.5","json_serializable":"^6.8.0","lints":"^4.0.0","publish_tools":"^1.0.0+4","retrofit_generator":"^8.2.1"},"executables":{"vision":""},"repository":"https://github.com/faithoflifedev/google_vision","funding":["https://www.buymeacoffee.com/faithoflif2"]}');
'{"name":"google_vision","version":"2.0.0+3","homepage":"https://github.com/faithoflifedev/google_vision/tree/main/packages/google_vision","environment":{"sdk":">=3.2.0 <4.0.0"},"description":"Allows you to add Google Visions image labeling, face, logo, and landmark detection, OCR, and detection of explicit content, into cross platform applications.","dependencies":{"args":"^2.5.0","collection":"^1.19.0","crypto_keys_plus":"^0.4.0","dio":"^5.7.0","flutter_loggy_dio":"^3.1.0","http":"^1.2.2","image":"^4.2.0","jose_plus":"^0.4.6","json_annotation":"^4.9.0","loggy":"^2.0.3","mime":"^1.0.6","retrofit":"^4.4.1","universal_platform":"^1.1.0"},"dev_dependencies":{"build_runner":"^2.4.12","grinder":"^0.9.5","json_serializable":"^6.8.0","lints":"^5.0.0","publish_tools":"^1.0.0+5","retrofit_generator":"^9.1.2"},"executables":{"vision":""},"repository":"https://github.com/faithoflifedev/google_vision","topics":["api","image","document"],"funding":["https://www.buymeacoffee.com/faithoflif2"]}');
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:io';
import 'dart:typed_data';

import 'package:args/command_runner.dart';
import 'package:dio/dio.dart';
import 'package:google_vision/google_vision.dart';
import 'package:loggy/loggy.dart';
import 'package:universal_io/io.dart';

/// Helper method to that retrieves error message string.
extension UsageExtension on DioException {
Expand Down
23 changes: 14 additions & 9 deletions packages/google_vision/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: google_vision
description: Allows you to add Google Visions image labeling, face, logo, and landmark detection, OCR, and detection of explicit content, into cross platform applications.
version: 2.0.0
version: 2.0.0+3
repository: https://github.com/faithoflifedev/google_vision
homepage: https://github.com/faithoflifedev/google_vision/tree/main/packages/google_vision

topics:
- api
- image
- document

funding:
- https://www.buymeacoffee.com/faithoflif2

Expand All @@ -12,27 +17,27 @@ environment:

dependencies:
args: ^2.5.0
collection: ^1.18.0
collection: ^1.19.0
crypto_keys_plus: ^0.4.0
dio: ^5.7.0
flutter_loggy_dio: ^3.1.0
http: ^1.2.2
image: ^4.1.7
image: ^4.2.0
jose_plus: ^0.4.6
json_annotation: ^4.9.0
loggy: ^2.0.3
mime: ^1.0.6
retrofit: ^4.4.0
universal_io: ^2.2.2
retrofit: ^4.4.1
# universal_io: ^2.2.2
universal_platform: ^1.1.0

dev_dependencies:
build_runner: ^2.4.11
build_runner: ^2.4.12
grinder: ^0.9.5
json_serializable: ^6.8.0
lints: ^4.0.0
publish_tools: ^1.0.0+4
retrofit_generator: ^8.2.1
lints: ^5.0.0
publish_tools: ^1.0.0+5
retrofit_generator: ^9.1.2

executables:
vision:
7 changes: 6 additions & 1 deletion packages/google_vision_flutter/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ pubspec.lock
build/


tool/publish_tools.yaml
tool/publish_tools.yaml

# deleted files
lib/src/extensions.dart
lib/src/google_vision_builder.dart
pubspec_overrides.yaml
12 changes: 10 additions & 2 deletions packages/google_vision_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Changelog

## 1.4.0
## 2.0.0+3

* dependency bump

## 2.0.0+2

* dependency bump

## 2.0.0

* singleton
* web platform support

## 1.4.0

Expand Down
133 changes: 67 additions & 66 deletions packages/google_vision_flutter/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,50 @@
# Google Vision Images Flutter Widget

[![pub package](https://img.shields.io/pub/v/google_vision_flutter.svg)](https://pub.dartlang.org/packages/google_vision_flutter)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![SDK version](https://badgen.net/pub/sdk-version/google_vision_flutter?style=for-the-badge)
![Supported platforms](https://badgen.net/pub/flutter-platform/google_vision_flutter?style=for-the-badge)
![Supported SDKs](https://badgen.net/pub/dart-platform/google_vision_flutter?style=for-the-badge)

Native [Dart](https://dart.dev/) 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](https://github.com/faithoflifedev/google_vision/issues) for a missing helper method and I'll add it if I have time available.

## Table of Contents
- [Getting Started](#getting-started)
- [pubspec.yaml](#pubspecyaml)
- [Obtaining Authorization Credentials](#obtaining-authorization-credentials)
- [Usage of the GoogleVisionBuilder Widget](#usage-of-the-googlevisionbuilder-widget)
- [Contributing](#contributing)
- [Google Vision Images Flutter Widget](#google-vision-images-flutter-widget)
- [Table of Contents](#table-of-contents)
- [Recent Changes](#recent-changes)
- [New for v2.0.0](#new-for-v200)
- [New for v1.4.0](#new-for-v140)
- [Getting Started](#getting-started)
- [pubspec.yaml](#pubspecyaml)
- [Obtaining Authorization Credentials](#obtaining-authorization-credentials)
- [Usage of the GoogleVisionBuilder Widget](#usage-of-the-googlevisionbuilder-widget)
- [ShoutOut](#shoutout)
- [Contributing](#contributing)

[![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
[![Pub Package](https://img.shields.io/pub/v/google_vision_flutter.svg?logo=dart&logoColor=00b9fc&color=blue&style=for-the-badge)](https://pub.dartlang.org/packages/google_vision_flutter)
[![Code Size](https://img.shields.io/github/languages/code-size/faithoflifedev/google_vision_workspace?logo=github&logoColor=white&style=for-the-badge)](https://github.com/faithoflifedev/google_vision_workspace)
[![Publisher](https://img.shields.io/pub/publisher/google_vision_flutter?style=for-the-badge)](https://pub.dev/publishers/muayid.com)

[![Build Status](https://img.shields.io/github/actions/workflow/status/faithoflifedev/google_vision_workspace/flutter.yaml?branch=main&logo=github-actions&logoColor=white&style=for-the-badge)](https://github.com/faithoflifedev/google_vision_workspace/actions)
[![Pull Requests](https://img.shields.io/github/issues-pr/faithoflifedev/google_vision_workspace?logo=github&logoColor=white&style=for-the-badge)](https://github.com/faithoflifedev/flutter_image_converter/pulls)
[![Issues](https://img.shields.io/github/issues/faithoflifedev/google_vision_workspace?logo=github&logoColor=white&style=for-the-badge)](https://github.com/faithoflifedev/google_vision_workspace/issues)
[![github last commit](https://shields.io/github/last-commit/faithoflifedev/google_vision?logo=github&logoColor=white&style=for-the-badge)](https://shields.io/github/last-commit/faithoflifedev/google_vision)
[![Pub Score](https://img.shields.io/pub/points/google_vision_flutter?logo=dart&logoColor=00b9fc&style=for-the-badge)](https://pub.dev/packages/google_vision_flutter/score)


[![Build Status](https://github.com/faithoflifedev/google_vision/workflows/Dart/badge.svg)](https://github.com/faithoflifedev/google_vision/actions) [![github last commit](https://shields.io/github/last-commit/faithoflifedev/google_vision)](https://shields.io/github/last-commit/faithoflifedev/google_vision) [![github build](https://img.shields.io/github/actions/workflow/status/faithoflifedev/google_vision_workspace/flutter.yaml?branch=main)](https://shields.io/github/workflow/status/faithoflifedev/google_vision/Dart) [![github issues](https://shields.io/github/issues/faithoflifedev/google_vision)](https://shields.io/github/issues/faithoflifedev/google_vision)

[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/guidelines/download-assets-1.svg)](https://www.buymeacoffee.com/faithoflif2)

## Recent Changes

### New for v2.0.0
- Even though this package worked when used with the `web` platform the **pub.dev** analyzer would not show it as `web` platform compatible due to the use of the `universal_io` package which has a dependency on `dart:io`. This version has removed the `universal_io` dependency from the core package, so some related method signatures have been removed.
- The deprecated methods from in v1.3.x have been removed in this version.
- Logging functionality has been added to the package
```dart
final googleVision = await GoogleVision(LogLevel.all).withJwtFile('service_credentials.json');
```

### New for v1.4.0
- A **breaking change** from the previous version is that the `GoogleVision` class now follows the Singleton design pattern. Now the object is instantiated as follows:
```dart
Expand All @@ -41,7 +65,7 @@ To use this package, add the dependency to your `pubspec.yaml` file:
```yaml
dependencies:
...
google_vision_flutter: ^1.4.0
google_vision_flutter: ^2.0.0+3
```
Expand All @@ -56,74 +80,47 @@ See the [example app](https://github.com/faithoflifedev/google_vision_workspace/
```dart
import 'package:flutter/material.dart';
import 'package:google_vision_flutter/google_vision_flutter.dart';
import 'example_base.dart';

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

final String title;
class LabelDetectionPage extends ExampleBase {

@override
State<LabelDetection> createState() => _MyHomePageState();
}
// final googleVision =
// GoogleVision().withAsset('assets/service_credentials.json');

class _MyHomePageState extends State<LabelDetection> {
final imageAsset = 'assets/setagaya_small.jpg';
static const assetName = 'assets/setagaya_small.jpg';

final _processImage = Image.asset(
imageAsset,
assetName,
fit: BoxFit.fitWidth,
);

LabelDetectionPage({
super.key,
required super.googleVision,
required super.title,
});

@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(imageAsset),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: _processImage,
),
const Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'Process result will appear below:',
),
),
appBar: getAppBar(context),
body: simpleColumn(
assetName: assetName,
sampleImage: _processImage,
result: GoogleVisionImageBuilder.labelDetection(
googleVision: googleVision,
imageProvider: _processImage.image,
builder: (
BuildContext context,
List<EntityAnnotation>? entityAnnotations,
) =>
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()),
),
),
)
],
padding: const EdgeInsets.all(8.0),
child: Column(
children: entityAnnotations!
.map((entity) => Text(
'${(entity.score! * 100).toStringAsFixed(2)}% - ${entity.description}'))
.toList()),
),
),
),
Expand All @@ -137,6 +134,10 @@ class _MyHomePageState extends State<LabelDetection> {

<center><img src="https://github.com/faithoflifedev/google_vision_workspace/blob/main/packages/google_vision_flutter/screenshot/face_detection.png?raw=true&amp;v1" width="320"></center>

## ShoutOut

- To [Andrii Syrokomskyi](https://github.com/signmotion) for creating [flutter_image_converter](https://github.com/signmotion/flutter_image_converter), I've borrowed some of the code included in the `flutter_image_converter` in this package. This package originally had a dependency on `flutter_image_converter`, but that had to be removed to achieve `web` platform support.

## Contributing

Any help from the open-source community is always welcome and needed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CropHintsPage extends ExampleBase {
final _processImage = Image.asset(
assetName,
fit: BoxFit.fitWidth,
width: 300,
);

CropHintsPage({
Expand All @@ -23,7 +24,7 @@ class CropHintsPage extends ExampleBase {
body: simpleColumn(
assetName: assetName,
sampleImage: _processImage,
result: GoogleVisionBuilder.cropHints(
result: GoogleVisionImageBuilder.cropHints(
googleVision: googleVision,
imageProvider: _processImage.image,
builder: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class DocumentTextDetectionPage extends ExampleBase {
final _processImage = Image.asset(
assetName,
fit: BoxFit.fitWidth,
width: 400,
);
DocumentTextDetectionPage({
super.key,
Expand All @@ -22,7 +23,7 @@ class DocumentTextDetectionPage extends ExampleBase {
body: simpleColumn(
assetName: assetName,
sampleImage: _processImage,
result: GoogleVisionBuilder.documentTextDetection(
result: GoogleVisionImageBuilder.documentTextDetection(
googleVision: googleVision,
imageProvider: _processImage.image,
builder: (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:google_vision_flutter/extensions/vertex.dart';
import 'package:google_vision_flutter/google_vision_flutter.dart';
import 'example_base.dart';

Expand All @@ -24,7 +25,7 @@ class FaceDetectionPage extends ExampleBase {
body: simpleColumn(
assetName: assetName,
sampleImage: _processImage,
result: GoogleVisionBuilder.faceDetection(
result: GoogleVisionImageBuilder.faceDetection(
googleVision: googleVision,
imageProvider: _processImage.image,
builder: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ImagePropertiesPage extends ExampleBase {
body: simpleColumn(
assetName: assetName,
sampleImage: _processImage,
result: GoogleVisionBuilder.imageProperties(
result: GoogleVisionImageBuilder.imageProperties(
maxResults: 5,
googleVision: googleVision,
imageProvider: _processImage.image,
Expand Down
Loading

0 comments on commit d51e7da

Please sign in to comment.