Skip to content

Commit

Permalink
image_view: fix encoding, help string (#850)
Browse files Browse the repository at this point in the history
* encoding shouldn't be hard coded, pull it from the message
* help string needs to be updated to proper parameter format
  • Loading branch information
mikeferguson authored Jan 17, 2024
1 parent ed4da8a commit 8f16860
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions image_view/src/image_view_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ ImageViewNode::ImageViewNode(const rclcpp::NodeOptions & options)
RCLCPP_WARN(
this->get_logger(), "Topic 'image' has not been remapped! "
"Typical command-line usage:\n"
"\t$ rosrun image_view image_view image:=<image topic> [transport]");
"\t$ ros2 run image_view image_view --ros-args -p image:=<image topic> "
"[-p image_transport:=<transport>]");
}

// Default window name is the resolved topic name
Expand Down Expand Up @@ -210,9 +211,11 @@ void ImageViewNode::imageCb(const sensor_msgs::msg::Image::ConstSharedPtr & msg)
}
}

std::string encoding = msg->encoding.empty() ? "bgr8" : msg->encoding;

queued_image_.set(
cv_bridge::cvtColorForDisplay(
cv_bridge::toCvShare(msg), "bgr8", options));
cv_bridge::toCvShare(msg), encoding, options));
} catch (cv_bridge::Exception & e) {
RCLCPP_ERROR_EXPRESSION(
this->get_logger(), (static_cast<int>(this->now().seconds()) % 30 == 0),
Expand Down

0 comments on commit 8f16860

Please sign in to comment.