Пример #1
0
 def __init__(self, ksize: int):
     """
     creates a pipeline that blurs the given frame using the median blur method
     works very good for denoising purposes
     :param ksize: the size of the kernel used by the filter, must be an odd number
     :return: a pipeline that filters the image using the median blur method
     """
     PipeLine.__init__(self, lambda frame: cv2.medianBlur(frame, ksize))
Пример #2
0
 def __init__(self, ksize, iterations=1):
     """
     creates a pipeline that erodes the image by a kernel of ones
     used mainly for Erode & Dilate denoise filters
     :param ksize: the kernel size, either an integer (meaning an nxn kernel) or a tuple (nxm kernel)
     :param iterations: optional, the amount of Erode iterations to perform, default is 1
     None! a large number of iterations will slow down the program
     :return: a pipeline that erodes the given frame
     """
     if type(ksize) is int:
         ksize = (ksize, ksize)
     PipeLine.__init__(
         self, lambda frame: cv2.erode(
             frame, np.ones(ksize), iterations=iterations))
Пример #3
0
    def __init__(self, collision_func: Callable[[Shape, Shape], bool]):
        def _filter(shapes: List[Shape]) -> List[Shape]:
            filtered_shapes = []
            for i, shape in enumerate(shapes):
                shape_invalid = False
                for j in range(i):
                    shape_invalid = collision_func(shape, shapes[j])
                    if shape_invalid:
                        break
                if not shape_invalid:
                    filtered_shapes.append(shape)
            return filtered_shapes

        PipeLine.__init__(self, _filter)
Пример #4
0
    def __init__(self, finding_func, color, drawing_func, *args, **kwargs):
        def _draw(frame):
            return drawing_func(frame, finding_func(frame), color, *args,
                                **kwargs)

        PipeLine.__init__(self, _draw)
Пример #5
0
 def __init__(self, ksize: Union[int, Tuple[int, int]], iterations=1):
     PipeLine.__init__(self)
     self.functions += (Erode(ksize, iterations) +
                        Dilate(ksize, iterations)).functions
Пример #6
0
 def __init__(self, min_area: float):
     PipeLine.__init__(self, lambda cnts: filter(lambda c: cv2.contourArea(c) >= min_area, cnts), list)
 def __init__(self, min_distance_ratio: float):
     PipeLine.__init__(self)
     from gbvision.models.basic_ops import normalized_distance_transform
     self.functions += (normalized_distance_transform + ColorThreshold([[min_distance_ratio, 1.0]],
                                                                       ColorThreshold.THRESH_TYPE_GRAY)).functions
Пример #8
0
 def __init__(self, ksize: int):
     PipeLine.__init__(self, lambda frame: cv2.medianBlur(frame, ksize))
Пример #9
0
 def __init__(self, ksize: Union[int, Tuple[int, int]], iterations=1):
     if type(ksize) is int:
         ksize = (ksize, ksize)
     PipeLine.__init__(
         self, lambda frame: cv2.dilate(
             frame, np.ones(ksize), iterations=iterations))