File: test_matrix_expr.cpp

package info (click to toggle)
opencv 4.10.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 282,092 kB
  • sloc: cpp: 1,178,079; xml: 682,621; python: 49,092; lisp: 31,150; java: 25,469; ansic: 11,039; javascript: 6,085; sh: 1,214; cs: 601; perl: 494; objc: 210; makefile: 173
file content (103 lines) | stat: -rw-r--r-- 2,711 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.

#include "../test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp"

#ifdef HAVE_OPENCL

namespace opencv_test {
namespace ocl {

//////////////////////////////// UMat Expressions /////////////////////////////////////////////////

PARAM_TEST_CASE(UMatExpr, MatDepth, Channels)
{
    int type;
    Size size;

    virtual void SetUp()
    {
        type = CV_MAKE_TYPE(GET_PARAM(0), GET_PARAM(1));
    }

    void generateTestData()
    {
        size = randomSize(1, MAX_VALUE);
    }
};

//////////////////////////////// UMat::eye /////////////////////////////////////////////////

OCL_TEST_P(UMatExpr, Eye)
{
    for (int j = 0; j < test_loop_times; j++)
    {
        generateTestData();

        Mat m = Mat::eye(size, type);
        UMat um = UMat::eye(size, type);

        EXPECT_MAT_NEAR(m, um, 0);
    }
}

//////////////////////////////// UMat::zeros /////////////////////////////////////////////////

OCL_TEST_P(UMatExpr, Zeros)
{
    for (int j = 0; j < test_loop_times; j++)
    {
        generateTestData();

        Mat m = Mat::zeros(size, type);
        UMat um = UMat::zeros(size, type);

        EXPECT_MAT_NEAR(m, um, 0);
    }
}

//////////////////////////////// UMat::ones /////////////////////////////////////////////////

OCL_TEST_P(UMatExpr, Ones)
{
    for (int j = 0; j < test_loop_times; j++)
    {
        generateTestData();

        Mat m = Mat::ones(size, type);
        UMat um = UMat::ones(size, type);

        EXPECT_MAT_NEAR(m, um, 0);
    }
}

//////////////////////////////// with usageFlags /////////////////////////////////////////////////

OCL_TEST_P(UMatExpr, WithUsageFlags)
{
    for (int j = 0; j < test_loop_times; j++)
    {
        generateTestData();

        UMat u0 = UMat::zeros(size, type, cv::USAGE_ALLOCATE_HOST_MEMORY);
        UMat u1 = UMat::ones(size, type, cv::USAGE_ALLOCATE_HOST_MEMORY);
        UMat u8 = UMat::eye(size, type, cv::USAGE_ALLOCATE_HOST_MEMORY);

        EXPECT_EQ(cv::USAGE_ALLOCATE_HOST_MEMORY, u0.usageFlags);
        EXPECT_EQ(cv::USAGE_ALLOCATE_HOST_MEMORY, u1.usageFlags);
        EXPECT_EQ(cv::USAGE_ALLOCATE_HOST_MEMORY, u8.usageFlags);
    }
}

//////////////////////////////// Instantiation /////////////////////////////////////////////////

OCL_INSTANTIATE_TEST_CASE_P(MatrixOperation, UMatExpr, Combine(OCL_ALL_DEPTHS_16F, OCL_ALL_CHANNELS));

} } // namespace opencv_test::ocl

#endif