Skip to content

Instantly share code, notes, and snippets.

@surajRathi
Created February 21, 2022 10:28
Show Gist options
  • Save surajRathi/d27fe1c4a04465f3c991480d47357c55 to your computer and use it in GitHub Desktop.
Save surajRathi/d27fe1c4a04465f3c991480d47357c55 to your computer and use it in GitHub Desktop.
Use image_transport::subscribe_camera
#include <ros/ros.h>
#include <image_transport/image_transport.h>
int main(int argc, char *argv[]) {
ros::init(argc, argv, "auto_brightness", ros::init_options::AnonymousName);
ros::NodeHandle nh, pnh("~");
image_transport::ImageTransport it{nh}; // Is this necessary?
auto input_ns = pnh.param("input", std::string{"camera"});
auto output_ns = pnh.param("output", std::string{"fake_stereo"});
auto callback = [](
const sensor_msgs::ImageConstPtr &img, const sensor_msgs::CameraInfoConstPtr &cinfo) {
ROS_WARN("recv data");
};
ROS_ERROR("Node runnin? %s %s", input_ns.c_str(), output_ns.c_str());
auto camera_sub = it.subscribeCamera(input_ns + "/image_raw", 10,
image_transport::CameraSubscriber::Callback{callback});
ros::spin();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment