diff --git a/.travis.sh b/.travis.sh index 9967b6d..40b9b6f 100644 --- a/.travis.sh +++ b/.travis.sh @@ -28,13 +28,29 @@ # Install ROS sudo sh -c "echo \"deb http://packages.ros.org/ros-shadow-fixed/ubuntu `lsb_release -cs` main\" > /etc/apt/sources.list.d/ros-latest.list" wget http://packages.ros.org/ros.key -O - | sudo apt-key add - + # Setup EoL repository + if [[ "$ROS_DISTRO" == "hydro" || "$ROS_DISTRO" == "jade" || "$ROS_DISTRO" == "lunar" ]]; then + sudo -E sh -c 'echo "deb http://snapshots.ros.org/$ROS_DISTRO/final/ubuntu `lsb_release -sc` main" >> /etc/apt/sources.list.d/ros-latest.list' + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 0xCBF125EA + fi sudo apt-get update -qq + ### HotFix: Hold python-vcs-tools for hydro (https://github.com/vcstools/vcstools/issues/157) + if [[ "$ROS_DISTRO" == "hydro" ]]; then + sudo apt-get install -y --force-yes -q python-vcstools=0.1.40-1 + sudo apt-mark hold python-vcstools + fi + ### # Install ROS - sudo apt-get install -y -q python-catkin-pkg python-catkin-tools python-rosdep python-wstool python-rosinstall-generator ros-$ROS_DISTRO-catkin + if [[ "$ROS_DISTRO" == "noetic" ]]; then + sudo apt-get install -y -q python3-catkin-pkg python3-catkin-tools python3-rosdep python3-wstool python3-rosinstall-generator python3-osrf-pycommon + else + sudo apt-get install -y -q python-catkin-pkg python-catkin-tools python-rosdep python-wstool python-rosinstall-generator + fi + sudo apt-get install -y -q ros-$ROS_DISTRO-catkin source /opt/ros/$ROS_DISTRO/setup.bash # Setup for rosdep sudo rosdep init - rosdep update + rosdep update --include-eol-distros travis_time_end travis_time_start setup.install @@ -103,7 +119,7 @@ echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections travis_time_end -if [ $TEST == "catkin_lint" ]; then +if [ "$TEST" == "catkin_lint" ]; then travis_time_start catkin_lint.script apt-get install -y -q python-pip @@ -114,7 +130,7 @@ ROS_DISTRO=melodic catkin_lint --resolve-env --strict $CI_SOURCE_PATH -elif [ $TEST == "clang-format" ]; then +elif [ "$TEST" == "clang-format" ]; then travis_time_start clang_format.script apt-get install -y -q clang-format-3.9 git @@ -123,7 +139,7 @@ git -C $CI_SOURCE_PATH --no-pager diff git -C $CI_SOURCE_PATH diff-index --quiet HEAD -- . -elif [ $TEST == "clang-tidy" ]; then +elif [ "$TEST" == "clang-tidy" ]; then setup diff --git a/.travis.yml b/.travis.yml index f5b0d71..d58f844 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ sudo: required -dist: trusty +dist: bionic language: generic env: + - CHECK_PYTHON3_COMPILE=true - TEST=catkin_lint DOCKER_IMAGE=ubuntu:bionic - TEST=clang-format DOCKER_IMAGE=ubuntu:bionic - TEST=clang-tidy ROS_DISTRO=melodic DOCKER_IMAGE=ubuntu:bionic @@ -10,8 +11,10 @@ - OPENCV_VERSION=3 ROS_DISTRO=indigo DOCKER_IMAGE=ubuntu:trusty - ROS_DISTRO=kinetic DOCKER_IMAGE=ubuntu:xenial - ROS_DISTRO=melodic DOCKER_IMAGE=ubuntu:bionic + - ROS_DISTRO=noetic DOCKER_IMAGE=ubuntu:focal # Install system dependencies, namely ROS. script: + - if [ "${CHECK_PYTHON3_COMPILE}" == "true" ]; then python3 -m compileall .; exit $?; fi - export CI_SOURCE_PATH=$(pwd) - export REPOSITORY_NAME=${PWD##*/} - echo "Testing branch $TRAVIS_BRANCH of $REPOSITORY_NAME" diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1054d73..7445d91 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,38 @@ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package opencv_apps ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +2.0.2 (2020-08-19) +------------------ +* .travis.yml: add noetic test (`#108 `_) + + * support oepncv4 for face detection launch/test files + * convert img_gray every loop, this fixes + [ERROR] [1597757072.115502734]: Image processing error: Matrix operand is an empty matrix. checkOperandsExist ../modules/core/src/matrix_expressions.cpp 23 + errors + * check CV_VERSION_VERSION > 4 + * add g++ static to package.xml + * use python3 for noetic + * .travis.yml : add CHECK_PYTHON3_COMPILE + * .travis.yml: add noetic test + +* fix travis (`#106 `_) + + * add more package to CATKIN_DEPENDS + * add image_view to run_depends + +* add hot fix for hydro test (`#98 `_) + + * add doublequote arount $TEST + * add hot fix for hydro test + +* Improved variable names and comments (`#95 `_) + + * Improved variable names and comments: The comments and variable names were the opposite of what was functionally happening in the code. No functional change to this commit, just better readability and maintainability. + +* setup EoL repository (`#96 `_) + +* Contributors: Gus Crowards, Kei Okada 2.0.1 (2019-04-22) ------------------ diff --git a/CMakeLists.txt b/CMakeLists.txt index 852001b..3b2dbb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,7 @@ std_msgs ) -catkin_package(CATKIN_DEPENDS message_runtime sensor_msgs std_msgs +catkin_package(CATKIN_DEPENDS dynamic_reconfigure message_runtime nodelet roscpp sensor_msgs std_msgs std_srvs # DEPENDS OpenCV INCLUDE_DIRS include LIBRARIES ${PROJECT_NAME} diff --git a/launch/face_detection.launch b/launch/face_detection.launch index b979e45..d0c9d8a 100644 --- a/launch/face_detection.launch +++ b/launch/face_detection.launch @@ -4,6 +4,7 @@ + @@ -23,6 +24,11 @@ name="face_cascade_name" default="$(find opencv3)/../OpenCV-3.3.1-dev/haarcascades/haarcascade_frontalface_alt.xml" doc="Face dtection cascade Filename" /> + + + + @@ -21,6 +22,7 @@ + opencv_apps - 2.0.1 + 2.0.2

