Я пытаюсь понять API Google Vision и играю с кодом python. Когда я пытаюсь извлечь тип ориентира, я не могу найти правильный метод.
Лучшая документация Я могу найти для Java, где getType () указан как метод.
Вот пробный код с выводом:
from google.cloud import vision
import pickle
import inspect
client = vision.ImageAnnotatorClient()
response = client.annotate_image({
'image': {'source': {'image_uri': 'gs://bsa-test-bucket/2020-04-28 19.54.21.jpg'}},
'features': [{'type': vision.enums.Feature.Type.FACE_DETECTION},
{'type' : vision.enums.Feature.Type.LABEL_DETECTION}],})
for face in response.face_annotations:
for i, lm in enumerate(face.landmarks):
print(i, 'landmark_annotations type', type(lm), '\n')
print(inspect.getmembers(lm))
print(lm.getType())
Вывод:
> 0 landmark_annotations type <class
> 'google.cloud.vision_v1.proto.image_annotator_pb2.Landmark'>
>
> [('_SetListener', <bound method Message._SetListener of type: LEFT_EYE
> position { x: 1198.06494140625 y: 1629.644287109375 z:
> -0.0032958984375 }
> >), ('__getstate__', <bound method Message.__getstate__ of type: LEFT_EYE position { x: 1198.06494140625 y: 1629.644287109375 z:
> -0.0032958984375 }
> >)]
Traceback (most recent call last): File "src/gv-test.py", line 18, in <module>
> print(lm.getType()) AttributeError: getType
Какой правильный метод и где я могу найти документацию для классов, реализованных в Python?
Спасибо!