Exemplo n.º 1
0
    def test_reasonable_values(self):
        """Test using some reasonable values to reduce lines found"""
        # Given
        window = get_transform_window(transforms.HoughLinesP, IMG_PATH)
        gauss, canny, hough = window.transforms[1:4]

        # Set reasonable values for
        gauss.k_size_x = 9
        gauss.k_size_y = 9
        gauss.sigma_x = 2

        canny.threshold1 = 185
        canny.threshold2 = 120
        canny.aperture_size = 3
        canny.use_l2_gradient = True

        hough.rho = 159
        hough.theta = 1.38
        hough.threshold = 36
        hough.min_length = 160
        hough.max_gap = 59

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 2
0
    def test_defaults(self):
        """Test using the defaults for all transforms"""
        # Given
        window = get_transform_window(transforms.HoughCircles, IMG_PATH)

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 3
0
    def test_merge(self):
        """No parameters here"""
        # Given
        window = get_transform_window(transforms.Split, IMG_PATH)

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 4
0
    def test_various_values(self, value):
        # Given
        window = get_transform_window(transforms.MedianBlur, IMG_PATH)
        tf = window.transforms[1]
        tf.k_size = value

        # When
        window.draw(None, None)

        # Then
        assert tf.error is None
Exemplo n.º 5
0
    def test_kernel_values(self, value):
        # Given
        window = get_transform_window(transforms.Filter2D, IMG_PATH)
        tf = window.transforms[1]
        tf.kernel = value

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 6
0
    def test_kernel_sizes(self, rows, cols):
        # Given
        window = get_transform_window(transforms.Filter2D, IMG_PATH)
        tf = window.transforms[1]
        tf.kernel = np.ones((rows, cols))

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 7
0
def _test_single_attr(transform, attr, value, tf_num=1):
    """Tests setting single attribute and running pipeline"""
    # Given
    window = get_transform_window(transform, IMG_PATH)
    tf = window.transforms[tf_num]
    setattr(tf, attr, value)

    # When
    window.draw(None, None)

    # Then
    _check_error(window)
Exemplo n.º 8
0
    def test_anchors(self, row, col):
        # Given
        window = get_transform_window(transforms.Filter2D, IMG_PATH)
        tf = window.transforms[1]
        tf.kernel = np.ones((3, 3))
        tf._kernel.anchor = (row, col)

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 9
0
    def test_l2(self, alpha):
        # Given
        window = get_transform_window(transforms.Normalize, IMG_PATH)
        tf = window.transforms[1]
        tf.alpha = alpha
        tf.norm_type = cvc.NORMS['NORM_L2']

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 10
0
    def test_other_params(self, n_images):
        """Test Other params"""
        # Given
        window = get_transform_window(transforms.PyrDown, IMG_PATH)
        tf = window.transforms[1]
        tf.n_images = n_images

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 11
0
    def test_border_types(self, border_type):
        """Test the different border options"""
        # Given
        window = get_transform_window(transforms.Sobel, IMG_PATH)
        tf = window.transforms[1]
        tf.border_type = cvc.BORDERS[border_type]

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 12
0
    def test_border_types(self, border_type):
        """Test the different border options"""
        # Given
        window = get_transform_window(transforms.Dilate, IMG_PATH)
        tf = window.transforms[1]
        tf.iterations = 5
        tf.border_type = cvc.BORDERS[border_type]
        tf.border_val = (255, 255, 255)
        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 13
