Skip to content

Commit

Permalink
#1881 vision: include original Likelihood score (#1887)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtw authored and stephenplusplus committed Mar 13, 2017
1 parent 882da55 commit de32ea4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/google-cloud-vision/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,12 +960,19 @@ Vision.prototype.detectCrops = function(images, options, callback) {
* // },
* // confidence: 56.748849,
* // anger: false,
* // angerLikelihood: 1,
* // blurred: false,
* // blurredLikelihood: 1,
* // headwear: false,
* // headwearLikelihood: 1,
* // joy: false,
* // joyLikelihood: 1,
* // sorrow: false,
* // sorrowLikelihood: 1,
* // surprise: false,
* // underExposed: false
* // surpriseLikelihood: 1,
* // underExposed: false,
* // underExposedLikelihood: 1
* // }
* // ]
* });
Expand Down Expand Up @@ -1916,6 +1923,8 @@ Vision.formatFaceAnnotation_ = function(faceAnnotation) {

formattedFaceAnnotation[shortenedProp] =
Vision.gteLikelihood_(LIKELY, faceAnnotation[prop]);

formattedFaceAnnotation[prop] = Vision.likelihood[faceAnnotation[prop]];
}
}

Expand Down
10 changes: 9 additions & 1 deletion packages/google-cloud-vision/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1474,15 +1474,23 @@ describe('Vision', function() {
confidence: faceAnnotation.detectionConfidence * 100,

anger: true,
angerLikelihood: 3,
blurred: true,
blurredLikelihood: 3,
headwear: true,
headwearLikelihood: 3,
joy: true,
joyLikelihood: 3,
sorrow: true,
sorrowLikelihood: 3,
surprise: true,
surpriseLikelihood: 3,
underExposed: true,
underExposedLikelihood: 3,

// Checks that *any* property that ends in `Likelihood` is shortened.
nonExistent: true
nonExistent: true,
nonExistentLikelihood: 3
};

var formatted = Vision.formatFaceAnnotation_(faceAnnotation);
Expand Down

0 comments on commit de32ea4

Please sign in to comment.