如何找到更全面的Google文档以使用其API

时间:2018-06-27 21:56:32

标签: github google-api

很多时候,Google文档不完整,缺少诸如导入所需的库之类的东西。如何查看更全面的示例?

示例:https://cloud.google.com/vision/docs/detecting-faces#vision-face-detection-python

def highlight_faces(image, faces, output_filename):

    """Draws a polygon around the faces, then saves to output_filename.

    Args:
      image: a file containing the image with the faces.
      faces: a list of faces found in the file. This should be in the format
          returned by the Vision API.
      output_filename: the name of the image file to be created, where the
          faces have polygons drawn around them.
    """

    im = Image.open(image)
    draw = ImageDraw.Draw(im)

    for face in faces:
        box = [(vertex.x, vertex.y)
               for vertex in face.bounding_poly.vertices]
        draw.line(box + [box[0]], width=5, fill='#00ff00')

    im.save(output_filename) 

缺少PIL导入

1 个答案:

答案 0 :(得分:1)

在许多Google的代码示例中,都有一个VIEW ON GITHUB按钮,可带您进入完整的工作示例,而不是摘要。对于查找必要的库导入或直接获取更多代码非常有用。

enter image description here

缺少该链接时,有时会有一个文件链接,例如此Firebase示例,链接到index.js

enter image description here