Skip to content

Commit be2cb8d

Browse files
Bug fixes of median filter test, replace .jpg to .png.
1 parent 5f01d59 commit be2cb8d

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

CMakeLists.txt

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
33
set(PROJECT_NAME practice2)
44
project(${PROJECT_NAME})
55

6-
option(WITH_CODE_COVERAGE "Enable code coverage analysis" OFF)
7-
86
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
97
if(NOT CMAKE_BUILD_TYPE)
108
set(CMAKE_BUILD_TYPE Release)
@@ -17,24 +15,14 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEAS
1715

1816
set(PRACTICE2_LIBRARY ${PROJECT_NAME})
1917
set(PRACTICE2_TESTS "${PROJECT_NAME}_test")
20-
21-
find_package(OpenCV REQUIRED)
22-
2318
set(PRACTICE2_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include")
19+
2420
include_directories("${PRACTICE2_INCLUDE}")
2521
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/3rdparty")
2622

23+
find_package(OpenCV REQUIRED)
2724
set(LIBRARY_DEPS ${OpenCV_LIBS})
2825

29-
if (WITH_CODE_COVERAGE)
30-
if (CMAKE_COMPILER_IS_GNUCXX)
31-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
32-
else()
33-
message(WARNING "Code coverage can be estimated only when g++ compiler is used. Code coverage analysis is disabled.")
34-
set(WITH_CODE_COVERAGE OFF)
35-
endif()
36-
endif()
37-
3826
# BUILD
3927
add_subdirectory(3rdparty)
4028
add_subdirectory(src)
@@ -48,5 +36,4 @@ message( STATUS "======================================")
4836
message( STATUS "")
4937
message( STATUS " Configuration: ${CMAKE_BUILD_TYPE}")
5038
message( STATUS " OpenCV build path: ${OpenCV_DIR}")
51-
message( STATUS " Enable code coverage: ${WITH_CODE_COVERAGE}")
5239
message( STATUS "")

src/img_proc.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ int processFrame(const Mat& src, Mat& dst)
1414
{
1515
const int kSize = 11;
1616
medianBlur(src, dst, kSize);
17+
if (dst.empty())
18+
{
19+
return 1;
20+
}
1721
return 0;
1822
}
1923

test/img_proc_test.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,26 @@
33

44
TEST(practice2, median_filter_test)
55
{
6-
std::string input = "./testdata/image.jpg";
7-
std::string expOutput = "./testdata/image_median_1.jpg";
6+
std::string input = "./testdata/image.png";
7+
std::string expOutput = "./testdata/image_median_11.png";
88

99
Mat src, expDst, dst;
1010
getFrame(input, src);
11+
if (src.empty())
12+
{
13+
FAIL() << "Can't read" + input + " image";
14+
}
1115
getFrame(expOutput, expDst);
1216
if (expDst.empty())
1317
{
1418
FAIL() << "Can't read" + expOutput + " image";
1519
}
1620

21+
if (processFrame(src, dst) != 0)
22+
{
23+
FAIL() << "Can't execute median filtering";
24+
}
25+
1726
Mat diff = abs(expDst - dst);
1827
Mat mask = diff.reshape(1) > 1;
1928

testdata/image.jpg

-76.9 KB
Binary file not shown.

testdata/image.png

446 KB
Loading

testdata/image_median_11.jpg

-31.2 KB
Binary file not shown.

testdata/image_median_11.png

340 KB
Loading

0 commit comments

Comments
 (0)