camera_info_republisher.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
27 
28 #include <ros/ros.h>
29 #include <tf/transform_broadcaster.h>
30 #include <geometry_msgs/TransformStamped.h>
31 #include <image_transport/image_transport.h>
32 #include <cv_bridge/cv_bridge.h>
33 #include <sensor_msgs/image_encodings.h>
34 #include <opencv2/imgproc/imgproc.hpp>
35 #include <opencv2/highgui/highgui.hpp>
36 #include <sensor_msgs/image_encodings.h>
37 #include <driver_base/driver.h>
38 #include <camera_info_manager/camera_info_manager.h>
39 #include <tf/transform_broadcaster.h>
40 
41 using namespace std;
42 
44 {
45  public:
46 
47  CameraInfoRepublisher(ros::NodeHandle& nh_):
48  nh(nh_),
49  it(nh_)
50  {
51  ros::NodeHandle private_node("~");
52 
53  string camera_calibration_file;
54  private_node.param("camera_calibration_file",camera_calibration_file,string("image calibration file not set"));
55 
56  string camera_name;
57  private_node.param("camera_name",camera_name,string(""));
58 
59  info_manager = new camera_info_manager::CameraInfoManager(ros::NodeHandle(nh, camera_name),camera_name,camera_calibration_file);
60 
61  subscriber = it.subscribe("image_raw", 1, &CameraInfoRepublisher::imageHandler,this);
62 
63  publisher = it.advertiseCamera("new_info/image_raw", 1);
64  }
65 
66  void imageHandler(const sensor_msgs::ImageConstPtr& msg)
67  {
68  image = *msg;
69  info = info_manager->getCameraInfo();
70  publisher.publish(image, info, image.header.stamp);
71  }
72 
73  ros::NodeHandle nh;
74  image_transport::ImageTransport it;
75 
76  sensor_msgs::Image image;
77 
78  sensor_msgs::CameraInfo info;
79 
80  image_transport::Subscriber subscriber;
81 
82  camera_info_manager::CameraInfoManager* info_manager;
83 
84  image_transport::CameraPublisher publisher;
85 };
86 
87 int main(int argc, char** argv)
88 {
89  ros::init(argc, argv, "camera_info_republisher");
90  ros::NodeHandle node;
91 
92  CameraInfoRepublisher info_publisher(node);
93 
94  ros::spin();
95 
96  return 0;
97 }
void imageHandler(const sensor_msgs::ImageConstPtr &msg)
image_transport::Subscriber subscriber
CameraInfoRepublisher(ros::NodeHandle &nh_)
image_transport::ImageTransport it
int main(int argc, char **argv)
image_transport::CameraPublisher publisher
camera_info_manager::CameraInfoManager * info_manager
sensor_msgs::CameraInfo info


multisensor_aquisition
Author(s): Jorge Almeida
autogenerated on Mon Mar 2 2015 01:32:28