diff --git a/common/perception_utils/CMakeLists.txt b/common/perception_utils/CMakeLists.txt index d4bbe928c0be8..c05dbdaaef644 100644 --- a/common/perception_utils/CMakeLists.txt +++ b/common/perception_utils/CMakeLists.txt @@ -5,3 +5,12 @@ find_package(autoware_cmake REQUIRED) autoware_package() ament_auto_package() + +ament_auto_add_library(${PROJECT_NAME} SHARED + src/run_length_encoder.cpp +) + +find_package(OpenCV REQUIRED) +target_link_libraries(${PROJECT_NAME} + ${OpenCV_LIBS} +) diff --git a/perception/autoware_tensorrt_yolox/include/autoware/tensorrt_yolox/utils.hpp b/common/perception_utils/include/perception_utils/run_length_encoder.hpp similarity index 79% rename from perception/autoware_tensorrt_yolox/include/autoware/tensorrt_yolox/utils.hpp rename to common/perception_utils/include/perception_utils/run_length_encoder.hpp index 8b86a798e798b..18b5f21854e35 100644 --- a/perception/autoware_tensorrt_yolox/include/autoware/tensorrt_yolox/utils.hpp +++ b/common/perception_utils/include/perception_utils/run_length_encoder.hpp @@ -12,17 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef AUTOWARE__TENSORRT_YOLOX__UTILS_HPP_ -#define AUTOWARE__TENSORRT_YOLOX__UTILS_HPP_ +#ifndef PERCEPTION_UTILS__RUN_LENGTH_ENCODER_HPP_ + +#define PERCEPTION_UTILS__RUN_LENGTH_ENCODER_HPP_ #include #include #include -namespace autoware::tensorrt_yolox +namespace perception_utils { std::vector> runLengthEncoder(const cv::Mat & mask); cv::Mat runLengthDecoder(const std::vector & rle_data, const int rows, const int cols); -} // namespace autoware::tensorrt_yolox +} // namespace perception_utils -#endif // AUTOWARE__TENSORRT_YOLOX__UTILS_HPP_ +#endif // PERCEPTION_UTILS__RUN_LENGTH_ENCODER_HPP_ diff --git a/common/perception_utils/package.xml b/common/perception_utils/package.xml index a6bfbc42090fe..b38226991eb66 100644 --- a/common/perception_utils/package.xml +++ b/common/perception_utils/package.xml @@ -11,6 +11,7 @@ ament_cmake_auto autoware_cmake + libopencv-dev rclcpp diff --git a/perception/autoware_tensorrt_yolox/src/utils.cpp b/common/perception_utils/src/run_length_encoder.cpp similarity index 94% rename from perception/autoware_tensorrt_yolox/src/utils.cpp rename to common/perception_utils/src/run_length_encoder.cpp index 8d2b4a4a0527f..fb7f5ba33b846 100644 --- a/perception/autoware_tensorrt_yolox/src/utils.cpp +++ b/common/perception_utils/src/run_length_encoder.cpp @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "autoware/tensorrt_yolox/utils.hpp" +#include "perception_utils/run_length_encoder.hpp" -namespace autoware::tensorrt_yolox +namespace perception_utils { std::vector> runLengthEncoder(const cv::Mat & image) @@ -62,4 +62,4 @@ cv::Mat runLengthDecoder(const std::vector & rle_data, const int rows, return mask; } -} // namespace autoware::tensorrt_yolox +} // namespace perception_utils diff --git a/perception/autoware_tensorrt_yolox/CMakeLists.txt b/perception/autoware_tensorrt_yolox/CMakeLists.txt index 564ac54dbc563..1f54326f2b33a 100644 --- a/perception/autoware_tensorrt_yolox/CMakeLists.txt +++ b/perception/autoware_tensorrt_yolox/CMakeLists.txt @@ -143,7 +143,6 @@ rclcpp_components_register_node(yolox_single_image_inference_node ) ament_auto_add_library(${PROJECT_NAME}_node SHARED - src/utils.cpp src/tensorrt_yolox_node.cpp ) diff --git a/perception/autoware_tensorrt_yolox/package.xml b/perception/autoware_tensorrt_yolox/package.xml index 9205b0c83cbea..3373a07d8b434 100644 --- a/perception/autoware_tensorrt_yolox/package.xml +++ b/perception/autoware_tensorrt_yolox/package.xml @@ -24,6 +24,7 @@ image_transport libopencv-dev object_recognition_utils + perception_utils rclcpp rclcpp_components sensor_msgs diff --git a/perception/autoware_tensorrt_yolox/src/tensorrt_yolox_node.cpp b/perception/autoware_tensorrt_yolox/src/tensorrt_yolox_node.cpp index 7f398ca005d67..c613e7d1df52f 100644 --- a/perception/autoware_tensorrt_yolox/src/tensorrt_yolox_node.cpp +++ b/perception/autoware_tensorrt_yolox/src/tensorrt_yolox_node.cpp @@ -14,8 +14,8 @@ #include "autoware/tensorrt_yolox/tensorrt_yolox_node.hpp" -#include "autoware/tensorrt_yolox/utils.hpp" #include "object_recognition_utils/object_classification.hpp" +#include "perception_utils/run_length_encoder.hpp" #include @@ -184,7 +184,7 @@ void TrtYoloXNode::onImage(const sensor_msgs::msg::Image::ConstSharedPtr msg) .toImageMsg(); out_mask_msg->header = msg->header; - std::vector> compressed_data = runLengthEncoder(mask); + std::vector> compressed_data = perception_utils::runLengthEncoder(mask); int step = sizeof(uint8_t) + sizeof(int); out_mask_msg->data.resize(static_cast(compressed_data.size()) * step); for (size_t i = 0; i < compressed_data.size(); ++i) {