diff --git a/detection/api/CMakeLists.txt b/detection/api/CMakeLists.txt index 19f2cfb..a4ad6cc 100644 --- a/detection/api/CMakeLists.txt +++ b/detection/api/CMakeLists.txt @@ -30,7 +30,7 @@ project(openmpf-cpp-component-api) set(CMAKE_CXX_STANDARD 11) -find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 +find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core opencv_imgcodecs opencv_imgproc opencv_videoio) diff --git a/detection/api/include/MPFDetectionComponent.h b/detection/api/include/MPFDetectionComponent.h index a96fd35..8b5d3f0 100644 --- a/detection/api/include/MPFDetectionComponent.h +++ b/detection/api/include/MPFDetectionComponent.h @@ -32,7 +32,6 @@ #include #include #include -#include #include "MPFComponentInterface.h" #include "MPFDetectionObjects.h" diff --git a/detection/api/test/test_detection_api.cpp b/detection/api/test/test_detection_api.cpp index b3a9be2..876775b 100644 --- a/detection/api/test/test_detection_api.cpp +++ b/detection/api/test/test_detection_api.cpp @@ -1307,6 +1307,14 @@ TEST(AffineFrameTransformerTest, RotateFullFrame) { } +bool isSameImage(const cv::Mat &im1, const cv::Mat &im2) { + if (im1.size() != im2.size()) { + return false; + } + return std::equal(im1.begin(), im1.end(), im2.begin()); +} + + TEST(AffineFrameTransformerTest, TestRotationThreshold) { const auto *test_img_path = "test/test_imgs/rotation/hello-world.png"; auto original_img = cv::imread(test_img_path); @@ -1315,14 +1323,14 @@ TEST(AffineFrameTransformerTest, TestRotationThreshold) { { {"ROTATION", "10"}, {"ROTATION_THRESHOLD", "10.001"} }, {}); auto img = MPFImageReader(job).GetImage(); - ASSERT_EQ(0, cv::countNonZero(img != original_img)); + ASSERT_TRUE(isSameImage(original_img, img)); } { MPFImageJob job("test", test_img_path, { {"ROTATION", "10"}, {"ROTATION_THRESHOLD", "9.99"} }, {}); auto img = MPFImageReader(job).GetImage(); - ASSERT_NE(original_img.size(), img.size()); + ASSERT_FALSE(isSameImage(original_img, img)); } } @@ -1337,13 +1345,13 @@ TEST(AffineFrameTransformerTest, TestRotationThresholdWithFeedForward) { MPFImageJob job("test", test_img_path, ff_img_loc, { {"ROTATION_THRESHOLD", "5.12"}, {"FEED_FORWARD_TYPE", "REGION"} }, {}); auto img = MPFImageReader(job).GetImage(); - ASSERT_EQ(0, cv::countNonZero(img != original_img)); + ASSERT_TRUE(isSameImage(original_img, img)); } { MPFImageJob job("test", test_img_path, ff_img_loc, { {"ROTATION_THRESHOLD", "5.00"}, {"FEED_FORWARD_TYPE", "REGION"} }, {}); auto img = MPFImageReader(job).GetImage(); - ASSERT_NE(0, cv::countNonZero(img != original_img)); + ASSERT_FALSE(isSameImage(original_img, img)); } } diff --git a/detection/examples/AudioOnlyComponent/CMakeLists.txt b/detection/examples/AudioOnlyComponent/CMakeLists.txt index ef6e8bc..d55cadc 100644 --- a/detection/examples/AudioOnlyComponent/CMakeLists.txt +++ b/detection/examples/AudioOnlyComponent/CMakeLists.txt @@ -34,7 +34,7 @@ include(../ComponentSetup.cmake) find_package(mpfComponentInterface REQUIRED) find_package(mpfDetectionComponentApi REQUIRED) -find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 COMPONENTS opencv_core) +find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core) set(AUDIO_ONLY_COMPONENT_SOURCES AudioOnly.cpp AudioOnly.h) diff --git a/detection/examples/AudioOnlyComponent/README.md b/detection/examples/AudioOnlyComponent/README.md index d7ee08f..f03de8e 100644 --- a/detection/examples/AudioOnlyComponent/README.md +++ b/detection/examples/AudioOnlyComponent/README.md @@ -1,6 +1,6 @@ # BUILD -NOTE: To build and run this component, OpenCV 3.4.7 +NOTE: To build and run this component, OpenCV 4.5.0 must be installed first. NOTE: You must build the MPF Component API library before @@ -10,7 +10,7 @@ NOTE: You must build the MPF Component API library before Before you build, edit the src/CMakeLists.txt file, and change the "find_package" command so that the PATHS option specifies -the root directory of your OpenCV 3.4.7 installation. +the root directory of your OpenCV 4.5.0 installation. Run the following commands: ``` diff --git a/detection/examples/AudioOnlyComponent/plugin-files/descriptor/descriptor.json b/detection/examples/AudioOnlyComponent/plugin-files/descriptor/descriptor.json index 82ff876..b793b74 100644 --- a/detection/examples/AudioOnlyComponent/plugin-files/descriptor/descriptor.json +++ b/detection/examples/AudioOnlyComponent/plugin-files/descriptor/descriptor.json @@ -1,7 +1,7 @@ { "componentName": "AudioOnlyComponent", - "componentVersion": "5.1", - "middlewareVersion": "5.1", + "componentVersion": "6.0", + "middlewareVersion": "6.0", "sourceLanguage": "c++", "batchLibrary": "${MPF_HOME}/plugins/AudioOnlyComponent/lib/libmpfAudioOnly.so", "environmentVariables": [ diff --git a/detection/examples/GenericComponent/CMakeLists.txt b/detection/examples/GenericComponent/CMakeLists.txt index e87cbf7..632606c 100644 --- a/detection/examples/GenericComponent/CMakeLists.txt +++ b/detection/examples/GenericComponent/CMakeLists.txt @@ -34,7 +34,7 @@ include(../ComponentSetup.cmake) find_package(mpfComponentInterface REQUIRED) find_package(mpfDetectionComponentApi REQUIRED) -find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 COMPONENTS opencv_core) +find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core) set(GENERIC_COMPONENT_SOURCES GenericComponent.cpp GenericComponent.h) diff --git a/detection/examples/GenericComponent/README.md b/detection/examples/GenericComponent/README.md index 36a5e31..8db22b5 100644 --- a/detection/examples/GenericComponent/README.md +++ b/detection/examples/GenericComponent/README.md @@ -1,6 +1,6 @@ # BUILD -NOTE: To build and run this component, OpenCV 3.4.7 +NOTE: To build and run this component, OpenCV 4.5.0 must be installed first. NOTE: You must build the MPF Component API library before @@ -10,7 +10,7 @@ NOTE: You must build the MPF Component API library before Before you build, edit the src/CMakeLists.txt file, and change the "find_package" command so that the PATHS option specifies -the root directory of your OpenCV 3.4.7 installation. +the root directory of your OpenCV 4.5.0 installation. Run the following commands: ``` diff --git a/detection/examples/GenericComponent/plugin-files/descriptor/descriptor.json b/detection/examples/GenericComponent/plugin-files/descriptor/descriptor.json index e6eda26..ceab67d 100644 --- a/detection/examples/GenericComponent/plugin-files/descriptor/descriptor.json +++ b/detection/examples/GenericComponent/plugin-files/descriptor/descriptor.json @@ -1,7 +1,7 @@ { "componentName": "GenericComponent", - "componentVersion": "5.1", - "middlewareVersion": "5.1", + "componentVersion": "6.0", + "middlewareVersion": "6.0", "sourceLanguage": "c++", "batchLibrary": "${MPF_HOME}/plugins/GenericComponent/lib/libmpfGeneric.so", "environmentVariables": [ diff --git a/detection/examples/HelloWorldComponent/CMakeLists.txt b/detection/examples/HelloWorldComponent/CMakeLists.txt index 75bfa00..6a2bb70 100644 --- a/detection/examples/HelloWorldComponent/CMakeLists.txt +++ b/detection/examples/HelloWorldComponent/CMakeLists.txt @@ -34,7 +34,7 @@ include(../ComponentSetup.cmake) find_package(mpfComponentInterface REQUIRED) find_package(mpfDetectionComponentApi REQUIRED) -find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 COMPONENTS opencv_core) +find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core) find_package(PkgConfig) pkg_search_module(LOG4CXX REQUIRED liblog4cxx) diff --git a/detection/examples/HelloWorldComponent/README.md b/detection/examples/HelloWorldComponent/README.md index 6edcdc4..e038a53 100644 --- a/detection/examples/HelloWorldComponent/README.md +++ b/detection/examples/HelloWorldComponent/README.md @@ -1,6 +1,6 @@ # BUILD -NOTE: To build and run this component, OpenCV 3.4.7 +NOTE: To build and run this component, OpenCV 4.5.0 must be installed first. NOTE: You must build the MPF Component API library before @@ -10,7 +10,7 @@ NOTE: You must build the MPF Component API library before Before you build, edit the src/CMakeLists.txt file, and change the "find_package" command so that the PATHS option specifies -the root directory of your OpenCV 3.4.7 installation. +the root directory of your OpenCV 4.5.0 installation. Run the following commands: ``` diff --git a/detection/examples/HelloWorldComponent/plugin-files/descriptor/descriptor.json b/detection/examples/HelloWorldComponent/plugin-files/descriptor/descriptor.json index 457a74f..7adbea5 100644 --- a/detection/examples/HelloWorldComponent/plugin-files/descriptor/descriptor.json +++ b/detection/examples/HelloWorldComponent/plugin-files/descriptor/descriptor.json @@ -1,7 +1,7 @@ { "componentName": "HelloWorldComponent", - "componentVersion": "5.1", - "middlewareVersion": "5.1", + "componentVersion": "6.0", + "middlewareVersion": "6.0", "sourceLanguage": "c++", "batchLibrary": "${MPF_HOME}/plugins/HelloWorldComponent/lib/libmpfHelloWorld.so", "streamLibrary": "${MPF_HOME}/plugins/HelloWorldComponent/lib/libmpfStreamingHelloWorld.so", diff --git a/detection/examples/ImageTransformerComponent/CMakeLists.txt b/detection/examples/ImageTransformerComponent/CMakeLists.txt index b1d4454..59a0725 100644 --- a/detection/examples/ImageTransformerComponent/CMakeLists.txt +++ b/detection/examples/ImageTransformerComponent/CMakeLists.txt @@ -34,7 +34,7 @@ include(../ComponentSetup.cmake) find_package(mpfComponentInterface REQUIRED) find_package(mpfDetectionComponentApi REQUIRED) -find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 COMPONENTS opencv_core opencv_highgui) +find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core opencv_highgui) set(IMAGE_TRANSFORMER_COMPONENT_SOURCES ImageTransformerComponent.h ImageTransformerComponent.cpp) diff --git a/detection/examples/ImageTransformerComponent/ImageTransformerComponent.cpp b/detection/examples/ImageTransformerComponent/ImageTransformerComponent.cpp index c5a49bf..acc70bd 100644 --- a/detection/examples/ImageTransformerComponent/ImageTransformerComponent.cpp +++ b/detection/examples/ImageTransformerComponent/ImageTransformerComponent.cpp @@ -73,7 +73,7 @@ std::vector ImageTransformerComponent::GetDetections(const MPF std::cout << "original image rows = " << original.rows << std::endl; std::cout << "original image cols = " << original.cols << std::endl; std::cout << std::endl << std::endl; - cv::namedWindow("Original", CV_WINDOW_AUTOSIZE); + cv::namedWindow("Original", cv::WINDOW_AUTOSIZE); cv::imshow("Original", original); cv::waitKey(500); @@ -101,7 +101,7 @@ std::vector ImageTransformerComponent::GetDetections(const MPF // Again, for illustration purposes only, we display the image after // the transformation has been applied. - cv::namedWindow("Transformed", CV_WINDOW_AUTOSIZE); + cv::namedWindow("Transformed", cv::WINDOW_AUTOSIZE); cv::imshow("Transformed", image_data); cv::waitKey(0); diff --git a/detection/examples/ImageTransformerComponent/README.md b/detection/examples/ImageTransformerComponent/README.md index 9edbe5a..a8391d3 100644 --- a/detection/examples/ImageTransformerComponent/README.md +++ b/detection/examples/ImageTransformerComponent/README.md @@ -1,6 +1,6 @@ # BUILD -NOTE: To build and run this component, OpenCV 3.4.7 +NOTE: To build and run this component, OpenCV 4.5.0 must be installed first. NOTE: You must build the MPF Component API library before @@ -10,7 +10,7 @@ NOTE: You must build the MPF Component API library before Before you build, edit the src/CMakeLists.txt file, and change the "find_package" command so that the PATHS option specifies -the root directory of your OpenCV 3.4.7 installation. +the root directory of your OpenCV 4.5.0 installation. Run the following commands: ``` diff --git a/detection/examples/ImageTransformerComponent/plugin-files/descriptor/descriptor.json b/detection/examples/ImageTransformerComponent/plugin-files/descriptor/descriptor.json index 050b239..ebc5ae6 100644 --- a/detection/examples/ImageTransformerComponent/plugin-files/descriptor/descriptor.json +++ b/detection/examples/ImageTransformerComponent/plugin-files/descriptor/descriptor.json @@ -1,7 +1,7 @@ { "componentName": "ImageTransformerComponent", - "componentVersion": "5.1", - "middlewareVersion": "5.1", + "componentVersion": "6.0", + "middlewareVersion": "6.0", "sourceLanguage": "c++", "batchLibrary": "${MPF_HOME}/plugins/ImageTransformerComponent/lib/libmpfImageTransformer.so", "environmentVariables": [ diff --git a/detection/examples/VideoCaptureComponent/CMakeLists.txt b/detection/examples/VideoCaptureComponent/CMakeLists.txt index 9d53927..af14f1f 100644 --- a/detection/examples/VideoCaptureComponent/CMakeLists.txt +++ b/detection/examples/VideoCaptureComponent/CMakeLists.txt @@ -34,7 +34,7 @@ include(../ComponentSetup.cmake) find_package(mpfComponentInterface REQUIRED) find_package(mpfDetectionComponentApi REQUIRED) -find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 COMPONENTS opencv_core opencv_highgui) +find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core opencv_highgui) set(VIDEO_CAPTURE_COMPONENT_SOURCES VideoCaptureComponent.h VideoCaptureComponent.cpp) diff --git a/detection/examples/VideoCaptureComponent/README.md b/detection/examples/VideoCaptureComponent/README.md index 3498a1f..bb1e303 100644 --- a/detection/examples/VideoCaptureComponent/README.md +++ b/detection/examples/VideoCaptureComponent/README.md @@ -1,6 +1,6 @@ # BUILD -NOTE: To build and run this component, OpenCV 3.4.7 and +NOTE: To build and run this component, OpenCV 4.5.0 and ffmpeg must be installed first. NOTE: You must build the MPF Component API library before @@ -10,7 +10,7 @@ NOTE: You must build the MPF Component API library before Before you build, edit the src/CMakeLists.txt file, and change the "find_package" command so that the PATHS option specifies -the root directory of your OpenCV 3.4.7 installation. +the root directory of your OpenCV 4.5.0 installation. Run the following commands: ``` diff --git a/detection/examples/VideoCaptureComponent/plugin-files/descriptor/descriptor.json b/detection/examples/VideoCaptureComponent/plugin-files/descriptor/descriptor.json index 1e0ea96..e4036a6 100644 --- a/detection/examples/VideoCaptureComponent/plugin-files/descriptor/descriptor.json +++ b/detection/examples/VideoCaptureComponent/plugin-files/descriptor/descriptor.json @@ -1,7 +1,7 @@ { "componentName": "VideoCaptureComponent", - "componentVersion": "5.1", - "middlewareVersion": "5.1", + "componentVersion": "6.0", + "middlewareVersion": "6.0", "sourceLanguage": "c++", "batchLibrary": "${MPF_HOME}/plugins/VideoCaptureComponent/lib/libmpfVideoCapture.so", "environmentVariables": [ diff --git a/detection/testUtils/CMakeLists.txt b/detection/testUtils/CMakeLists.txt index 3d69fcd..04e3096 100644 --- a/detection/testUtils/CMakeLists.txt +++ b/detection/testUtils/CMakeLists.txt @@ -30,7 +30,7 @@ project(openmpf-cpp-component-test-utils) set(CMAKE_CXX_STANDARD 11) -find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 +find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core opencv_imgcodecs opencv_imgproc opencv_videoio opencv_highgui) include_directories(include) @@ -54,4 +54,4 @@ set(SOURCE_FILES add_library(mpfComponentTestUtils SHARED ${SOURCE_FILES}) target_link_libraries(mpfComponentTestUtils ${OpenCV_LIBS}) -export_mpf_lib(mpfComponentTestUtils) \ No newline at end of file +export_mpf_lib(mpfComponentTestUtils) diff --git a/detection/testUtils/src/ImageGeneration.cpp b/detection/testUtils/src/ImageGeneration.cpp index 250c980..b02f204 100644 --- a/detection/testUtils/src/ImageGeneration.cpp +++ b/detection/testUtils/src/ImageGeneration.cpp @@ -84,7 +84,7 @@ namespace MPF { namespace COMPONENT { Rect new_rect(x_pos, y_pos, rect.width, rect.height); - cv::rectangle(mask, new_rect, Scalar(255, 255, 255), CV_FILLED); + cv::rectangle(mask, new_rect, Scalar(255, 255, 255), cv::FILLED); if (imshow_on) { cv::imshow("random mask", mask); @@ -98,7 +98,7 @@ namespace MPF { namespace COMPONENT { int ImageGeneration::WriteDetectionOutputImage(const string image_in_uri, const vector &detections, const string image_out_filepath) { - Mat input_image = cv::imread(image_in_uri.c_str(), CV_LOAD_IMAGE_IGNORE_ORIENTATION + CV_LOAD_IMAGE_COLOR); + Mat input_image = cv::imread(image_in_uri.c_str(), cv::IMREAD_IGNORE_ORIENTATION + cv::IMREAD_COLOR); if (input_image.empty()) { printf("Could not open the input image: %s\n", image_in_uri.c_str()); return -1; @@ -120,7 +120,7 @@ namespace MPF { namespace COMPONENT { int ImageGeneration::WriteDetectionOutputImage(const string image_in_uri, const vector &detections, const string image_out_filepath) { - Mat input_image = cv::imread(image_in_uri.c_str(), CV_LOAD_IMAGE_IGNORE_ORIENTATION + CV_LOAD_IMAGE_COLOR); + Mat input_image = cv::imread(image_in_uri.c_str(), cv::IMREAD_IGNORE_ORIENTATION + cv::IMREAD_COLOR); if (input_image.empty()) { printf("Could not open the input image: %s\n", image_in_uri.c_str()); return -1; diff --git a/detection/testUtils/src/VideoGeneration.cpp b/detection/testUtils/src/VideoGeneration.cpp index 3f7aa41..db9b485 100644 --- a/detection/testUtils/src/VideoGeneration.cpp +++ b/detection/testUtils/src/VideoGeneration.cpp @@ -102,7 +102,7 @@ namespace MPF { namespace COMPONENT { Rect new_rect(x_pos, y_pos, rect.width, rect.height); - cv::rectangle(mask, new_rect, Scalar(255, 255, 255), CV_FILLED); + cv::rectangle(mask, new_rect, Scalar(255, 255, 255), cv::FILLED); if (imshow_on) { cv::imshow("random mask", mask); @@ -128,7 +128,7 @@ namespace MPF { namespace COMPONENT { return Rect(0, 0, 0, 0); } else { - cv::rectangle(mask, new_rect, Scalar(255, 255, 255), CV_FILLED); + cv::rectangle(mask, new_rect, Scalar(255, 255, 255), cv::FILLED); if (imshow_on) { cv::imshow("random mask", mask); cv::waitKey(5); @@ -158,13 +158,13 @@ namespace MPF { namespace COMPONENT { return -1; } - Size size = Size(static_cast(input_video.get(CV_CAP_PROP_FRAME_WIDTH)), - static_cast(input_video.get(CV_CAP_PROP_FRAME_HEIGHT))); + Size size = Size(static_cast(input_video.get(cv::CAP_PROP_FRAME_WIDTH)), + static_cast(input_video.get(cv::CAP_PROP_FRAME_HEIGHT))); VideoWriter output_video; - double fps = input_video.get(CV_CAP_PROP_FPS); - output_video.open(video_out_filepath, CV_FOURCC('M', 'J', 'P', 'G'), fps, size, true); + double fps = input_video.get(cv::CAP_PROP_FPS); + output_video.open(video_out_filepath, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), fps, size, true); if (!output_video.isOpened()) { std::cout << "Could not open the output video for write: " << video_out_filepath << std::endl; @@ -227,7 +227,7 @@ namespace MPF { namespace COMPONENT { VideoWriter output_video; double fps = 30; - output_video.open(video_out_filepath, CV_FOURCC('M', 'J', 'P', 'G'), fps, video_size, true); + output_video.open(video_out_filepath, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), fps, video_size, true); if (!output_video.isOpened()) { std::cout << "Could not open the output video for write: " << video_out_filepath << std::endl; return -1; diff --git a/detection/utils/CMakeLists.txt b/detection/utils/CMakeLists.txt index c8bcc51..8c45176 100644 --- a/detection/utils/CMakeLists.txt +++ b/detection/utils/CMakeLists.txt @@ -29,7 +29,7 @@ project(openmpf-cpp-component-utils) set(CMAKE_CXX_STANDARD 11) -find_package(OpenCV 3.4.7 EXACT REQUIRED PATHS /opt/opencv-3.4.7 +find_package(OpenCV 4.5.0 EXACT REQUIRED PATHS /opt/opencv-4.5.0 COMPONENTS opencv_core opencv_imgcodecs opencv_imgproc opencv_videoio) find_package(PkgConfig) diff --git a/detection/utils/src/Utils.cpp b/detection/utils/src/Utils.cpp index ece87b1..d2d423f 100644 --- a/detection/utils/src/Utils.cpp +++ b/detection/utils/src/Utils.cpp @@ -120,7 +120,7 @@ namespace MPF { namespace COMPONENT { namespace Utils { cv::Mat ConvertToGray(const cv::Mat &image) { cv::Mat gray; if (image.channels() == 3) { - cv::cvtColor(image, gray, CV_BGR2GRAY); + cv::cvtColor(image, gray, cv::COLOR_BGR2GRAY); } else if (image.channels() == 1) { gray = image.clone();