I'm trying to publish a CameraInfo message so that I can (eventually) use image_proc. I tried to write the subscriber/publisher from scratch and ran into the issue with filling in entries in the D matrix of the CameraInfo message (segfaults caused by allocation issues).
I looked around and found the camera_info_manager package but I can't figure out how to use it. I've tried to copy/paste what I could from the [camera1394 drivers](https://github.com/ros-drivers/camera1394/blob/master/src/nodes/driver1394.cpp) recommended by [this](http://answers.ros.org/question/11361/how-to-publish-sensor_msgscamerainfo-messages/) thread but I can't figure out how to initialize it--the references for the initialization are missing.
Update: I've gotten the problem down to a camera URL issue. I run the code with a rosbag publishing images and get an error from camera_info_manager reading
Camera calibration file /home/rnl/.ros/camera_info/camtest1.yaml not found.
Update 2: It all works now, camera_info_manager was not reading properly from the .yaml. Whoever had installed the package on this machine had downloaded it from a bad source.
code here
//includes and whatnot
class publishCameraInfo
{
public:
publishCameraInfo()
{
//Topic you want to publish
image_pub_ = n_.advertise("snap_cam_camInfo/CameraInfo", 1);
//Topic you want to subscribe
sub_ = n_.subscribe("snap_cam_highres_publisher/image", 1, &publishCameraInfo::callback, this);
}
void callback(const sensor_msgs::Image& imgmsg)
{
const std::string camname="camtest1";
const std::string camurl="file://~/.ros/camera_info/camtest1.yaml";
camera_info_manager::CameraInfoManager caminfo(n_, camname,camurl);
sensor_msgs::CameraInfo ci;
ci=caminfo.getCameraInfo();
ci.header.stamp = imgmsg.header.stamp;
ci.header.frame_id = imgmsg.header.frame_id;
image_pub_.publish(imgmsg, ci);
}
private:
ros::NodeHandle n_;
ros::Publisher image_pub_;
ros::Subscriber sub_;
};//End of class
int main(int argc, char **argv)
{
ros::init(argc, argv, "publishCameraInfo");
publishCameraInfo cameraPubObject;
ros::spin();
return 0;
}
↧