ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you need a "screenshot", you have two possibilities:

  1. Use system-screenshot ability and take a screenshot of the image_view output.
  2. Write a little Node / Nodelet which listen to a keyboard shortcut and then write the current image to file, for e.g. with cv_bridge functionality.

    void save_image(const sensor_msgs::ImageConstPtr img, const std::string prefix)
    {
        // May want to view raw bayer data
        // NB: This is hacky, but should be OK since we have only one image CB.
        if (img->encoding.find("bayer") != std::string::npos)
          boost::const_pointer_cast<sensor_msgs::image>(img)->encoding = "mono8";

        cv::Mat image;
        try
        {
          image = cv_bridge::toCvShare(img, "bgr8")->image;
        } catch(cv_bridge::Exception)
        {
          ROS_ERROR("Unable to convert %s image to bgr8", img->encoding.c_str());
        }
        std::string directory = std::string(getenv("HOME")) + "/catkin_ws/video_dumper_jpeg/";
        std::string filename = (filename_format_ % prefix % count_ ).str();
        cv::imwrite(directory + filename, image);
    }