(x1, y1, x2, y2, height, width)
return x1, y1, x2, y2
Clip coordinates to an image with the given height and width.
Clip coordinates to an image with the given height and width.
Clip coordinates to an image with the given height and width .
def clip_xyxy_to_image(x1, y1, x2, y2, height, width):
    """Clip coordinates to an image with the given height and width."""
    x1 = np.minimum(width - 1., np.maximum(0., x1))
    y1 = np.minimum(height - 1., np.maximum(0., y1))
    x2 = np.minimum(width - 1., np.maximum(0., x2))
    y2 = np.minimum(height - 1., np.maximum(0., y2))
    return x1, y1, x2, y2
def clip_xyxy_to_image ( x1 , y1 , x2 , y2 , height , width ) : x1 = np . minimum ( width - 1. , np . maximum ( 0. , x1 ) ) y1 = np . minimum ( height - 1. , np . maximum ( 0. , y1 ) ) x2 = np . minimum ( width - 1. , np . maximum ( 0. , x2 ) ) y2 = np . minimum ( height - 1. , np . maximum ( 0. , y2 ) ) return x1 , y1 , x2 , y2