@@ -6,79 +6,79 @@ using namespace cv;
6
6
7
7
namespace opencv_test
8
8
{
9
- namespace
10
- {
11
- const std::string INPUT_DIR = " cv/ximgproc" ;
12
- const std::string IMAGE_FILENAME = " input/doll.png" ;
13
- const std::string TRIMAP_FILENAME = " trimap/doll.png" ;
9
+ namespace
10
+ {
11
+ const std::string INPUT_DIR = " cv/ximgproc" ;
12
+ const std::string IMAGE_FILENAME = " input/doll.png" ;
13
+ const std::string TRIMAP_FILENAME = " trimap/doll.png" ;
14
14
15
15
16
- class CV_GlobalMattingTest
17
- {
18
- public:
19
- CV_GlobalMattingTest ();
16
+ class CV_GlobalMattingTest : public cvtest ::BaseTest
17
+ {
18
+ public:
19
+ CV_GlobalMattingTest ();
20
20
21
- protected:
22
- Ptr<GlobalMatting> gm;
23
- virtual void run (int );
24
- void runModel ();
21
+ protected:
22
+ Ptr<GlobalMatting> gm;
23
+ virtual void run (int );
24
+ void runModel ();
25
25
26
- };
26
+ };
27
27
28
- void CV_GlobalMattingTest::runModel ()
29
- {
30
- std::string folder = std::string (cvtest::TS::ptr ()->get_data_path ());
31
- std::string img_path = folder + INPUT_DIR + " /" + IMAGE_FILENAME;
32
- std::string trimap_path = folder + INPUT_DIR + " /" + TRIMAP_FILENAME;
28
+ void CV_GlobalMattingTest::runModel ()
29
+ {
30
+ std::string folder = std::string (cvtest::TS::ptr ()->get_data_path ());
31
+ std::string img_path = folder + INPUT_DIR + " /" + IMAGE_FILENAME;
32
+ std::string trimap_path = folder + INPUT_DIR + " /" + TRIMAP_FILENAME;
33
33
34
- Mat img = cv::imread (img_path,cv::IMREAD_COLOR);
35
- Mat trimap = cv::imread (trimap_path,cv::IMREAD_GRAYSCALE);
36
- if (img.empty () || trimap.empty ())
37
- {
38
- ts->printf (cvtest::TS::LOG," Test images not found!\n " );
39
- ts->set_failed_test_info (cvtest::TS::FAIL_INVALID_TEST_DATA);
40
- return ;
41
- }
42
- if (img.cols !=trimap.cols || img.rows !=trimap.rows )
43
- {
44
- ts->printf (cvtest::TS::LOG," Dimensions of trimap and the image are not the same" );
45
- ts->set_failed_test_info (cvtest::TS::FAIL_INVALID_TEST_DATA);
46
- return ;
47
- }
48
- Mat foreground,alpha;
49
- int niter = 9 ;
50
- this ->gm ->getMat (img,trimap,foreground,alpha,niter);
51
- if (alpha.empty ())
52
- {
53
- ts->printf (cvtest::TS::LOG," Could not find the alpha matte for the image\n " );
54
- ts->set_failed_test_info (cvtest::TS::FAIL_BAD_ACCURACY);
55
- return ;
56
- }
34
+ Mat img = cv::imread (img_path,cv::IMREAD_COLOR);
35
+ Mat trimap = cv::imread (trimap_path,cv::IMREAD_GRAYSCALE);
36
+ if (img.empty () || trimap.empty ())
37
+ {
38
+ ts->printf (cvtest::TS::LOG," Test images not found!\n " );
39
+ ts->set_failed_test_info (cvtest::TS::FAIL_INVALID_TEST_DATA);
40
+ return ;
41
+ }
42
+ if (img.cols !=trimap.cols || img.rows !=trimap.rows )
43
+ {
44
+ ts->printf (cvtest::TS::LOG," Dimensions of trimap and the image are not the same" );
45
+ ts->set_failed_test_info (cvtest::TS::FAIL_INVALID_TEST_DATA);
46
+ return ;
47
+ }
48
+ Mat foreground,alpha;
49
+ int niter = 9 ;
50
+ this ->gm ->getMat (img,trimap,foreground,alpha,niter);
51
+ if (alpha.empty ())
52
+ {
53
+ ts->printf (cvtest::TS::LOG," Could not find the alpha matte for the image\n " );
54
+ ts->set_failed_test_info (cvtest::TS::FAIL_BAD_ACCURACY);
55
+ return ;
56
+ }
57
57
58
- if (alpha.cols !=img.cols || alpha.rows !=img.rows )
59
- {
60
- ts->printf (cvtest::TS::LOG," The dimensions of the output are not correct" );
61
- ts->set_failed_test_info (cvtest::TS::FAIL_BAD_ACCURACY);
62
- return ;
63
- }
64
- }
58
+ if (alpha.cols !=img.cols || alpha.rows !=img.rows )
59
+ {
60
+ ts->printf (cvtest::TS::LOG," The dimensions of the output are not correct" );
61
+ ts->set_failed_test_info (cvtest::TS::FAIL_BAD_ACCURACY);
62
+ return ;
63
+ }
64
+ }
65
65
66
- CV_GlobalMattingTest::CV_GlobalMattingTest ()
67
- {
68
- gm = makePtr<GlobalMatting>();
69
- }
70
- void CV_GlobalMattingTest::run (int )
71
- {
72
- runModel ();
73
- }
66
+ CV_GlobalMattingTest::CV_GlobalMattingTest ()
67
+ {
68
+ gm = makePtr<GlobalMatting>();
69
+ }
70
+ void CV_GlobalMattingTest::run (int )
71
+ {
72
+ runModel ();
73
+ }
74
74
75
75
76
76
77
- TEST (CV_GlobalMattingTest,accuracy)
78
- {
79
- CV_GlobalMattingTest test;
80
- test.safe_run ();
81
- }
77
+ TEST (CV_GlobalMattingTest,accuracy)
78
+ {
79
+ CV_GlobalMattingTest test;
80
+ test.safe_run ();
81
+ }
82
82
83
- }
83
+ }
84
84
}
0 commit comments