Skip to content

Commit 603f796

Browse files
'web entities and pages'
1 parent d15f408 commit 603f796

20 files changed

Lines changed: 356 additions & 28 deletions

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.0.8
4+
5+
* web entities and pages
6+
* dependency bump
7+
38
## 1.0.7+7
49

510
* https://github.com/faithoflifedev/google_vision/issues/8

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ To use this package, add the dependency to your `pubspec.yaml` file:
5555
```yaml
5656
dependencies:
5757
...
58-
google_vision: ^1.0.7+7
58+
google_vision: ^1.0.8
5959
```
6060
6161
### Obtaining Authorization Credentials

example/web_detection.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:google_vision/google_vision.dart';
2+
3+
void main() async {
4+
final googleVision =
5+
await GoogleVision.withJwt('example/skc-live-decbd0969cbb.json');
6+
7+
final painter = Painter.fromFilePath('example/structures.png');
8+
9+
final requests = AnnotationRequests(requests: [
10+
AnnotationRequest(
11+
image: Image(painter: painter),
12+
features: [Feature(maxResults: 10, type: 'WEB_DETECTION')])
13+
]);
14+
15+
print('checking...');
16+
17+
AnnotatedResponses annotatedResponses =
18+
await googleVision.annotate(requests: requests);
19+
20+
print(annotatedResponses);
21+
22+
print('done.\n');
23+
}

lib/meta.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
import 'dart:convert' show json;
44

55
final pubSpec = json.decode(
6-
'{"name":"google_vision","version":"1.0.7+7","homepage":"https://github.com/faithoflifedev/google_vision","environment":{"sdk":">=2.17.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 applications.","dependencies":{"args":"^2.4.0","color":"^3.0.0","crypto_keys":"^0.3.0+1","dio":"^5.1.1","http":"^0.13.5","image":"^4.0.16","jose":"^0.3.3","json_annotation":"^4.8.0","retrofit":"^4.0.1","universal_io":"^2.0.4"},"dev_dependencies":{"build_runner":"^2.3.3","grinder":"^0.9.3","json_serializable":"^6.6.1","lints":"^2.0.1","publish_tools":"^0.1.0+9","retrofit_generator":"^6.0.0+3","test":"^1.23.1"},"executables":{"vision":""},"repository":"https://github.com/faithoflifedev/google_vision"}');
6+
'{"name":"google_vision","version":"1.0.8","homepage":"https://github.com/faithoflifedev/google_vision","environment":{"sdk":">=2.17.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 applications.","dependencies":{"args":"^2.4.2","color":"^3.0.0","crypto_keys":"^0.3.0+1","dio":"^5.2.1+1","http":"^0.13.6","image":"^4.0.17","jose":"^0.3.3","json_annotation":"^4.8.1","retrofit":"^4.0.1","universal_io":"^2.2.2"},"dev_dependencies":{"build_runner":"^2.4.5","grinder":"^0.9.4","json_serializable":"^6.7.0","lints":"^2.1.1","publish_tools":"^0.1.0+10","retrofit_generator":"^7.0.1","test":"^1.24.3"},"executables":{"vision":""},"repository":"https://github.com/faithoflifedev/google_vision"}');

lib/src/cmd/vision_helper_command.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:dio/dio.dart';
33
import 'package:google_vision/google_vision.dart';
44

55
/// Helper method to that retrieves error message string.
6-
extension UsageExtension on DioError {
6+
extension UsageExtension on DioException {
77
String get usage {
88
return response?.data['error']['errors'] == null
99
? message!

lib/src/cmd/vision_highlight_command.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class VisionHighlightCommand extends VisionHelper {
7777
}
7878
}
7979
await image.writeAsJpeg(argResults!['output-file']);
80-
} on DioError catch (err) {
80+
} on DioException catch (err) {
8181
throw UsageException('API usage error:', err.usage);
8282
}
8383
}

lib/src/model/annotate_image_response.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'dart:convert' show json;
22

3-
import 'package:google_vision/src/model/safe_search_annotation.dart';
43
import 'package:json_annotation/json_annotation.dart';
54

65
import 'crop_hints_annotation.dart';
@@ -9,8 +8,10 @@ import 'image_annotation_context.dart';
98
import 'image_properties_annotation.dart';
109
import 'entity_annotation.dart';
1110
import 'localized_object_annotation.dart';
11+
import 'safe_search_annotation.dart';
1212
import 'status.dart';
1313
import 'full_text_annotation.dart';
14+
import 'web_detection.dart';
1415

1516
part 'annotate_image_response.g.dart';
1617

@@ -60,7 +61,9 @@ class AnnotateImageResponse {
6061
@JsonKey(name: 'cropHintsAnnotation')
6162
final CropHintsAnnotation? cropHintsAnnotation;
6263

63-
// TODO: webDetection
64+
/// Relevant information for the image from the Internet.
65+
@JsonKey(name: 'webDetection')
66+
final WebDetection? webDetection;
6467

6568
// TODO: productSearchResults
6669

@@ -110,6 +113,7 @@ class AnnotateImageResponse {
110113
this.safeSearchAnnotation,
111114
this.imagePropertiesAnnotation,
112115
this.cropHintsAnnotation,
116+
this.webDetection,
113117
this.error,
114118
this.context,
115119
});

lib/src/model/annotate_image_response.g.dart

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/model/web_detection.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import 'dart:convert';
2+
3+
import 'package:json_annotation/json_annotation.dart';
4+
5+
import 'web_entity.dart';
6+
import 'web_image.dart';
7+
import 'web_label.dart';
8+
import 'web_page.dart';
9+
10+
part 'web_detection.g.dart';
11+
12+
/// Relevant information for the image from the Internet.
13+
@JsonSerializable()
14+
class WebDetection {
15+
/// Entity deduced from similar images on the Internet.
16+
final List<WebEntity>? webEntities;
17+
18+
/// Fully matching images from the Internet.
19+
final List<WebImage>? fullMatchingImages;
20+
21+
/// Partial matching images from the Internet.
22+
final List<WebImage>? partialMatchingImages;
23+
24+
final List<WebPage>? pagesWithMatchingImages;
25+
26+
final List<WebImage>? visuallySimilarImages;
27+
28+
final List<WebLabel>? bestGuessLabels;
29+
30+
WebDetection({
31+
this.webEntities,
32+
this.fullMatchingImages,
33+
this.partialMatchingImages,
34+
this.pagesWithMatchingImages,
35+
this.visuallySimilarImages,
36+
this.bestGuessLabels,
37+
});
38+
39+
factory WebDetection.fromJson(Map<String, dynamic> json) =>
40+
_$WebDetectionFromJson(json);
41+
42+
Map<String, dynamic> toJson() => _$WebDetectionToJson(this);
43+
44+
@override
45+
String toString() => jsonEncode(toJson());
46+
}

lib/src/model/web_detection.g.dart

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)