Repository navigation
implement Vision API - #1136
implement Vision API#1136
Conversation
|
Fancy! 🌈 |
|
@callmehiphop I'm going to work on locking this up with tests. Should I wait a tick for you to check out the API? @dhermes 🐶❤️ |
|
@stephenplusplus sure, I'll take a peak! |
| * @param {object} callback.apiResponse - Raw API response. | ||
| * | ||
| * @example | ||
| * vision.annotate(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
I like it, the convenience methods look great! Do we know if there's a common use case where a user might want to leverage more than one feature on a given image (e.g. face + text)? If there is, it might be nice to make the |
|
Wow, I totally misread the API and thought only a single type of annotation could be requested at a time. I will definitely make it easier. |
257a434 to
44387ae
Compare
40d6c52 to
68c904f
Compare
|
Awesome! @bradabrams I think you were using this too, right? |
29130c7 to
f6f0c81
Compare
|
don't merge lifted! |
|
Thank you @stephenplusplus for implementing the vision API in nodejs. I used the code of your fork (git://github.com/stephenplusplus/gcloud-node.git#spp--vision), Is this the latest version? because I noticed that the face detect function does not return the original response Looks like the splice line 334 removes the objects from it. To fix this I cloned the original response object in the Vision.prototype.annotate function, like this: var respClone = extend(true, {}, resp); callback(null, resp.responses, respClone); I also wondered why the vision API always told me that I was not happy when analyzing my picture, so I tried to smile even more but this did not help, it always told me happy = false ... finally I noticed that line 1134 the likehood was not transformed into a value before the comparison, I changed it to this: var value = Vision.likelihood[object[prop]]; |
|
Thank you very much for catching this stuff. I will fix this up so you will be happy in no time! |
f6f0c81 to
a2955bc
Compare
| [gcloud-search-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/search | ||
| [gcloud-storage-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/storage | ||
| [gcloud-translate-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/translate | ||
| [gcloud-translate-docs]: https://googlecloudplatform.github.io/gcloud-node/#/docs/vision |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
a2955bc to
7201f7c
Compare
| * </p> | ||
| * | ||
| * To learn more about the Vision API, see | ||
| * [Getting Started](https://cloud.google.com/vision/docs/getting-started). |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
7201f7c to
e5bd1f5
Compare
| * [`AnnotateImageRequest`](https://cloud.google.com/vision/reference/rest/v1/images/annotate#AnnotateImageRequest). | ||
| * @param {function} callback - The callback function. | ||
| * @param {?error} callback.err - An error returned while making this request. | ||
| * @param {object} callback.apiResponse - Raw API response. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
b1bcb5e to
b3c69cd
Compare
|
|
||
| for (var i = 0; i < images.length; i++) { | ||
| detections.push(annotations.splice(0, types.length)); | ||
| } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
b3c69cd to
9215494
Compare
| detections = detections | ||
| .map(mergeArrayOfObjects) | ||
| .map(function(annotations) { | ||
| if (Object.keys(annotations).length === 0) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
9215494 to
e325d64
Compare
| var types = arrify(options.types); | ||
|
|
||
| var typeShortNameToFullName = { | ||
| face: 'FACE_DETECTION', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@stephenplusplus works perfectly now, well done and thank you |
| assert.ifError(err); | ||
|
|
||
| assert.deepEqual(properties.colors, [ | ||
| '#3b3027', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
e325d64 to
9a07c4f
Compare
|
@chrisweb great, thanks again for testing this out! |
9a07c4f to
a362ae8
Compare
|
woo 👍 |
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com> Co-authored-by: danieljbruce <danieljbruce@users.noreply.github.com>
Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com> Co-authored-by: danieljbruce <danieljbruce@users.noreply.github.com>
Co-authored-by: sofisl <55454395+sofisl@users.noreply.github.com> Co-authored-by: danieljbruce <danieljbruce@users.noreply.github.com>
* fix: add whitespace to generateV4SignedPolicy * fix: revert break for hidden fields. * fix Co-authored-by: Jonathan Lui <jonathanlui@google.com>
Fixes #1144
The Vision API. Which has one endpoint.
Docs
http://stephenplusplus.github.io/gcloud-node/#/docs/master/vision
To Dos
IMAGE_PROPERTIESExamples
All Vision methods take a single or multiple images, which may be File objects or file paths. Therefore, these are all acceptable...
To detect text from an image...
To detect faces in an image... (this one returns a super long object)
All methods also accept an object to activate "verbose" mode...