class_docstr: Class for iterating over the labeled/unlabeled image patches in a
  collection.
  
  By default, this class emits only the image patches, but you can set
  ``include_labels`` to True to emit ``(img_patch, label)`` tuples.
  
  Args:
      samples: a :class:`fiftyone.core.collections.SampleCollection`
      patches_field (None): the name of the field defining the image patches
          in each sample to extract. Must be of type
          :class:`fiftyone.core.labels.Detection`,
          :class:`fiftyone.core.labels.Detections`,
          :class:`fiftyone.core.labels.Polyline`, or
          :class:`fiftyone.core.labels.Polylines`. This can be automatically
          inferred (only) if ``samples`` is a patches view
      include_labels (False): whether to emit ``(img_patch, label)`` tuples
          rather than just image patches
      force_rgb (False): whether to force convert the images to RGB
      force_square (False): whether to minimally manipulate the patch
          bounding boxes into squares prior to extraction
      alpha (None): an optional expansion/contraction to apply to the patches
          before extracting them, in ``[-1, inf)``. If provided, the length
          and width of the box are expanded (or contracted, when
          ``alpha < 0``) by ``(100 * alpha)%``. For example, set
          ``alpha = 1.1`` to expand the boxes by 10%, and set ``alpha = 0.9``
          to contract the boxes by 10%
class_docstr_tok: ["Class","for","iterating","over","the","labeled\/unlabeled","image","patches","in","a","collection",".","By","default",",","this","class","emits","only","the","image","patches",",","but","you","can","set","``","include_labels","``","to","True","to","emit","``","(","img_patch",",","label",")","``","tuples",".","Args",":","samples",":","a",":","class",":","`","fiftyone.core.collections.SampleCollection","`","patches_field","(","None",")",":","the","name","of","the","field","defining","the","image","patches","in","each","sample","to","extract",".","Must","be","of","type",":","class",":","`","fiftyone.core.labels.Detection","`",",",":","class",":","`","fiftyone.core.labels.Detections","`",",",":","class",":","`","fiftyone.core.labels.Polyline","`",",","or",":","class",":","`","fiftyone.core.labels.Polylines","`",".","This","can","be","automatically","inferred","(","only",")","if","``","samples","``","is","a","patches","view","include_labels","(","False",")",":","whether","to","emit","``","(","img_patch",",","label",")","``","tuples","rather","than","just","image","patches","force_rgb","(","False",")",":","whether","to","force","convert","the","images","to","RGB","force_square","(","False",")",":","whether","to","minimally","manipulate","the","patch","bounding","boxes","into","squares","prior","to","extraction","alpha","(","None",")",":","an","optional","expansion\/contraction","to","apply","to","the","patches","before","extracting","them",",","in","``","[","-1",",","inf",")","``",".","If","provided",",","the","length","and","width","of","the","box","are","expanded","(","or","contracted",",","when","``","alpha","<","0","``",")","by","``","(","100","*","alpha",")","%","``",".","For","example",",","set","``","alpha","=","1.1","``","to","expand","the","boxes","by","10","%",",","and","set","``","alpha","=","0.9","``","to","contract","the","boxes","by","10","%"]
code: def __iter__(self):
      for sample in self.samples.select_fields(self.patches_field):
          patches = parse_patches(
              sample, self.patches_field, handle_missing="skip"
          )
  
          if patches is not None:
              fov.validate_image_sample(sample)
              img = _load_image(
                  sample.filepath, force_rgb=self.force_rgb
              )
              for detection in patches.detections:
                  patch = extract_patch(
                      img,
                      detection,
                      force_square=self.force_square,
                      alpha=self.alpha,
                  )
                  if self.include_labels:
                      yield patch, _to_classification(detection)
                  else:
                      yield patch
  
file_path: fiftyone/fiftyone/utils/patches.py
imports: import cv2
  import fiftyone.core.frame
  import fiftyone.core.labels
  import fiftyone.core.validation
  import fiftyone.utils.eta
  import fiftyone.utils.image
label_desc: Use image node_id 3 for calling the ImagePatchesExtractor obj's underlying member method code with example usage: obj.__iter__() without return types