Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to using cv_bridge type adapter #584

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion image_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ find_package(rclcpp_components REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(OpenCV REQUIRED COMPONENTS core highgui imgcodecs imgproc videoio)
find_package(cv_bridge REQUIRED)

add_library(${PROJECT_NAME} SHARED
src/burger.cpp
src/cam2image.cpp
src/cv_mat_sensor_msgs_image_type_adapter.cpp
src/showimage.cpp
)
target_compile_definitions(${PROJECT_NAME}
Expand All @@ -34,6 +34,7 @@ target_link_libraries(${PROJECT_NAME}
${sensor_msgs_TARGETS}
${std_msgs_TARGETS}
rclcpp_components::component
cv_bridge::cv_bridge
${OpenCV_LIBS})
rclcpp_components_register_node(${PROJECT_NAME} PLUGIN "image_tools::Cam2Image" EXECUTABLE cam2image)
rclcpp_components_register_node(${PROJECT_NAME} PLUGIN "image_tools::ShowImage" EXECUTABLE showimage)
Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions image_tools/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
<author email="[email protected]">Mabel Zhang</author>

<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>libopencv-dev</build_depend>
<build_depend>rclcpp</build_depend>
<build_depend>rclcpp_components</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>

<exec_depend>cv_bridge</exec_depend>
<exec_depend>libopencv-dev</exec_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>rclcpp_components</exec_depend>
Expand Down
10 changes: 5 additions & 5 deletions image_tools/src/cam2image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
#include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"

#include "cv_bridge/cv_mat_sensor_msgs_image_type_adapter.hpp"
#include "rcl_interfaces/msg/parameter_descriptor.hpp"
#include "rclcpp/rclcpp.hpp"
#include "rclcpp_components/register_node_macro.hpp"
#include "std_msgs/msg/bool.hpp"

#include "image_tools/cv_mat_sensor_msgs_image_type_adapter.hpp"
#include "image_tools/visibility_control.h"

#include "./burger.hpp"
#include "./policy_maps.hpp"

RCLCPP_USING_CUSTOM_TYPE_AS_ROS_MESSAGE_TYPE(
image_tools::ROSCvMatContainer,
cv_bridge::ROSCvMatContainer,
sensor_msgs::msg::Image);

namespace image_tools
Expand Down Expand Up @@ -81,7 +81,7 @@ class Cam2Image : public rclcpp::Node
// ensure that every message gets received in order, or best effort, meaning that the transport
// makes no guarantees about the order or reliability of delivery.
qos.reliability(reliability_policy_);
pub_ = create_publisher<image_tools::ROSCvMatContainer>("image", qos);
pub_ = create_publisher<cv_bridge::ROSCvMatContainer>("image", qos);

// Subscribe to a message that will toggle flipping or not flipping, and manage the state in a
// callback
Expand Down Expand Up @@ -148,7 +148,7 @@ class Cam2Image : public rclcpp::Node
std_msgs::msg::Header header;
header.frame_id = frame_id_;
header.stamp = this->now();
image_tools::ROSCvMatContainer container(frame, header);
cv_bridge::ROSCvMatContainer container(frame, header);

// Publish the image message and increment the publish_number_.
RCLCPP_INFO(get_logger(), "Publishing image #%zd", publish_number_++);
Expand Down Expand Up @@ -255,7 +255,7 @@ class Cam2Image : public rclcpp::Node
burger::Burger burger_cap;

rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr sub_;
rclcpp::Publisher<image_tools::ROSCvMatContainer>::SharedPtr pub_;
rclcpp::Publisher<cv_bridge::ROSCvMatContainer>::SharedPtr pub_;
rclcpp::TimerBase::SharedPtr timer_;

// ROS parameters
Expand Down
Loading