CPUImage

Inheritance diagram of CPUImage

CPUImage inheritance diagram

class savant.utils.image.CPUImage(image)
property np_array: ndarray

Returns numpy image.

Returns:

numpy image

to_gpu()

Returns GPU image.

Returns:

GPU image

Return type:

cv2.cuda.GpuMat

property height: int

Returns image height.

Returns:

image height

property width: int

Returns image width.

Returns:

image width

cut(bbox)

Cuts image by bbox and padding. :param bbox: cutout bbox :return:

paste(image, point)

Pastes image on current image.

Parameters:
concat(image, axis=0)

Concatenates images along axis.

Parameters:
  • image (CPUImage) – image to concatenate

  • axis (int) – axis to concatenate. 0 - is vertical, 1 - is horizontal

Returns:

concatenated image

Return type:

CPUImage

rotate(angle, bbox=None)

Rotates image on angle. If bbox is not None, image will be rotated around center point of image.

Parameters:
  • angle (float) – angle to rotate in degrees

  • bbox (Optional[RBBox]) – image will be rotated on bbox.angle if bbox is not None

Returns:

rotated image

Return type:

Tuple[CPUImage, RBBox]

resize(resolution, method='fit', interpolation=cv2.INTER_LINEAR)

Resizes image to resolution.

Parameters:
  • resolution (Tuple[int, int]) – resolution to resize [width, height]

  • method (str) – method to resize one of [‘fit’, ‘scale’]

  • interpolation (int) – interpolation method. Oone of [cv2.INTER_NEAREST, cv2.INTER_AREA, cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_LANCZOS4]

Returns:

resized image

Return type:

CPUImage