0
    def test_method_options(self, method):
        """Test method options"""
        window = get_transform_window(transforms.FindContours, IMG_PATH)
        tf = window.transforms[1]
        tf.method = cvc.CHAIN_APPROX[method]
        draw_cont = window.transforms[2]
        draw_cont.enabled = False

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 14
0
    def test_mode_options(self, mode):
        """Test Mode options"""
        window = get_transform_window(transforms.FindContours, IMG_PATH)
        tf = window.transforms[1]
        tf.mode = cvc.RETR[mode]
        draw_cont = window.transforms[2]
        draw_cont.enabled = False

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 15
0
    def test_other_params(self, scale_x, scale_y):
        """Test Other params"""
        # Given
        window = get_transform_window(transforms.Resize, IMG_PATH)
        tf = window.transforms[1]
        tf.scale_x = scale_x
        tf.scale_y = scale_y

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 16
0
    def test_other_params(self, kernel, normalize):
        """Test other param combinations"""
        # Given
        window = get_transform_window(transforms.BoxFilter, IMG_PATH)
        tf = window.transforms[1]
        tf.kernel = kernel
        tf.normalize = normalize

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 17
0
    def test_other_params(self, r, theta):
        """Test other param combinations"""
        # Given
        window = get_transform_window(transforms.Remap, IMG_PATH)
        tf = window.transforms[1]
        tf.r = r
        tf.theta = theta

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 18
0
    def test_other_params(self, alpha, beta, gamma):
        """Test Other params"""
        # Given
        window = get_transform_window(transforms.AddWeighted, IMG_PATH)
        tf = window.transforms[1]
        tf.alpha = alpha
        tf.beta = beta
        tf.gamma = gamma

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 19
0
    def test_min_and_middle_val(self, value):
        # Given
        window = get_transform_window(transforms.CopyMakeBorder, IMG_PATH)
        tf = window.transforms[1]
        tf.top = value
        tf.right = value
        tf.bottom = value
        tf.left = value

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 20
0
    def test_other_params(self, ch1, ch2, ch3):
        """Test other param combinations"""
        # Given
        window = get_transform_window(transforms.InRangeRaw, IMG_PATH)
        tf = window.transforms[1]
        tf.ch1['top'], tf.ch1['bot'] = ch1
        tf.ch2['top'], tf.ch2['bot'] = ch2
        tf.ch3['top'], tf.ch3['bot'] = ch3

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 21
0
    def test_canny(self, thresh1, thresh2, aperture, l2_grad):
        # Given
        window = get_transform_window(transforms.Canny, IMG_PATH)
        tf = window.transforms[1]
        tf.threshold1 = thresh1
        tf.threshold2 = thresh2
        tf.aperture_size = aperture
        tf.use_l2_gradient = l2_grad

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 22
0
    def test_other_params(self, kernel_x, kernel_y, delta):
        """Test other param combinations"""
        # Given
        window = get_transform_window(transforms.SepFilter2D, IMG_PATH)
        tf = window.transforms[1]
        tf.kernel_X = kernel_x
        tf.kernel_Y = kernel_y
        tf.delta = delta

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 23
0
    def test_other_params(self, kernel, anchor, iterations):
        """Test combinations of the other params"""
        # Given
        window = get_transform_window(transforms.Dilate, IMG_PATH)
        tf = window.transforms[1]
        tf.iterations = iterations
        tf.kernel = kernel
        tf._kernel.anchor = anchor

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 24
0
    def test_other_params(self, thresh):
        """Test Other params"""
        # Given
        window = get_transform_window(transforms.FindContours, IMG_PATH)
        tf = window.transforms[1]
        tf.threshold = thresh
        draw_cont = window.transforms[2]
        draw_cont.enabled = False

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 25
0
    def test_other_params(self, diameter, sigma_c, sigma_s):
        """Test combinations of the other params"""
        # Given
        window = get_transform_window(transforms.BilateralFilter, IMG_PATH)
        tf = window.transforms[1]
        tf.d = diameter
        tf.sigma_color = sigma_c
        tf.sigma_space = sigma_s

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 26
0
    def test_other_params(self, criteria, win_rows, win_cols, eps, max_iter):
        """Test Other params"""
        # Given
        window = get_transform_window(transforms.CornerSubPix, IMG_PATH)
        tf = window.transforms[2]
        tf.criteria = cvc.TERM[criteria]
        tf.window_size_rows = win_rows
        tf.window_size_cols = win_cols
        tf.epsilon = eps
        tf.max_iter = max_iter

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 27
0
    def test_other_params(self, criteria, k, epsilon, max_iter, attempts):
        """Test Other params"""
        # Given
        window = get_transform_window(transforms.Kmeans, IMG_PATH)
        tf = window.transforms[1]
        tf.criteria = cvc.TERM[criteria]
        tf.k = k
        tf.epsilon = epsilon
        tf.max_iter = max_iter
        tf.attempts = attempts

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 28
0
    def test_other_params(self, temp_win_size, search_win_size, h, h_color):
        """Test other param combinations"""
        # Given
        window = get_transform_window(transforms.FastNIMeansDenoisingColored,
                                      IMG_PATH)
        tf = window.transforms[1]
        tf.template_window_size = temp_win_size
        tf.search_window_size = search_win_size
        tf.h = h
        tf.h_color = h_color

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 29
0
    def test_other_params(self, k_size, sigma):
        """Test Other params"""
        # Given
        window = get_transform_window(transforms.GetGaussianKernel, IMG_PATH)
        # Drop the display transform - window isn't set on pipeline
        # pipeline usually does that setup and we're not using it
        window.transforms.pop()
        tf = window.transforms[1]
        tf.k_size = k_size
        tf.sigma = sigma

        # When
        window.draw(None, None)

        # Then
        _check_error(window)
Exemplo n.º 30
0
    def test_other_params(self, dx, dy, k_size, scale, delta):
        """Test other param combinations"""
        # Given
        window = get_transform_window(transforms.Sobel, IMG_PATH)
        tf = window.transforms[1]
        tf.dx = dx
        tf.dy = dy
        tf.k_size = k_size
        tf.scale = scale
        tf.delta = delta

        # When
        window.draw(None, None)

        # Then
        _check_error(window)