CameraInfo publisher can't find .yaml file
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 camerainfomanager package but I can't figure out how to use it. I've tried to copy/paste what I could from the camera1394 drivers recommended by this 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 camerainfomanager reading
Camera calibration file /home/rnl/.ros/camera_info/camtest1.yaml not found.
Update 2: It all works now, camerainfomanager 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<sensor_msgs::CameraInfo>("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;
}
Asked by Nick30075 on 2017-06-29 17:09:26 UTC
Comments