@@ -140,20 +140,18 @@ def anger_likelihood(self):
140140class Face (object ):
141141 """Representation of a face found by the Vision API"""
142142
143- def __init__ (self , angles , blurred_likelihood , bounds ,
144- detection_confidence , emotions , fd_bounds ,
145- headwear_likelihood , landmarks , landmarking_confidence ,
146- under_exposed_likelihood ):
143+ def __init__ (self , angles , bounds , detection_confidence , emotions ,
144+ fd_bounds , headwear_likelihood , image_properties , landmarks ,
145+ landmarking_confidence ):
147146 self ._angles = angles
148- self ._blurred_likelihood = blurred_likelihood
149147 self ._bounds = bounds
150148 self ._detection_confidence = detection_confidence
151149 self ._emotions = emotions
152150 self ._fd_bounds = fd_bounds
153151 self ._headwear_likelihood = headwear_likelihood
154152 self ._landmarks = landmarks
155153 self ._landmarking_confidence = landmarking_confidence
156- self ._under_exposed_likelihood = under_exposed_likelihood
154+ self ._image_properties = image_properties
157155
158156 @classmethod
159157 def from_api_repr (cls , response ):
@@ -166,21 +164,19 @@ def from_api_repr(cls, response):
166164 :returns: A instance of `Face` with data parsed from `response`.
167165 """
168166 angles = Angles .from_api_repr (response )
169- blurred_likelihood = getattr (Likelihood , response ['blurredLikelihood' ])
170167 bounds = Bounds .from_api_repr (response ['boundingPoly' ])
171168 detection_confidence = response ['detectionConfidence' ]
172169 emotions = Emotions .from_api_repr (response )
173170 fd_bounds = FDBounds .from_api_repr (response ['fdBoundingPoly' ])
174171 headwear_likelihood = getattr (Likelihood ,
175172 response ['headwearLikelihood' ])
173+ image_properties = FaceImageProperties .from_api_repr (response )
176174 landmarks = Landmarks (response ['landmarks' ])
177175 landmarking_confidence = response ['landmarkingConfidence' ]
178- under_exposed_likelihood = getattr (Likelihood ,
179- response ['underExposedLikelihood' ])
180176
181- return cls (angles , blurred_likelihood , bounds , detection_confidence ,
182- emotions , fd_bounds , headwear_likelihood , landmarks ,
183- landmarking_confidence , under_exposed_likelihood )
177+ return cls (angles , bounds , detection_confidence , emotions , fd_bounds ,
178+ headwear_likelihood , image_properties , landmarks ,
179+ landmarking_confidence )
184180
185181 @property
186182 def angles (self ):
@@ -192,16 +188,6 @@ def angles(self):
192188
193189 return self ._angles
194190
195- @property
196- def blurred_likelihood (self ):
197- """Likelihood of the image being blurred.
198-
199- :rtype: str
200- :returns: String representing the likelihood based on
201- :class:`gcloud.vision.face.Likelihood`
202- """
203- return self ._blurred_likelihood
204-
205191 @property
206192 def bounds (self ):
207193 """Accessor to the bounding poly information of the detected face.
@@ -249,6 +235,15 @@ def headwear_likelihood(self):
249235 """
250236 return self ._headwear_likelihood
251237
238+ @property
239+ def image_properties (self ):
240+ """Image properties from imaged used in face detection.
241+
242+ :rtype: :class:`gcloud.vision.face.FaceImageProperties`
243+ :returns: ``FaceImageProperties`` object with image properties.
244+ """
245+ return self ._image_properties
246+
252247 @property
253248 def landmarks (self ):
254249 """Accessor to the facial landmarks detected in a face.
@@ -268,15 +263,46 @@ def landmarking_confidence(self):
268263 """
269264 return self ._landmarking_confidence
270265
266+
267+ class FaceImageProperties (object ):
268+ """A representation of the image properties from face detection."""
269+ def __init__ (self , blurred_likelihood , underexposed_likelihood ):
270+ self ._blurred_likelihood = blurred_likelihood
271+ self ._underexposed_likelihood = underexposed_likelihood
272+
273+ @classmethod
274+ def from_api_repr (cls , response ):
275+ """Factory: construct image properties from image.
276+
277+ :rtype: :class:`gcloud.vision.face.FaceImageProperties`
278+ :returns: Instance populated with image property data.
279+ """
280+ blurred_likelihood = getattr (Likelihood ,
281+ response ['blurredLikelihood' ])
282+ underexposed_likelihood = getattr (Likelihood ,
283+ response ['underExposedLikelihood' ])
284+
285+ return cls (blurred_likelihood , underexposed_likelihood )
286+
271287 @property
272- def under_exposed_likelihood (self ):
273- """Likelihood that the image used for detection was under exposed .
288+ def blurred_likelihood (self ):
289+ """Likelihood of the image being blurred .
274290
275291 :rtype: str
276- :returns: String representing the likelihood based on
277- :class:`gcloud.vision.face.Likelihood`
292+ :returns: String representation derived from
293+ :class:`gcloud.vision.face.Position`.
294+ """
295+ return self ._blurred_likelihood
296+
297+ @property
298+ def underexposed_likelihood (self ):
299+ """Likelihood that the image used for detection was underexposed.
300+
301+ :rtype: str
302+ :returns: String representation derived from
303+ :class:`gcloud.vision.face.Position`.
278304 """
279- return self ._under_exposed_likelihood
305+ return self ._underexposed_likelihood
280306
281307
282308class FaceLandmarkTypes (object ):
@@ -348,7 +374,7 @@ def from_api_repr(cls, response_landmark):
348374
349375 @property
350376 def position (self ):
351- """Landmark position.
377+ """Landmark position on face .
352378
353379 :rtype: :class:`gcloud.vision.face.Position`
354380 :returns: Instance of `Position` with landmark coordinates.
@@ -357,7 +383,7 @@ def position(self):
357383
358384 @property
359385 def landmark_type (self ):
360- """Landmark type.
386+ """Landmark type of facial feature .
361387
362388 :rtype: str
363389 :returns: String representation of facial landmark type.
0 commit comments