opencv_apps provides various nodes that run internally OpenCV's functionalities and publish the result as ROS topics. With opencv_apps, you can skip writing OpenCV application codes for a lot of its functionalities by simply running a launch file that corresponds to OpenCV's functionality you want.

    @@ -20,6 +20,7 @@ cv_bridge dynamic_reconfigure + g++-static image_transport message_generation nodelet @@ -31,6 +32,7 @@ cv_bridge dynamic_reconfigure image_transport + image_view message_runtime nodelet roscpp @@ -44,7 +46,6 @@ rosservice rostopic image_proc - image_view topic_tools compressed_image_transport diff --git a/src/nodelet/face_recognition_nodelet.cpp b/src/nodelet/face_recognition_nodelet.cpp index 4088e78..ef7b7b5 100644 --- a/src/nodelet/face_recognition_nodelet.cpp +++ b/src/nodelet/face_recognition_nodelet.cpp @@ -74,6 +74,11 @@ namespace face = cv; #endif +#if CV_MAJOR_VERSION >= 4 +#include // include CV_LOAD_IMAGE_COLOR +#include // include CV_AA +#endif + // utility for resolving path namespace boost { @@ -548,7 +553,7 @@ if (config.model_method == "eigen") { // https://docs.opencv.org/3.3.1/da/d60/tutorial_face_main.html -#if CV_MAJOR_VERSION >= 3 && CV_MINOR_VERSION >= 3 +#if (CV_MAJOR_VERSION >= 4) || (CV_MAJOR_VERSION >= 3 && CV_MINOR_VERSION >= 3) model_ = face::EigenFaceRecognizer::create(config.model_num_components, config.model_threshold); #else model_ = face::createEigenFaceRecognizer(config.model_num_components, config.model_threshold); @@ -556,7 +561,7 @@ } else if (config.model_method == "fisher") { -#if CV_MAJOR_VERSION >= 3 && CV_MINOR_VERSION >= 3 +#if (CV_MAJOR_VERSION >= 4) || (CV_MAJOR_VERSION >= 3 && CV_MINOR_VERSION >= 3) model_ = face::FisherFaceRecognizer::create(config.model_num_components, config.model_threshold); #else model_ = face::createFisherFaceRecognizer(config.model_num_components, config.model_threshold); @@ -564,7 +569,7 @@ } else if (config.model_method == "LBPH") { -#if CV_MAJOR_VERSION >= 3 && CV_MINOR_VERSION >= 3 +#if (CV_MAJOR_VERSION >= 4) || (CV_MAJOR_VERSION >= 3 && CV_MINOR_VERSION >= 3) model_ = face::LBPHFaceRecognizer::create(config.lbph_radius, config.lbph_neighbors, config.lbph_grid_x, config.lbph_grid_y); #else diff --git a/src/nodelet/segment_objects_nodelet.cpp b/src/nodelet/segment_objects_nodelet.cpp index a6b276a..609de52 100644 --- a/src/nodelet/segment_objects_nodelet.cpp +++ b/src/nodelet/segment_objects_nodelet.cpp @@ -46,6 +46,9 @@ #include #include #include +#if CV_MAJOR_VERSION >= 4 +#include // incldue CV_FILLED +#endif #include #include "opencv_apps/SegmentObjectsConfig.h" diff --git a/src/nodelet/simple_flow_nodelet.cpp b/src/nodelet/simple_flow_nodelet.cpp index c9629fe..300563a 100644 --- a/src/nodelet/simple_flow_nodelet.cpp +++ b/src/nodelet/simple_flow_nodelet.cpp @@ -46,7 +46,7 @@ #include #include #include -#if CV_MAJOR_VERSION == 3 +#if CV_MAJOR_VERSION >= 3 #include #endif @@ -79,7 +79,7 @@ static bool need_config_update_; int scale_; - cv::Mat gray, prevGray; + cv::Mat color, prevColor; void reconfigureCallback(Config& new_config, uint32_t level) { @@ -117,7 +117,7 @@ // Convert the image into something opencv can handle. cv::Mat frame_src = cv_bridge::toCvShare(msg, sensor_msgs::image_encodings::BGR8)->image; - /// Convert it to gray + /// Convert it to 3 channel cv::Mat frame; if (frame_src.channels() > 1) { @@ -128,18 +128,18 @@ cv::cvtColor(frame_src, frame, cv::COLOR_GRAY2BGR); } - cv::resize(frame, gray, cv::Size(frame.cols / (double)MAX(1, scale_), frame.rows / (double)MAX(1, scale_)), 0, 0, + cv::resize(frame, color, cv::Size(frame.cols / (double)MAX(1, scale_), frame.rows / (double)MAX(1, scale_)), 0, 0, CV_INTER_AREA); - if (prevGray.empty()) - gray.copyTo(prevGray); - - if (gray.rows != prevGray.rows && gray.cols != prevGray.cols) + if (prevColor.empty()) + color.copyTo(prevColor); + + if (color.rows != prevColor.rows && color.cols != prevColor.cols) { NODELET_WARN("Images should be of equal sizes"); - gray.copyTo(prevGray); - } - - if (frame.type() != 16) + color.copyTo(prevColor); + } + + if (frame.type() != CV_8UC3) { NODELET_ERROR("Images should be of equal type CV_8UC3"); } @@ -163,10 +163,10 @@ } float start = (float)cv::getTickCount(); -#if CV_MAJOR_VERSION == 3 - cv::optflow::calcOpticalFlowSF(gray, prevGray, +#if CV_MAJOR_VERSION >= 3 + cv::optflow::calcOpticalFlowSF(color, prevColor, #else - cv::calcOpticalFlowSF(gray, prevGray, + cv::calcOpticalFlowSF(color, prevColor, #endif flow, 3, 2, 4, 4.1, 25.5, 18, 55.0, 25.5, 0.35, 18, 55.0, 25.5, 10); NODELET_INFO("calcOpticalFlowSF : %lf sec", (cv::getTickCount() - start) / cv::getTickFrequency()); @@ -210,7 +210,7 @@ int c = cv::waitKey(1); } - cv::swap(prevGray, gray); + cv::swap(prevColor, color); // Publish the image. sensor_msgs::Image::Ptr out_img = cv_bridge::CvImage(msg->header, "bgr8", frame).toImageMsg(); img_pub_.publish(out_img); diff --git a/src/nodelet/watershed_segmentation_nodelet.cpp b/src/nodelet/watershed_segmentation_nodelet.cpp index c4465bf..efde9a6 100644 --- a/src/nodelet/watershed_segmentation_nodelet.cpp +++ b/src/nodelet/watershed_segmentation_nodelet.cpp @@ -82,7 +82,7 @@ static int on_mouse_y_; static int on_mouse_flags_; - cv::Mat markerMask; + cv::Mat markerMask, img_gray; cv::Point prevPt; static void onMouse(int event, int x, int y, int flags, void* /*unused*/) @@ -135,15 +135,16 @@ // Do the work // std::vector faces; - cv::Mat img_gray; /// Initialize if (markerMask.empty()) { cv::cvtColor(frame, markerMask, cv::COLOR_BGR2GRAY); - cv::cvtColor(markerMask, img_gray, cv::COLOR_GRAY2BGR); markerMask = cv::Scalar::all(0); } + cv::Mat tmp; + cv::cvtColor(frame, tmp, cv::COLOR_BGR2GRAY); + cv::cvtColor(tmp, img_gray, cv::COLOR_GRAY2BGR); if (debug_view_) { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d6c2cd8..c561c05 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -41,6 +41,9 @@ add_rostest(test-general_contours.test ARGS gui:=false) add_rostest(test-contour_moments.test ARGS gui:=false) if(cv_bridge_VERSION VERSION_LESS "1.11.9") # hydro skip face_detection.test +elseif("$ENV{ROS_DISTRO}" STREQUAL "noetic") # noetic uses opencv4 (need to use_opencv3 for some reason...) + add_rostest(test-face_detection.test ARGS gui:=false use_opencv3:=true use_opencv4:=true) + add_rostest(test-face_recognition.test ARGS gui:=false use_opencv3:=true use_opencv4:=true) elseif("$ENV{ROS_DISTRO}" STREQUAL "melodic") # melodic uses opencv3 add_rostest(test-face_detection.test ARGS gui:=false) add_rostest(test-face_recognition.test ARGS gui:=false) diff --git a/test/test-face_detection.test b/test/test-face_detection.test index fb60405..2ea7370 100644 --- a/test/test-face_detection.test +++ b/test/test-face_detection.test @@ -4,6 +4,7 @@ + @@ -18,6 +19,7 @@ + diff --git a/test/test-face_recognition.test b/test/test-face_recognition.test index a4606b4..2bbe44b 100644 --- a/test/test-face_recognition.test +++ b/test/test-face_recognition.test @@ -4,6 +4,7 @@ + @@ -20,6 +21,7 @@ +