class_docstr: A wrapper for `Google Cloud Vision (GCV) <https://cloud.google.com/vision>`_ Text
  Detection APIs.
  
  Note:
      Google Cloud Vision API returns the output text in two types:
  
      * `text_annotations`:
  
          In this format, GCV automatically find the best aggregation
          level for the text, and return the results in a list. We use
          :obj:`~gather_text_annotations` to reterive this type of
          information.
  
      * `full_text_annotation`:
  
          To support better user control, GCV also provides the
          `full_text_annotation` output, where it returns the hierarchical
          structure of the output text. To process this output, we provide
          the :obj:`~gather_full_text_annotation` function to aggregate the
          texts of the given aggregation level.
class_docstr_tok: ["A","wrapper","for","`","Google","Cloud","Vision","(","GCV",")","<","https",":","\/\/cloud.google.com\/vision",">","`","_","Text","Detection","APIs",".","Note",":","Google","Cloud","Vision","API","returns","the","output","text","in","two","types",":","*","`","text_annotations","`",":","In","this","format",",","GCV","automatically","find","the","best","aggregation","level","for","the","text",",","and","return","the","results","in","a","list",".","We","use",":","obj",":","`","~gather_text_annotations","`","to","reterive","this","type","of","information",".","*","`","full_text_annotation","`",":","To","support","better","user","control",",","GCV","also","provides","the","`","full_text_annotation","`","output",",","where","it","returns","the","hierarchical","structure","of","the","output","text",".","To","process","this","output",",","we","provide","the",":","obj",":","`","~gather_full_text_annotation","`","function","to","aggregate","the","texts","of","the","given","aggregation","level","."]
docstr: Convert the full_text_annotation from GCV output to an :obj:`Layout` object.
  
  Args:
      response (:obj:`AnnotateImageResponse`):
          The returned Google Cloud Vision AnnotateImageResponse object.
  
      agg_level (:obj:`~GCVFeatureType`):
          The layout level to aggregate the text in full_text_annotation.
  
  Returns:
      :obj:`Layout`: The reterived layout from the response.
docstr_tok: ["Convert","the","full_text_annotation","from","GCV","output","to","an",":","obj",":","`","Layout","`","object",".","Args",":","response","(",":","obj",":","`","AnnotateImageResponse","`",")",":","The","returned","Google","Cloud","Vision","AnnotateImageResponse","object",".","agg_level","(",":","obj",":","`","~GCVFeatureType","`",")",":","The","layout","level","to","aggregate","the","text","in","full_text_annotation",".","Returns",":",":","obj",":","`","Layout","`",":","The","reterived","layout","from","the","response","."]
code: def gather_full_text_annotation(response, agg_level):
      """Convert the full_text_annotation from GCV output to an :obj:`Layout` object.
  
      Args:
          response (:obj:`AnnotateImageResponse`):
              The returned Google Cloud Vision AnnotateImageResponse object.
  
          agg_level (:obj:`~GCVFeatureType`):
              The layout level to aggregate the text in full_text_annotation.
  
      Returns:
          :obj:`Layout`: The reterived layout from the response.
      """
  
      def iter_level(
          iter,
          agg_level=None,
          text_blocks=None,
          texts=None,
          cur_level=GCVFeatureType.PAGE,
      ):
          for item in getattr(iter, cur_level.attr_name):
              if cur_level == agg_level:
                  texts = []
  
              # Go down levels to fetch the texts
              if cur_level == GCVFeatureType.SYMBOL:
                  texts.append(item.text)
              elif (
                  cur_level == GCVFeatureType.WORD
                  and agg_level != GCVFeatureType.SYMBOL
              ):
                  chars = []
                  iter_level(
                      item,
                      agg_level,
                      text_blocks,
                      chars,
                      cur_level.child_level,
                  )
                  texts.append("".join(chars))
              else:
                  iter_level(
                      item,
                      agg_level,
                      text_blocks,
                      texts,
                      cur_level.child_level,
                  )
  
              if cur_level == agg_level:
                  nonlocal element_id
                  points = _cvt_GCV_vertices_to_points(
                      item.bounding_box.vertices
                  )
                  text_block = TextBlock(
                      block=Quadrilateral(points),
                      text=" ".join(texts),
                      score=item.confidence,
                      id=element_id,
                  )
  
                  text_blocks.append(text_block)
                  element_id += 1
  
      if agg_level == GCVFeatureType.PAGE:
          doc = response.text_annotations[0]
          points = _cvt_GCV_vertices_to_points(
              doc.bounding_poly.vertices
          )
  
          text_blocks = [
              TextBlock(
                  block=Quadrilateral(points), text=doc.description
              )
          ]
  
      else:
          doc = response.full_text_annotation
          text_blocks = []
          element_id = 0
          iter_level(doc, agg_level, text_blocks)
  
      return Layout(text_blocks)
  
imports: import io
  import os
  import json
  import warnings
  import numpy
  from cv2 import imencode
  from .base import BaseOCRAgent, BaseOCRElementType
  from ..elements import Layout, TextBlock, Quadrilateral, TextBlock
  from ..file_utils import is_gcv_available
label_desc: Use image node_id 6 for calling the GCVAgent obj's underlying member method code with example usage: obj.gather_full_text_annotation(response, agg_level) and returns: Layout