CameraInfo publisher can't find .yaml file [closed]

asked 2017-06-29 17:09:26 -0600

Nick30075 gravatar image

updated 2017-07-03 11:27:55 -0600

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 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 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<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;
}
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Nick30075
close date 2017-07-03 11:28:23.792775