Skip to content

Commit

Permalink
Vision Partial Veneer (#2298)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesneeringer authored and stephenplusplus committed Jul 26, 2017
1 parent d10362f commit a3406b0
Show file tree
Hide file tree
Showing 25 changed files with 3,274 additions and 4,713 deletions.
26 changes: 26 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"report-dir": "./.coverage",
"exclude": [
"packages/*/src/*{/*,/**/*}.js",
"packages/*/src/*/v*/*.js",
"packages/*/test/**/*.js"
],
"watermarks": {
"branches": [
95,
100
],
"functions": [
95,
100
],
"lines": [
95,
100
],
"statements": [
95,
100
]
}
}
33 changes: 5 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"extend": "^3.0.0",
"glob": "^5.0.9",
"globby": "^3.0.1",
"intelli-espower-loader": "^1.0.1",
"is": "^3.1.0",
"jscs": "^2.1.1",
"jshint": "^2.9.1",
Expand All @@ -25,6 +26,7 @@
"multiline": "^1.0.2",
"nyc": "^10.3.0",
"package-json": "^2.4.0",
"power-assert": "^1.4.2",
"propprop": "^0.3.1",
"semver": "^5.3.0",
"shelljs": "^0.7.3",
Expand All @@ -41,37 +43,12 @@
"remove-ghpages": "node ./scripts/docs/remove.js",
"lint": "jshint scripts/ packages/ system-test/ test/ && jscs packages/ system-test/ test/",
"test": "npm run unit-test && npm run docs && npm run snippet-test",
"unit-test": "mocha --timeout 5000 --bail packages/*/test/*.js",
"unit-test": "mocha --timeout 5000 --bail --require intelli-espower-loader packages/*/test/*.js",
"snippet-test": "mocha --timeout 5000 --bail test/docs.js",
"system-test": "mocha packages/*/system-test/*.js --no-timeouts --bail",
"cover": "nyc --reporter=lcov --reporter=html mocha --no-timeouts packages/*/test/*.js && nyc report",
"system-test": "mocha packages/*/system-test/*.js --require intelli-espower-loader --no-timeouts --bail",
"cover": "nyc --reporter=lcov --reporter=html mocha --require intelli-espower-loader --no-timeouts packages/*/test/*.js && nyc report",
"coveralls": "npm run cover && nyc report --reporter=text-lcov | coveralls"
},
"nyc": {
"report-dir": "./.coverage",
"exclude": [
"packages/*/src/*{/*,/**/*}.js",
"packages/*/test/**/*.js"
],
"watermarks": {
"branches": [
95,
100
],
"functions": [
95,
100
],
"lines": [
95,
100
],
"statements": [
95,
100
]
}
},
"license": "Apache-2.0",
"engines": {
"node": ">=4.0.0"
Expand Down
208 changes: 50 additions & 158 deletions packages/vision/README.md
Original file line number Diff line number Diff line change
@@ -1,168 +1,60 @@
# @google-cloud/vision ([Beta][versioning])
> Cloud Vision Client Library for Node.js
# Node.js Client for Google Cloud Vision API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning))

*Looking for more Google APIs than just Vision? You might want to check out [`google-cloud`][google-cloud].*
[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.
- [Client Library Documentation][]
- [Product Documentation][]

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

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

```sh
$ npm install --save @google-cloud/vision
### Installation
```
```js
var vision = require('@google-cloud/vision')({
projectId: 'grape-spaceship-123',
keyFilename: '/path/to/keyfile.json'
});

// Read the text from an image.
vision.detectText('./image.jpg', function(err, text) {
// text = [
// 'This was text found in the image',
// 'This was more text found in the image'
// ]
});

// Detect faces and the locations of their features in an image.
vision.detectFaces('./image.jpg', function(err, faces) {
// faces = [
// {
// angles: {pan,tilt,roll},
// bounds: {
// head: [{x,y},{x,y},{x,y},{x,y}],
// face: [{x,y},{x,y},{x,y},{x,y}]
// },
// features: {
// confidence: 34.489909,
// chin: {
// center: {x,y,z},
// left: {x,y,z},
// right: {x,y,z}
// },
// ears: {
// left: {x,y,z},
// right: {x,y,z}
// },
// eyebrows: {
// left: {
// left: {x,y,z},
// right: {x,y,z},
// top: {x,y,z}
// },
// right: {
// left: {x,y,z},
// right: {x,y,z},
// top: {x,y,z}
// }
// },
// eyes: {
// left: {
// bottom: {x,y,z},
// center: {x,y,z},
// left: {x,y,z},
// pupil: {x,y,z},
// right: {x,y,z},
// top: {x,y,z}
// },
// right: {
// bottom: {x,y,z},
// center: {x,y,z},
// left: {x,y,z},
// pupil: {x,y,z},
// right: {x,y,z},
// top: {x,y,z}
// }
// },
// forehead: {x,y,z},
// lips: {
// bottom: {x,y,z},
// top: {x,y,z}
// },
// mouth: {
// center: {x,y,z},
// left: {x,y,z},
// right: {x,y,z}
// },
// nose: {
// bottom: {
// center: {x,y,z},
// left: {x,y,z},
// right: {x,y,z}
// },
// tip: {x,y,z},
// top: {x,y,z}
// }
// },
// confidence: 56.748849,
// blurry: false,
// dark: false,
// happy: false,
// hat: false,
// mad: false,
// sad: false,
// surprised: false
// }
// ]
});

// Promises are also supported by omitting callbacks.
vision.detectFaces('./image.jpg').then(function(data) {
var faces = data[0];
});

// It's also possible to integrate with third-party Promise libraries.
var vision = require('@google-cloud/vision')({
promise: require('bluebird')
});
```


## Authentication

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.

### On Google Cloud Platform

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.

``` js
var vision = require('@google-cloud/vision')();
// ...you're good to go!
$ npm install --save @google-cloud/vision
```

### Elsewhere

If you are not running this client on Google Cloud Platform, you need a Google Developers service account. To create a service account:

1. Visit the [Google Developers Console][dev-console].
2. Create a new project or click on an existing project.
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):
* Google Cloud Vision API
4. Navigate to **APIs & auth** > **Credentials** and then:
* 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.
* 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.

``` js
var projectId = process.env.GCLOUD_PROJECT; // E.g. 'grape-spaceship-123'

var vision = require('@google-cloud/vision')({
projectId: projectId,

// The path to your key file:
keyFilename: '/path/to/keyfile.json'

// Or the contents of the key file:
credentials: require('./path/to/keyfile.json')
});

// ...you're good to go!
### Preview
#### ImageAnnotatorClient
```js
var vision = require('@google-cloud/vision');

var client = vision({
// optional auth parameters.
});

var gcsImageUri = 'gs://gapic-toolkit/President_Barack_Obama.jpg';
var source = {
gcsImageUri : gcsImageUri
};
var image = {
source : source
};
var type = vision.v1.types.Feature.Type.FACE_DETECTION;
var featuresElement = {
type : type
};
var features = [featuresElement];
var requestsElement = {
image : image,
features : features
};
var requests = [requestsElement];
client.batchAnnotateImages({requests: requests}).then(function(responses) {
var response = responses[0];
// doThingsWith(response)
})
.catch(function(err) {
console.error(err);
});
```

### Next Steps
- Read the [Client Library Documentation][] for Google Cloud Vision API to see other available methods on the client.
- Read the [Google Cloud Vision API Product documentation][Product Documentation] to learn more about the product and see How-to Guides.
- 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.

[versioning]: https://github.com/GoogleCloudPlatform/google-cloud-node#versioning
[google-cloud]: https://github.com/GoogleCloudPlatform/google-cloud-node/
[gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
[dev-console]: https://console.developers.google.com/project
[gcloud-vision-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/vision
[cloud-vision-docs]: https://cloud.google.com/vision/docs
[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/vision
[Product Documentation]: https://cloud.google.com/vision
37 changes: 16 additions & 21 deletions packages/vision/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"repository": "GoogleCloudPlatform/google-cloud-node",
"name": "@google-cloud/vision",
"version": "0.11.5",
"author": "Google Inc.",
"description": "Cloud Vision Client Library for Node.js",
"author": "Google Inc",
"description": "Google Cloud Vision API client for Node.js",
"contributors": [
{
"name": "Burcu Dogan",
Expand All @@ -29,14 +30,12 @@
"email": "[email protected]"
}
],
"main": "./src/index.js",
"main": "src/index.js",
"files": [
"src",
"AUTHORS",
"CONTRIBUTORS",
"COPYING"
],
"repository": "googlecloudplatform/google-cloud-node",
"keywords": [
"google apis client",
"google api client",
Expand All @@ -47,36 +46,32 @@
"google cloud",
"cloud",
"google vision",
"vision"
"vision",
"Google Cloud Vision API"
],
"dependencies": {
"@google-cloud/common": "^0.13.0",
"@google-cloud/common-grpc": "^0.4.0",
"arrify": "^1.0.0",
"async": "^2.0.1",
"extend": "^3.0.0",
"google-gax": "^0.13.0",
"google-gax": "^0.13.2",
"google-proto-files": "^0.12.0",
"is": "^3.0.1",
"prop-assign": "^1.0.0",
"propprop": "^0.3.0",
"rgb-hex": "^1.0.0",
"string-format-obj": "^1.0.0"
"is": "^3.0.1"
},
"devDependencies": {
"@google-cloud/storage": "*",
"deep-strict-equal": "^0.2.0",
"intelli-espower-loader": "^1.0.1",
"mocha": "^3.0.1",
"multiline": "^1.0.2",
"node-uuid": "^1.4.7",
"normalize-newline": "^2.0.0",
"proxyquire": "^1.7.10",
"tmp": "^0.0.31"
"nyc": "^10.3.0",
"power-assert": "^1.4.2",
"sinon": "^2.2.0"
},
"scripts": {
"cover": "nyc --reporter=lcov --reporter=html mocha --no-timeouts --require intelli-espower-loader test/*.js && nyc report",
"publish-module": "node ../../scripts/publish.js vision",
"test": "mocha test/*.js",
"system-test": "mocha system-test/*.js --no-timeouts --bail"
"test": "mocha --require intelli-espower-loader test/*.js",
"smoke-test": "mocha smoke-test/*.js --timeout 5000",
"system-test": "mocha system-test/*.js --require intelli-espower-loader --no-timeouts --bail"
},
"license": "Apache-2.0",
"engines": {
Expand Down
Loading

0 comments on commit a3406b0

Please sign in to comment.