Skip to content

Commit a3406b0

Browse files
lukesneeringerstephenplusplus
authored andcommitted
Vision Partial Veneer (#2298)
1 parent d10362f commit a3406b0

25 files changed

+3274
-4713
lines changed

.nycrc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"report-dir": "./.coverage",
3+
"exclude": [
4+
"packages/*/src/*{/*,/**/*}.js",
5+
"packages/*/src/*/v*/*.js",
6+
"packages/*/test/**/*.js"
7+
],
8+
"watermarks": {
9+
"branches": [
10+
95,
11+
100
12+
],
13+
"functions": [
14+
95,
15+
100
16+
],
17+
"lines": [
18+
95,
19+
100
20+
],
21+
"statements": [
22+
95,
23+
100
24+
]
25+
}
26+
}

package.json

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"extend": "^3.0.0",
1414
"glob": "^5.0.9",
1515
"globby": "^3.0.1",
16+
"intelli-espower-loader": "^1.0.1",
1617
"is": "^3.1.0",
1718
"jscs": "^2.1.1",
1819
"jshint": "^2.9.1",
@@ -25,6 +26,7 @@
2526
"multiline": "^1.0.2",
2627
"nyc": "^10.3.0",
2728
"package-json": "^2.4.0",
29+
"power-assert": "^1.4.2",
2830
"propprop": "^0.3.1",
2931
"semver": "^5.3.0",
3032
"shelljs": "^0.7.3",
@@ -41,37 +43,12 @@
4143
"remove-ghpages": "node ./scripts/docs/remove.js",
4244
"lint": "jshint scripts/ packages/ system-test/ test/ && jscs packages/ system-test/ test/",
4345
"test": "npm run unit-test && npm run docs && npm run snippet-test",
44-
"unit-test": "mocha --timeout 5000 --bail packages/*/test/*.js",
46+
"unit-test": "mocha --timeout 5000 --bail --require intelli-espower-loader packages/*/test/*.js",
4547
"snippet-test": "mocha --timeout 5000 --bail test/docs.js",
46-
"system-test": "mocha packages/*/system-test/*.js --no-timeouts --bail",
47-
"cover": "nyc --reporter=lcov --reporter=html mocha --no-timeouts packages/*/test/*.js && nyc report",
48+
"system-test": "mocha packages/*/system-test/*.js --require intelli-espower-loader --no-timeouts --bail",
49+
"cover": "nyc --reporter=lcov --reporter=html mocha --require intelli-espower-loader --no-timeouts packages/*/test/*.js && nyc report",
4850
"coveralls": "npm run cover && nyc report --reporter=text-lcov | coveralls"
4951
},
50-
"nyc": {
51-
"report-dir": "./.coverage",
52-
"exclude": [
53-
"packages/*/src/*{/*,/**/*}.js",
54-
"packages/*/test/**/*.js"
55-
],
56-
"watermarks": {
57-
"branches": [
58-
95,
59-
100
60-
],
61-
"functions": [
62-
95,
63-
100
64-
],
65-
"lines": [
66-
95,
67-
100
68-
],
69-
"statements": [
70-
95,
71-
100
72-
]
73-
}
74-
},
7552
"license": "Apache-2.0",
7653
"engines": {
7754
"node": ">=4.0.0"

packages/vision/README.md

Lines changed: 50 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,60 @@
1-
# @google-cloud/vision ([Beta][versioning])
2-
> Cloud Vision Client Library for Node.js
1+
# Node.js Client for Google Cloud Vision API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning))
32

4-
*Looking for more Google APIs than just Vision? You might want to check out [`google-cloud`][google-cloud].*
3+
[Google Cloud Vision API][Product Documentation]: Integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications.
4+
- [Client Library Documentation][]
5+
- [Product Documentation][]
56

6-
- [API Documentation][gcloud-vision-docs]
7-
- [Official Documentation][cloud-vision-docs]
7+
## Quick Start
8+
In order to use this library, you first need to go through the following steps:
89

10+
1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
11+
2. [Enable the Google Cloud Vision API.](https://console.cloud.google.com/apis/api/vision)
12+
3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication)
913

10-
```sh
11-
$ npm install --save @google-cloud/vision
14+
### Installation
1215
```
13-
```js
14-
var vision = require('@google-cloud/vision')({
15-
projectId: 'grape-spaceship-123',
16-
keyFilename: '/path/to/keyfile.json'
17-
});
18-
19-
// Read the text from an image.
20-
vision.detectText('./image.jpg', function(err, text) {
21-
// text = [
22-
// 'This was text found in the image',
23-
// 'This was more text found in the image'
24-
// ]
25-
});
26-
27-
// Detect faces and the locations of their features in an image.
28-
vision.detectFaces('./image.jpg', function(err, faces) {
29-
// faces = [
30-
// {
31-
// angles: {pan,tilt,roll},
32-
// bounds: {
33-
// head: [{x,y},{x,y},{x,y},{x,y}],
34-
// face: [{x,y},{x,y},{x,y},{x,y}]
35-
// },
36-
// features: {
37-
// confidence: 34.489909,
38-
// chin: {
39-
// center: {x,y,z},
40-
// left: {x,y,z},
41-
// right: {x,y,z}
42-
// },
43-
// ears: {
44-
// left: {x,y,z},
45-
// right: {x,y,z}
46-
// },
47-
// eyebrows: {
48-
// left: {
49-
// left: {x,y,z},
50-
// right: {x,y,z},
51-
// top: {x,y,z}
52-
// },
53-
// right: {
54-
// left: {x,y,z},
55-
// right: {x,y,z},
56-
// top: {x,y,z}
57-
// }
58-
// },
59-
// eyes: {
60-
// left: {
61-
// bottom: {x,y,z},
62-
// center: {x,y,z},
63-
// left: {x,y,z},
64-
// pupil: {x,y,z},
65-
// right: {x,y,z},
66-
// top: {x,y,z}
67-
// },
68-
// right: {
69-
// bottom: {x,y,z},
70-
// center: {x,y,z},
71-
// left: {x,y,z},
72-
// pupil: {x,y,z},
73-
// right: {x,y,z},
74-
// top: {x,y,z}
75-
// }
76-
// },
77-
// forehead: {x,y,z},
78-
// lips: {
79-
// bottom: {x,y,z},
80-
// top: {x,y,z}
81-
// },
82-
// mouth: {
83-
// center: {x,y,z},
84-
// left: {x,y,z},
85-
// right: {x,y,z}
86-
// },
87-
// nose: {
88-
// bottom: {
89-
// center: {x,y,z},
90-
// left: {x,y,z},
91-
// right: {x,y,z}
92-
// },
93-
// tip: {x,y,z},
94-
// top: {x,y,z}
95-
// }
96-
// },
97-
// confidence: 56.748849,
98-
// blurry: false,
99-
// dark: false,
100-
// happy: false,
101-
// hat: false,
102-
// mad: false,
103-
// sad: false,
104-
// surprised: false
105-
// }
106-
// ]
107-
});
108-
109-
// Promises are also supported by omitting callbacks.
110-
vision.detectFaces('./image.jpg').then(function(data) {
111-
var faces = data[0];
112-
});
113-
114-
// It's also possible to integrate with third-party Promise libraries.
115-
var vision = require('@google-cloud/vision')({
116-
promise: require('bluebird')
117-
});
118-
```
119-
120-
121-
## Authentication
122-
123-
It's incredibly easy to get authenticated and start using Google's APIs. You can set your credentials on a global basis as well as on a per-API basis. See each individual API section below to see how you can auth on a per-API-basis. This is useful if you want to use different accounts for different Cloud services.
124-
125-
### On Google Cloud Platform
126-
127-
If you are running this client on Google Cloud Platform, we handle authentication for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access.
128-
129-
``` js
130-
var vision = require('@google-cloud/vision')();
131-
// ...you're good to go!
16+
$ npm install --save @google-cloud/vision
13217
```
13318

134-
### Elsewhere
135-
136-
If you are not running this client on Google Cloud Platform, you need a Google Developers service account. To create a service account:
137-
138-
1. Visit the [Google Developers Console][dev-console].
139-
2. Create a new project or click on an existing project.
140-
3. Navigate to **APIs & auth** > **APIs section** and turn on the following APIs (you may need to enable billing in order to use these services):
141-
* Google Cloud Vision API
142-
4. Navigate to **APIs & auth** > **Credentials** and then:
143-
* If you want to use a new service account, click on **Create new Client ID** and select **Service account**. After the account is created, you will be prompted to download the JSON key file that the library uses to authenticate your requests.
144-
* If you want to generate a new key for an existing service account, click on **Generate new JSON key** and download the JSON key file.
145-
146-
``` js
147-
var projectId = process.env.GCLOUD_PROJECT; // E.g. 'grape-spaceship-123'
148-
149-
var vision = require('@google-cloud/vision')({
150-
projectId: projectId,
151-
152-
// The path to your key file:
153-
keyFilename: '/path/to/keyfile.json'
154-
155-
// Or the contents of the key file:
156-
credentials: require('./path/to/keyfile.json')
157-
});
158-
159-
// ...you're good to go!
19+
### Preview
20+
#### ImageAnnotatorClient
21+
```js
22+
var vision = require('@google-cloud/vision');
23+
24+
var client = vision({
25+
// optional auth parameters.
26+
});
27+
28+
var gcsImageUri = 'gs://gapic-toolkit/President_Barack_Obama.jpg';
29+
var source = {
30+
gcsImageUri : gcsImageUri
31+
};
32+
var image = {
33+
source : source
34+
};
35+
var type = vision.v1.types.Feature.Type.FACE_DETECTION;
36+
var featuresElement = {
37+
type : type
38+
};
39+
var features = [featuresElement];
40+
var requestsElement = {
41+
image : image,
42+
features : features
43+
};
44+
var requests = [requestsElement];
45+
client.batchAnnotateImages({requests: requests}).then(function(responses) {
46+
var response = responses[0];
47+
// doThingsWith(response)
48+
})
49+
.catch(function(err) {
50+
console.error(err);
51+
});
16052
```
16153

54+
### Next Steps
55+
- Read the [Client Library Documentation][] for Google Cloud Vision API to see other available methods on the client.
56+
- Read the [Google Cloud Vision API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
57+
- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/README.md) to see the full list of Cloud APIs that we cover.
16258

163-
[versioning]: https://github.com/GoogleCloudPlatform/google-cloud-node#versioning
164-
[google-cloud]: https://github.com/GoogleCloudPlatform/google-cloud-node/
165-
[gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
166-
[dev-console]: https://console.developers.google.com/project
167-
[gcloud-vision-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/vision
168-
[cloud-vision-docs]: https://cloud.google.com/vision/docs
59+
[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/vision
60+
[Product Documentation]: https://cloud.google.com/vision

packages/vision/package.json

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2+
"repository": "GoogleCloudPlatform/google-cloud-node",
23
"name": "@google-cloud/vision",
34
"version": "0.11.5",
4-
"author": "Google Inc.",
5-
"description": "Cloud Vision Client Library for Node.js",
5+
"author": "Google Inc",
6+
"description": "Google Cloud Vision API client for Node.js",
67
"contributors": [
78
{
89
"name": "Burcu Dogan",
@@ -29,14 +30,12 @@
2930
"email": "[email protected]"
3031
}
3132
],
32-
"main": "./src/index.js",
33+
"main": "src/index.js",
3334
"files": [
3435
"src",
3536
"AUTHORS",
36-
"CONTRIBUTORS",
3737
"COPYING"
3838
],
39-
"repository": "googlecloudplatform/google-cloud-node",
4039
"keywords": [
4140
"google apis client",
4241
"google api client",
@@ -47,36 +46,32 @@
4746
"google cloud",
4847
"cloud",
4948
"google vision",
50-
"vision"
49+
"vision",
50+
"Google Cloud Vision API"
5151
],
5252
"dependencies": {
5353
"@google-cloud/common": "^0.13.0",
54-
"@google-cloud/common-grpc": "^0.4.0",
55-
"arrify": "^1.0.0",
5654
"async": "^2.0.1",
5755
"extend": "^3.0.0",
58-
"google-gax": "^0.13.0",
56+
"google-gax": "^0.13.2",
5957
"google-proto-files": "^0.12.0",
60-
"is": "^3.0.1",
61-
"prop-assign": "^1.0.0",
62-
"propprop": "^0.3.0",
63-
"rgb-hex": "^1.0.0",
64-
"string-format-obj": "^1.0.0"
58+
"is": "^3.0.1"
6559
},
6660
"devDependencies": {
6761
"@google-cloud/storage": "*",
68-
"deep-strict-equal": "^0.2.0",
62+
"intelli-espower-loader": "^1.0.1",
6963
"mocha": "^3.0.1",
70-
"multiline": "^1.0.2",
7164
"node-uuid": "^1.4.7",
72-
"normalize-newline": "^2.0.0",
73-
"proxyquire": "^1.7.10",
74-
"tmp": "^0.0.31"
65+
"nyc": "^10.3.0",
66+
"power-assert": "^1.4.2",
67+
"sinon": "^2.2.0"
7568
},
7669
"scripts": {
70+
"cover": "nyc --reporter=lcov --reporter=html mocha --no-timeouts --require intelli-espower-loader test/*.js && nyc report",
7771
"publish-module": "node ../../scripts/publish.js vision",
78-
"test": "mocha test/*.js",
79-
"system-test": "mocha system-test/*.js --no-timeouts --bail"
72+
"test": "mocha --require intelli-espower-loader test/*.js",
73+
"smoke-test": "mocha smoke-test/*.js --timeout 5000",
74+
"system-test": "mocha system-test/*.js --require intelli-espower-loader --no-timeouts --bail"
8075
},
8176
"license": "Apache-2.0",
8277
"engines": {

0 commit comments

Comments
 (0)