Image process

The concept of this module is based on being able to apply different effects to input images using a common class and if necessary stack one effect on top of another to that image.

The epicenter of this module

class py2vision.image_process.frame_decorator.Frame(input_image)[source]

The base Component interface defines operations that can be altered by decorators.

img

an image array

apply()[source]

To get input image

class py2vision.image_process.frame_decorator.FrameDecorator(frame: py2vision.image_process.frame_decorator.Frame)[source]
apply(input_image)[source]

To get input image

frame

The Decorator delegates all work to the wrapped component.

Image transformations

class py2vision.image_process.resize_with_bbox.ResizeWithBBox(frame: py2vision.image_process.frame_decorator.Frame)[source]
apply(target_size, gt_boxes=None)[source]

Apply resizing on an image and their bounding boxes.

Parameters:
  • target_size – a tuple or list with the new dimensions of an image.
  • gt_boxes – bounding boxes.
Returns:

a resized image and their reescaling bounding boxes.

class py2vision.image_process.resize.Resize(frame: py2vision.image_process.frame_decorator.Frame)[source]
apply(width, height)[source]

Apply resizing on an image.

Parameters:
  • width – new width to the image.
  • height – new height to the image.
Returns:

an image resized.

class py2vision.image_process.rotate.Rotate(frame: py2vision.image_process.frame_decorator.Frame)[source]

Concrete Decorators call the wrapped object and alter its result in some way.

apply(angle)[source]

Apply rotation on an image.

Parameters:angle – an integer that represents rotation angle.
Returns:an image rotated.
class py2vision.image_process.split_pair.SplitPair(frame: py2vision.image_process.frame_decorator.Frame)[source]

Concrete Decorators call the wrapped object and alter its result in some way.

apply(mode='sbs')[source]

Apply split in an image pair from stereo cameras.

Parameters:mode – if it is “sbs” (side-by-side) it will do a vertical slice, if it is “tb” (top-bottom) it will do a a horizontal slice.
Returns:left image and right image.

How to use?

1
2
3
4
5
6
7
8
from py2vision.image_process.frame_decorator import Frame
from py2vision.image_process.resize import Resize

width = 640
height = 720
img = cv.imread("AN_IMAGE_PATH")
frame = Frame(img)
frame_transformed = Resize(frame).apply(width, height)