|
| 1 | +from __future__ import absolute_import |
| 2 | +from ... import c_lib_wrap as C |
| 3 | + |
| 4 | + |
| 5 | +class Processor(): |
| 6 | + def __init__(self): |
| 7 | + self.processor |
| 8 | + |
| 9 | + def __call__(self, mat): |
| 10 | + self.processor(mat) |
| 11 | + |
| 12 | + |
| 13 | +class ResizeByShort(Processor): |
| 14 | + def __init__(self, target_size: int, interp=1, use_scale=True, max_hw=[]): |
| 15 | + self.processor = C.vision.processors.ResizeByShort(target_size, interp, |
| 16 | + use_scale, max_hw) |
| 17 | + """Create a ResizeByShort operation with the given parameters. |
| 18 | +
|
| 19 | + :param target_size: the target short size to resize the image |
| 20 | + :param interp: optionally, the interpolation mode for resizing image |
| 21 | + :param use_scale: optionally, whether to scale image |
| 22 | + :param max_hw: max spatial size which is used by ResizeByShort |
| 23 | + """ |
| 24 | + |
| 25 | + |
| 26 | +class CenterCrop(Processor): |
| 27 | + def __init__(self, width, height): |
| 28 | + self.processor = C.vision.processors.CenterCrop(width, height) |
| 29 | + """Create a CenterCrop operation with the given parameters. |
| 30 | +
|
| 31 | + :param width: desired width of the cropped image |
| 32 | + :param height: desired height of the cropped image |
| 33 | + """ |
| 34 | + |
| 35 | + |
| 36 | +class Pad(Processor): |
| 37 | + def __init__(self, top: int, bottom: int, left: int, right: int, value=[]): |
| 38 | + self.processor = C.vision.processors.Pad(top, bottom, left, right, |
| 39 | + value) |
| 40 | + """Create a Pad operation with the given parameters. |
| 41 | +
|
| 42 | + :param top: the top padding |
| 43 | + :param bottom: the bottom padding |
| 44 | + :param left: the left padding |
| 45 | + :param right: the right padding |
| 46 | + :param value: the value that is used to pad on the input image |
| 47 | + """ |
| 48 | + |
| 49 | + |
| 50 | +class NormalizeAndPermute(Processor): |
| 51 | + def __init__(self, |
| 52 | + mean=[], |
| 53 | + std=[], |
| 54 | + is_scale=True, |
| 55 | + min=[], |
| 56 | + max=[], |
| 57 | + swap_rb=False): |
| 58 | + self.processor = C.vision.processors.NormalizeAndPermute( |
| 59 | + mean, std, is_scale, min, max, swap_rb) |
| 60 | + """Creae a Normalize and a Permute operation with the given parameters. |
| 61 | +
|
| 62 | + :param mean A list containing the mean of each channel |
| 63 | + :param std A list containing the standard deviation of each channel |
| 64 | + :param is_scale Specifies if the image are being scaled or not |
| 65 | + :param min A list containing the minimum value of each channel |
| 66 | + :param max A list containing the maximum value of each channel |
| 67 | + """ |
0 commit comments