def extract_patch(img, detection, force_square=False, alpha=None):
    """Extracts the patch from the image.

    Args:
        img: a numpy image array
        detection: a :class:`fiftyone.core.labels.Detection` defining the
            patch
        force_square (False): whether to minimally manipulate the patch
            bounding box into a square prior to extraction
        alpha (None): an optional expansion/contraction to apply to the patch
            before extracting it, 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 = 0.1`` to expand
            the box by 10%, and set ``alpha = -0.1`` to contract the box by 10%

    Returns:
        the image patch
    """
    dobj = foue.to_detected_object(detection, extra_attrs=False)

    bbox = dobj.bounding_box
    if alpha is not None:
        bbox = bbox.pad_relative(alpha)

    return bbox.extract_from(img, force_square=force_square)
Extracts the patch from the image.

    Args:
        img: a numpy image array
        detection: a :class:`fiftyone.core.labels.Detection` defining the
            patch
        force_square (False): whether to minimally manipulate the patch
            bounding box into a square prior to extraction
        alpha (None): an optional expansion/contraction to apply to the patch
            before extracting it, 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 = 0.1`` to expand
            the box by 10%, and set ``alpha = -0.1`` to contract the box by 10%

    Returns:
        the image patch
    
fiftyone/utils/patches.py