def obj_box_horizontal_flip(im, coords=None, is_rescale=False, is_center=False, is_random=False):
if coords is None:<EOL><INDENT>coords = []<EOL><DEDENT>def _flip(im, coords):<EOL><INDENT>im = flip_axis(im, axis=<NUM_LIT:1>, is_random=False)<EOL>coords_new = list()<EOL>for coord in coords:<EOL><INDENT>if len(coord) != <NUM_LIT:4>:<EOL><INDENT>raise AssertionError("<STR_LIT>")<EOL><DEDENT>if is_rescale:<EOL><INDENT>if is_center:<EOL><INDENT>x = <NUM_LIT:1.> - coord[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>x = <NUM_LIT:1.> - coord[<NUM_LIT:0>] - coord[<NUM_LIT:2>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if is_center:<EOL><INDENT>x = im.shape[<NUM_LIT:1>] - coord[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>x = im.shape[<NUM_LIT:1>] - coord[<NUM_LIT:0>] - coord[<NUM_LIT:2>]<EOL><DEDENT><DEDENT>coords_new.append([x, coord[<NUM_LIT:1>], coord[<NUM_LIT:2>], coord[<NUM_LIT:3>]])<EOL><DEDENT>return im, coords_new<EOL><DEDENT>if is_random:<EOL><INDENT>factor = np.random.uniform(-<NUM_LIT:1>, <NUM_LIT:1>)<EOL>if factor > <NUM_LIT:0>:<EOL><INDENT>return _flip(im, coords)<EOL><DEDENT>else:<EOL><INDENT>return im, coords<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return _flip(im, coords)<EOL><DEDENT>
Left-right flip the image and coordinates for object detection.

    Parameters
    ----------
    im : numpy.array
        An image with dimension of [row, col, channel] (default).
    coords : list of list of 4 int/float or None
        Coordinates [[x, y, w, h], [x, y, w, h], ...].
    is_rescale : boolean
        Set to True, if the input coordinates are rescaled to [0, 1]. Default is False.
    is_center : boolean
        Set to True, if the x and y of coordinates are the centroid (i.e. darknet format). Default is False.
    is_random : boolean
        If True, randomly flip. Default is False.

    Returns
    -------
    numpy.array
        A processed image
    list of list of 4 numbers
        A list of new bounding boxes.

    Examples
    --------
    >>> im = np.zeros([80, 100])    # as an image with shape width=100, height=80
    >>> im, coords = obj_box_left_right_flip(im, coords=[[0.2, 0.4, 0.3, 0.3], [0.1, 0.5, 0.2, 0.3]], is_rescale=True, is_center=True, is_random=False)
    >>> print(coords)
      [[0.8, 0.4, 0.3, 0.3], [0.9, 0.5, 0.2, 0.3]]
    >>> im, coords = obj_box_left_right_flip(im, coords=[[0.2, 0.4, 0.3, 0.3]], is_rescale=True, is_center=False, is_random=False)
    >>> print(coords)
      [[0.5, 0.4, 0.3, 0.3]]
    >>> im, coords = obj_box_left_right_flip(im, coords=[[20, 40, 30, 30]], is_rescale=False, is_center=True, is_random=False)
    >>> print(coords)
      [[80, 40, 30, 30]]
    >>> im, coords = obj_box_left_right_flip(im, coords=[[20, 40, 30, 30]], is_rescale=False, is_center=False, is_random=False)
    >>> print(coords)
      [[50, 40, 30, 30]]