def _filter_annotations_list(annotations_list, image,
    small_object_area_threshold, foreground_class_of_interest_id):
    """Filters COCO annotations_list to visual wakewords annotations_list.

  Each image is assigned a label 1 or 0. The label 1 is assigned as long
  as it has at least one foreground_class_of_interest (e.g. person)
  bounding box greater than 5% of the image area.

  Args:
    annotations_list: list of dicts with keys: [ u'id', u'image_id',
    u'category_id', u'segmentation', u'area', u'bbox' : [x,y,width,height],
      u'iscrowd']. Notice that bounding box coordinates in the official COCO
      dataset are given as [x, y, width, height] tuples using absolute
      coordinates where x, y represent the top-left (0-indexed) corner.
    image: dict with keys: [u'license', u'file_name', u'coco_url', u'height',
      u'width', u'date_captured', u'flickr_url', u'id']
    small_object_area_threshold: threshold on fraction of image area below which
      small objects are filtered
    foreground_class_of_interest_id: category of COCO dataset which visual
      wakewords filters

  Returns:
    filtered_annotations_list: list of dicts with keys: [ u'image_id',
    u'label', u'category_id', u'count',
    u'object':[{"category_id", "area", "bbox" : [x,y,width,height],}]
  """
    category_ids = []
    area = []
    flag_small_object = []
    num_ann = 0
    image_height = image['height']
    image_width = image['width']
    image_area = image_height * image_width
    bbox = []
    count = 0
    for object_annotations in annotations_list:
        x, y, width, height = tuple(object_annotations['bbox'])
        category_id = int(object_annotations['category_id'])
        category_ids.append(category_id)
        obj_area = object_annotations['area']
        normalized_object_area = obj_area / image_area
        if category_id == foreground_class_of_interest_id:
            if normalized_object_area < small_object_area_threshold:
                flag_small_object.append(True)
            else:
                flag_small_object.append(False)
                bbox.append({u'bbox': [x, y, width, height], u'area':
                    obj_area, u'category_id': category_id})
                count = count + 1
        area.append(obj_area)
        num_ann = num_ann + 1
    if (foreground_class_of_interest_id in category_ids and False in
        flag_small_object):
        return {u'image_id': image['id'], u'label': 1, u'object': bbox,
            u'count': count}
    else:
        return {u'image_id': image['id'], u'label': 0, u'object': [],
            u'count': 0}
