Skip to content

Commit 76053c8

Browse files
authored
OpenCV4 upgrade with CUDA (#89)
1 parent 3854132 commit 76053c8

19 files changed

Lines changed: 44 additions & 37 deletions

File tree

detection/api/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ project(openmpf-cpp-component-api)
3030

3131
set(CMAKE_CXX_STANDARD 11)
3232

33-
find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7
33+
find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0
3434
COMPONENTS opencv_core opencv_imgcodecs opencv_imgproc opencv_videoio)
3535

3636

detection/api/include/MPFDetectionComponent.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <map>
3333
#include <string>
3434
#include <vector>
35-
#include <opencv2/core.hpp>
3635

3736
#include "MPFComponentInterface.h"
3837
#include "MPFDetectionObjects.h"

detection/api/test/test_detection_api.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,14 @@ TEST(AffineFrameTransformerTest, RotateFullFrame) {
13071307
}
13081308

13091309

1310+
bool isSameImage(const cv::Mat &im1, const cv::Mat &im2) {
1311+
if (im1.size() != im2.size()) {
1312+
return false;
1313+
}
1314+
return std::equal(im1.begin<Pixel>(), im1.end<Pixel>(), im2.begin<Pixel>());
1315+
}
1316+
1317+
13101318
TEST(AffineFrameTransformerTest, TestRotationThreshold) {
13111319
const auto *test_img_path = "test/test_imgs/rotation/hello-world.png";
13121320
auto original_img = cv::imread(test_img_path);
@@ -1315,14 +1323,14 @@ TEST(AffineFrameTransformerTest, TestRotationThreshold) {
13151323
{ {"ROTATION", "10"}, {"ROTATION_THRESHOLD", "10.001"} }, {});
13161324

13171325
auto img = MPFImageReader(job).GetImage();
1318-
ASSERT_EQ(0, cv::countNonZero(img != original_img));
1326+
ASSERT_TRUE(isSameImage(original_img, img));
13191327
}
13201328
{
13211329
MPFImageJob job("test", test_img_path,
13221330
{ {"ROTATION", "10"}, {"ROTATION_THRESHOLD", "9.99"} }, {});
13231331

13241332
auto img = MPFImageReader(job).GetImage();
1325-
ASSERT_NE(original_img.size(), img.size());
1333+
ASSERT_FALSE(isSameImage(original_img, img));
13261334
}
13271335
}
13281336

@@ -1337,13 +1345,13 @@ TEST(AffineFrameTransformerTest, TestRotationThresholdWithFeedForward) {
13371345
MPFImageJob job("test", test_img_path, ff_img_loc,
13381346
{ {"ROTATION_THRESHOLD", "5.12"}, {"FEED_FORWARD_TYPE", "REGION"} }, {});
13391347
auto img = MPFImageReader(job).GetImage();
1340-
ASSERT_EQ(0, cv::countNonZero(img != original_img));
1348+
ASSERT_TRUE(isSameImage(original_img, img));
13411349
}
13421350
{
13431351
MPFImageJob job("test", test_img_path, ff_img_loc,
13441352
{ {"ROTATION_THRESHOLD", "5.00"}, {"FEED_FORWARD_TYPE", "REGION"} }, {});
13451353
auto img = MPFImageReader(job).GetImage();
1346-
ASSERT_NE(0, cv::countNonZero(img != original_img));
1354+
ASSERT_FALSE(isSameImage(original_img, img));
13471355
}
13481356
}
13491357

detection/examples/AudioOnlyComponent/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ include(../ComponentSetup.cmake)
3434

3535
find_package(mpfComponentInterface REQUIRED)
3636
find_package(mpfDetectionComponentApi REQUIRED)
37-
find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 COMPONENTS opencv_core)
37+
find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core)
3838

3939

4040
set(AUDIO_ONLY_COMPONENT_SOURCES AudioOnly.cpp AudioOnly.h)

detection/examples/AudioOnlyComponent/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# BUILD
22

3-
NOTE: To build and run this component, OpenCV 3.4.7
3+
NOTE: To build and run this component, OpenCV 4.5.0
44
must be installed first.
55

66
NOTE: You must build the MPF Component API library before
@@ -10,7 +10,7 @@ NOTE: You must build the MPF Component API library before
1010

1111
Before you build, edit the src/CMakeLists.txt file, and change
1212
the "find_package" command so that the PATHS option specifies
13-
the root directory of your OpenCV 3.4.7 installation.
13+
the root directory of your OpenCV 4.5.0 installation.
1414

1515
Run the following commands:
1616
```

detection/examples/GenericComponent/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ include(../ComponentSetup.cmake)
3434

3535
find_package(mpfComponentInterface REQUIRED)
3636
find_package(mpfDetectionComponentApi REQUIRED)
37-
find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 COMPONENTS opencv_core)
37+
find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core)
3838

3939

4040
set(GENERIC_COMPONENT_SOURCES GenericComponent.cpp GenericComponent.h)

detection/examples/GenericComponent/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# BUILD
22

3-
NOTE: To build and run this component, OpenCV 3.4.7
3+
NOTE: To build and run this component, OpenCV 4.5.0
44
must be installed first.
55

66
NOTE: You must build the MPF Component API library before
@@ -10,7 +10,7 @@ NOTE: You must build the MPF Component API library before
1010

1111
Before you build, edit the src/CMakeLists.txt file, and change
1212
the "find_package" command so that the PATHS option specifies
13-
the root directory of your OpenCV 3.4.7 installation.
13+
the root directory of your OpenCV 4.5.0 installation.
1414

1515
Run the following commands:
1616
```

detection/examples/HelloWorldComponent/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ include(../ComponentSetup.cmake)
3434

3535
find_package(mpfComponentInterface REQUIRED)
3636
find_package(mpfDetectionComponentApi REQUIRED)
37-
find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 COMPONENTS opencv_core)
37+
find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core)
3838
find_package(PkgConfig)
3939
pkg_search_module(LOG4CXX REQUIRED liblog4cxx)
4040

detection/examples/HelloWorldComponent/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# BUILD
22

3-
NOTE: To build and run this component, OpenCV 3.4.7
3+
NOTE: To build and run this component, OpenCV 4.5.0
44
must be installed first.
55

66
NOTE: You must build the MPF Component API library before
@@ -10,7 +10,7 @@ NOTE: You must build the MPF Component API library before
1010

1111
Before you build, edit the src/CMakeLists.txt file, and change
1212
the "find_package" command so that the PATHS option specifies
13-
the root directory of your OpenCV 3.4.7 installation.
13+
the root directory of your OpenCV 4.5.0 installation.
1414

1515
Run the following commands:
1616
```

detection/examples/ImageTransformerComponent/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ include(../ComponentSetup.cmake)
3434

3535
find_package(mpfComponentInterface REQUIRED)
3636
find_package(mpfDetectionComponentApi REQUIRED)
37-
find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 COMPONENTS opencv_core opencv_highgui)
37+
find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core opencv_highgui)
3838

3939

4040
set(IMAGE_TRANSFORMER_COMPONENT_SOURCES ImageTransformerComponent.h ImageTransformerComponent.cpp)

0 commit comments

Comments
 (0)