Skip to content

Commit 5004dc3

Browse files
authored
Update test_globalmatting.cpp
1 parent 0a7ca9e commit 5004dc3

File tree

1 file changed

+63
-63
lines changed

1 file changed

+63
-63
lines changed

modules/ximgproc/test/test_globalmatting.cpp

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,79 @@ using namespace cv;
66

77
namespace opencv_test
88
{
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";
1414

1515

16-
class CV_GlobalMattingTest
17-
{
18-
public:
19-
CV_GlobalMattingTest();
16+
class CV_GlobalMattingTest : public cvtest::BaseTest
17+
{
18+
public:
19+
CV_GlobalMattingTest();
2020

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();
2525

26-
};
26+
};
2727

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;
3333

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+
}
5757

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+
}
6565

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+
}
7474

7575

7676

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+
}
8282

83-
}
83+
}
8484
}

0 commit comments

Comments
 (0)