How to incorporate VideoWriter code into image_publisher code of ros?












0















I am setting up a ros system to publish images with ros, c++ and opencv-2 for my drone. The code, below, is publishing raw images. While publishing, I want to write gray-scale images frame-by-frame with resolution of 1280 x 720 to record a video. I have found a readily available video writing code with opencv. However, I could not incorporate this code into image_publisher code. Here is the image_publisher code:



#include <ros/ros.h>
#include <camera_info_manager/camera_info_manager.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <opencv2/opencv.hpp>

int main(int argc, char **argv)
{
ROS_INFO("Starting image_pub ROS node...n");

ros::init(argc, argv, "image_pub");
ros::NodeHandle nh("~");

std::string camera_topic;
std::string camera_info_topic;
std::string camera_info_url;
std::string img_path;
std::string frame_id;
float pub_rate;
int start_sec;
bool repeat;
nh.param<std::string>("camera_topic", camera_topic, "/camera/image_raw");
nh.param<std::string>("camera_info_topic", camera_info_topic, "/camera/camera_info");
nh.param<std::string>("camera_info_url", camera_info_url, "");
nh.param<std::string>("img_path", img_path, "");
nh.param<std::string>("frame_id", frame_id, "");
nh.param("pub_rate", pub_rate, 30.0f);
nh.param("start_sec", start_sec, 0);
nh.param("repeat", repeat, false);

ROS_INFO("CTopic : %s", camera_topic.c_str());
ROS_INFO("ITopic : %s", camera_info_topic.c_str());
ROS_INFO("CI URL : %s", camera_info_url.c_str());
ROS_INFO("Source : %s", img_path.c_str());
ROS_INFO("Rate : %.1f", pub_rate);
ROS_INFO("Start : %d", start_sec);
ROS_INFO("Repeat : %s", repeat ? "yes" : "no");
ROS_INFO("FrameID: %s", frame_id.c_str());

camera_info_manager::CameraInfoManager camera_info_manager(nh);
if (camera_info_manager.validateURL(camera_info_url))
camera_info_manager.loadCameraInfo(camera_info_url);

ros::Publisher img_pub = nh.advertise<sensor_msgs::Image>(camera_topic, 1);
ros::Publisher info_pub = nh.advertise<sensor_msgs::CameraInfo>(camera_info_topic, 1);

cv::VideoCapture vid_cap(img_path.c_str());
if (start_sec > 0)
vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec);

ros::Rate rate(pub_rate);
while (ros::ok())
{
cv::Mat img;
if (!vid_cap.read(img))
{
if (repeat)
{
vid_cap.open(img_path.c_str());
if (start_sec > 0)
vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec);
continue;
}
ROS_ERROR("Failed to capture frame.");
ros::shutdown();
}
else
{
//ROS_DEBUG("Image: %dx%dx%d, %zu, %d", img.rows, img.cols, img.channels(), img.elemSize(), img.type() == CV_8UC3);
if (img.type() != CV_8UC3)
img.convertTo(img, CV_8UC3);
// Convert image from BGR format used by OpenCV to RGB.
cv::cvtColor(img, img, CV_BGR2RGB);

auto img_msg = boost::make_shared<sensor_msgs::Image>();
img_msg->header.stamp = ros::Time::now();
img_msg->header.frame_id = frame_id;
img_msg->encoding = "rgb8";
img_msg->width = img.cols;
img_msg->height = img.rows;
img_msg->step = img_msg->width * img.channels();
auto ptr = img.ptr<unsigned char>(0);
img_msg->data = std::vector<unsigned char>(ptr, ptr + img_msg->step * img_msg->height);
img_pub.publish(img_msg);

if (camera_info_manager.isCalibrated())
{
auto info = boost::make_shared<sensor_msgs::CameraInfo>(camera_info_manager.getCameraInfo());
info->header = img_msg->header;
info_pub.publish(info);
}
}
ros::spinOnce();
rate.sleep();
}

return 0;
}


The video writing code (referred to this link):



#include "opencv2/opencv.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int main(){

// Create a VideoCapture object and use camera to capture the video
VideoCapture cap(0);

// Check if camera opened successfully
if(!cap.isOpened())
{
cout << "Error opening video stream" << endl;
return -1;
}

// Default resolution of the frame is obtained.The default resolution is system dependent.
int frame_width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
int frame_height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);

// Define the codec and create VideoWriter object.The output is stored in 'outcpp.avi' file.
VideoWriter video("outcpp.avi",CV_FOURCC('M','J','P','G'),10,
Size(frame_width,frame_height));
while(1)
{
Mat frame;

// Capture frame-by-frame
cap >> frame;

// If the frame is empty, break immediately
if (frame.empty())
break;

// Write the frame into the file 'outcpp.avi'
video.write(frame);

// Display the resulting frame
imshow( "Frame", frame );

// Press ESC on keyboard to exit
char c = (char)waitKey(1);
if( c == 27 )
break;
}

// When everything done, release the video capture and write object
cap.release();
video.release();

// Closes all the windows
destroyAllWindows();
return 0;
}


Firstly, I tried incorporating video writing code (without grayscale) into publisher code. But it failed to run. All in all, image_publisher code should result a video after completing its task. What is the right way of doing this ?










share|improve this question



























    0















    I am setting up a ros system to publish images with ros, c++ and opencv-2 for my drone. The code, below, is publishing raw images. While publishing, I want to write gray-scale images frame-by-frame with resolution of 1280 x 720 to record a video. I have found a readily available video writing code with opencv. However, I could not incorporate this code into image_publisher code. Here is the image_publisher code:



    #include <ros/ros.h>
    #include <camera_info_manager/camera_info_manager.h>
    #include <sensor_msgs/Image.h>
    #include <sensor_msgs/CameraInfo.h>
    #include <opencv2/opencv.hpp>

    int main(int argc, char **argv)
    {
    ROS_INFO("Starting image_pub ROS node...n");

    ros::init(argc, argv, "image_pub");
    ros::NodeHandle nh("~");

    std::string camera_topic;
    std::string camera_info_topic;
    std::string camera_info_url;
    std::string img_path;
    std::string frame_id;
    float pub_rate;
    int start_sec;
    bool repeat;
    nh.param<std::string>("camera_topic", camera_topic, "/camera/image_raw");
    nh.param<std::string>("camera_info_topic", camera_info_topic, "/camera/camera_info");
    nh.param<std::string>("camera_info_url", camera_info_url, "");
    nh.param<std::string>("img_path", img_path, "");
    nh.param<std::string>("frame_id", frame_id, "");
    nh.param("pub_rate", pub_rate, 30.0f);
    nh.param("start_sec", start_sec, 0);
    nh.param("repeat", repeat, false);

    ROS_INFO("CTopic : %s", camera_topic.c_str());
    ROS_INFO("ITopic : %s", camera_info_topic.c_str());
    ROS_INFO("CI URL : %s", camera_info_url.c_str());
    ROS_INFO("Source : %s", img_path.c_str());
    ROS_INFO("Rate : %.1f", pub_rate);
    ROS_INFO("Start : %d", start_sec);
    ROS_INFO("Repeat : %s", repeat ? "yes" : "no");
    ROS_INFO("FrameID: %s", frame_id.c_str());

    camera_info_manager::CameraInfoManager camera_info_manager(nh);
    if (camera_info_manager.validateURL(camera_info_url))
    camera_info_manager.loadCameraInfo(camera_info_url);

    ros::Publisher img_pub = nh.advertise<sensor_msgs::Image>(camera_topic, 1);
    ros::Publisher info_pub = nh.advertise<sensor_msgs::CameraInfo>(camera_info_topic, 1);

    cv::VideoCapture vid_cap(img_path.c_str());
    if (start_sec > 0)
    vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec);

    ros::Rate rate(pub_rate);
    while (ros::ok())
    {
    cv::Mat img;
    if (!vid_cap.read(img))
    {
    if (repeat)
    {
    vid_cap.open(img_path.c_str());
    if (start_sec > 0)
    vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec);
    continue;
    }
    ROS_ERROR("Failed to capture frame.");
    ros::shutdown();
    }
    else
    {
    //ROS_DEBUG("Image: %dx%dx%d, %zu, %d", img.rows, img.cols, img.channels(), img.elemSize(), img.type() == CV_8UC3);
    if (img.type() != CV_8UC3)
    img.convertTo(img, CV_8UC3);
    // Convert image from BGR format used by OpenCV to RGB.
    cv::cvtColor(img, img, CV_BGR2RGB);

    auto img_msg = boost::make_shared<sensor_msgs::Image>();
    img_msg->header.stamp = ros::Time::now();
    img_msg->header.frame_id = frame_id;
    img_msg->encoding = "rgb8";
    img_msg->width = img.cols;
    img_msg->height = img.rows;
    img_msg->step = img_msg->width * img.channels();
    auto ptr = img.ptr<unsigned char>(0);
    img_msg->data = std::vector<unsigned char>(ptr, ptr + img_msg->step * img_msg->height);
    img_pub.publish(img_msg);

    if (camera_info_manager.isCalibrated())
    {
    auto info = boost::make_shared<sensor_msgs::CameraInfo>(camera_info_manager.getCameraInfo());
    info->header = img_msg->header;
    info_pub.publish(info);
    }
    }
    ros::spinOnce();
    rate.sleep();
    }

    return 0;
    }


    The video writing code (referred to this link):



    #include "opencv2/opencv.hpp"
    #include <iostream>

    using namespace std;
    using namespace cv;

    int main(){

    // Create a VideoCapture object and use camera to capture the video
    VideoCapture cap(0);

    // Check if camera opened successfully
    if(!cap.isOpened())
    {
    cout << "Error opening video stream" << endl;
    return -1;
    }

    // Default resolution of the frame is obtained.The default resolution is system dependent.
    int frame_width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
    int frame_height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);

    // Define the codec and create VideoWriter object.The output is stored in 'outcpp.avi' file.
    VideoWriter video("outcpp.avi",CV_FOURCC('M','J','P','G'),10,
    Size(frame_width,frame_height));
    while(1)
    {
    Mat frame;

    // Capture frame-by-frame
    cap >> frame;

    // If the frame is empty, break immediately
    if (frame.empty())
    break;

    // Write the frame into the file 'outcpp.avi'
    video.write(frame);

    // Display the resulting frame
    imshow( "Frame", frame );

    // Press ESC on keyboard to exit
    char c = (char)waitKey(1);
    if( c == 27 )
    break;
    }

    // When everything done, release the video capture and write object
    cap.release();
    video.release();

    // Closes all the windows
    destroyAllWindows();
    return 0;
    }


    Firstly, I tried incorporating video writing code (without grayscale) into publisher code. But it failed to run. All in all, image_publisher code should result a video after completing its task. What is the right way of doing this ?










    share|improve this question

























      0












      0








      0








      I am setting up a ros system to publish images with ros, c++ and opencv-2 for my drone. The code, below, is publishing raw images. While publishing, I want to write gray-scale images frame-by-frame with resolution of 1280 x 720 to record a video. I have found a readily available video writing code with opencv. However, I could not incorporate this code into image_publisher code. Here is the image_publisher code:



      #include <ros/ros.h>
      #include <camera_info_manager/camera_info_manager.h>
      #include <sensor_msgs/Image.h>
      #include <sensor_msgs/CameraInfo.h>
      #include <opencv2/opencv.hpp>

      int main(int argc, char **argv)
      {
      ROS_INFO("Starting image_pub ROS node...n");

      ros::init(argc, argv, "image_pub");
      ros::NodeHandle nh("~");

      std::string camera_topic;
      std::string camera_info_topic;
      std::string camera_info_url;
      std::string img_path;
      std::string frame_id;
      float pub_rate;
      int start_sec;
      bool repeat;
      nh.param<std::string>("camera_topic", camera_topic, "/camera/image_raw");
      nh.param<std::string>("camera_info_topic", camera_info_topic, "/camera/camera_info");
      nh.param<std::string>("camera_info_url", camera_info_url, "");
      nh.param<std::string>("img_path", img_path, "");
      nh.param<std::string>("frame_id", frame_id, "");
      nh.param("pub_rate", pub_rate, 30.0f);
      nh.param("start_sec", start_sec, 0);
      nh.param("repeat", repeat, false);

      ROS_INFO("CTopic : %s", camera_topic.c_str());
      ROS_INFO("ITopic : %s", camera_info_topic.c_str());
      ROS_INFO("CI URL : %s", camera_info_url.c_str());
      ROS_INFO("Source : %s", img_path.c_str());
      ROS_INFO("Rate : %.1f", pub_rate);
      ROS_INFO("Start : %d", start_sec);
      ROS_INFO("Repeat : %s", repeat ? "yes" : "no");
      ROS_INFO("FrameID: %s", frame_id.c_str());

      camera_info_manager::CameraInfoManager camera_info_manager(nh);
      if (camera_info_manager.validateURL(camera_info_url))
      camera_info_manager.loadCameraInfo(camera_info_url);

      ros::Publisher img_pub = nh.advertise<sensor_msgs::Image>(camera_topic, 1);
      ros::Publisher info_pub = nh.advertise<sensor_msgs::CameraInfo>(camera_info_topic, 1);

      cv::VideoCapture vid_cap(img_path.c_str());
      if (start_sec > 0)
      vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec);

      ros::Rate rate(pub_rate);
      while (ros::ok())
      {
      cv::Mat img;
      if (!vid_cap.read(img))
      {
      if (repeat)
      {
      vid_cap.open(img_path.c_str());
      if (start_sec > 0)
      vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec);
      continue;
      }
      ROS_ERROR("Failed to capture frame.");
      ros::shutdown();
      }
      else
      {
      //ROS_DEBUG("Image: %dx%dx%d, %zu, %d", img.rows, img.cols, img.channels(), img.elemSize(), img.type() == CV_8UC3);
      if (img.type() != CV_8UC3)
      img.convertTo(img, CV_8UC3);
      // Convert image from BGR format used by OpenCV to RGB.
      cv::cvtColor(img, img, CV_BGR2RGB);

      auto img_msg = boost::make_shared<sensor_msgs::Image>();
      img_msg->header.stamp = ros::Time::now();
      img_msg->header.frame_id = frame_id;
      img_msg->encoding = "rgb8";
      img_msg->width = img.cols;
      img_msg->height = img.rows;
      img_msg->step = img_msg->width * img.channels();
      auto ptr = img.ptr<unsigned char>(0);
      img_msg->data = std::vector<unsigned char>(ptr, ptr + img_msg->step * img_msg->height);
      img_pub.publish(img_msg);

      if (camera_info_manager.isCalibrated())
      {
      auto info = boost::make_shared<sensor_msgs::CameraInfo>(camera_info_manager.getCameraInfo());
      info->header = img_msg->header;
      info_pub.publish(info);
      }
      }
      ros::spinOnce();
      rate.sleep();
      }

      return 0;
      }


      The video writing code (referred to this link):



      #include "opencv2/opencv.hpp"
      #include <iostream>

      using namespace std;
      using namespace cv;

      int main(){

      // Create a VideoCapture object and use camera to capture the video
      VideoCapture cap(0);

      // Check if camera opened successfully
      if(!cap.isOpened())
      {
      cout << "Error opening video stream" << endl;
      return -1;
      }

      // Default resolution of the frame is obtained.The default resolution is system dependent.
      int frame_width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
      int frame_height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);

      // Define the codec and create VideoWriter object.The output is stored in 'outcpp.avi' file.
      VideoWriter video("outcpp.avi",CV_FOURCC('M','J','P','G'),10,
      Size(frame_width,frame_height));
      while(1)
      {
      Mat frame;

      // Capture frame-by-frame
      cap >> frame;

      // If the frame is empty, break immediately
      if (frame.empty())
      break;

      // Write the frame into the file 'outcpp.avi'
      video.write(frame);

      // Display the resulting frame
      imshow( "Frame", frame );

      // Press ESC on keyboard to exit
      char c = (char)waitKey(1);
      if( c == 27 )
      break;
      }

      // When everything done, release the video capture and write object
      cap.release();
      video.release();

      // Closes all the windows
      destroyAllWindows();
      return 0;
      }


      Firstly, I tried incorporating video writing code (without grayscale) into publisher code. But it failed to run. All in all, image_publisher code should result a video after completing its task. What is the right way of doing this ?










      share|improve this question














      I am setting up a ros system to publish images with ros, c++ and opencv-2 for my drone. The code, below, is publishing raw images. While publishing, I want to write gray-scale images frame-by-frame with resolution of 1280 x 720 to record a video. I have found a readily available video writing code with opencv. However, I could not incorporate this code into image_publisher code. Here is the image_publisher code:



      #include <ros/ros.h>
      #include <camera_info_manager/camera_info_manager.h>
      #include <sensor_msgs/Image.h>
      #include <sensor_msgs/CameraInfo.h>
      #include <opencv2/opencv.hpp>

      int main(int argc, char **argv)
      {
      ROS_INFO("Starting image_pub ROS node...n");

      ros::init(argc, argv, "image_pub");
      ros::NodeHandle nh("~");

      std::string camera_topic;
      std::string camera_info_topic;
      std::string camera_info_url;
      std::string img_path;
      std::string frame_id;
      float pub_rate;
      int start_sec;
      bool repeat;
      nh.param<std::string>("camera_topic", camera_topic, "/camera/image_raw");
      nh.param<std::string>("camera_info_topic", camera_info_topic, "/camera/camera_info");
      nh.param<std::string>("camera_info_url", camera_info_url, "");
      nh.param<std::string>("img_path", img_path, "");
      nh.param<std::string>("frame_id", frame_id, "");
      nh.param("pub_rate", pub_rate, 30.0f);
      nh.param("start_sec", start_sec, 0);
      nh.param("repeat", repeat, false);

      ROS_INFO("CTopic : %s", camera_topic.c_str());
      ROS_INFO("ITopic : %s", camera_info_topic.c_str());
      ROS_INFO("CI URL : %s", camera_info_url.c_str());
      ROS_INFO("Source : %s", img_path.c_str());
      ROS_INFO("Rate : %.1f", pub_rate);
      ROS_INFO("Start : %d", start_sec);
      ROS_INFO("Repeat : %s", repeat ? "yes" : "no");
      ROS_INFO("FrameID: %s", frame_id.c_str());

      camera_info_manager::CameraInfoManager camera_info_manager(nh);
      if (camera_info_manager.validateURL(camera_info_url))
      camera_info_manager.loadCameraInfo(camera_info_url);

      ros::Publisher img_pub = nh.advertise<sensor_msgs::Image>(camera_topic, 1);
      ros::Publisher info_pub = nh.advertise<sensor_msgs::CameraInfo>(camera_info_topic, 1);

      cv::VideoCapture vid_cap(img_path.c_str());
      if (start_sec > 0)
      vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec);

      ros::Rate rate(pub_rate);
      while (ros::ok())
      {
      cv::Mat img;
      if (!vid_cap.read(img))
      {
      if (repeat)
      {
      vid_cap.open(img_path.c_str());
      if (start_sec > 0)
      vid_cap.set(CV_CAP_PROP_POS_MSEC, 1000.0 * start_sec);
      continue;
      }
      ROS_ERROR("Failed to capture frame.");
      ros::shutdown();
      }
      else
      {
      //ROS_DEBUG("Image: %dx%dx%d, %zu, %d", img.rows, img.cols, img.channels(), img.elemSize(), img.type() == CV_8UC3);
      if (img.type() != CV_8UC3)
      img.convertTo(img, CV_8UC3);
      // Convert image from BGR format used by OpenCV to RGB.
      cv::cvtColor(img, img, CV_BGR2RGB);

      auto img_msg = boost::make_shared<sensor_msgs::Image>();
      img_msg->header.stamp = ros::Time::now();
      img_msg->header.frame_id = frame_id;
      img_msg->encoding = "rgb8";
      img_msg->width = img.cols;
      img_msg->height = img.rows;
      img_msg->step = img_msg->width * img.channels();
      auto ptr = img.ptr<unsigned char>(0);
      img_msg->data = std::vector<unsigned char>(ptr, ptr + img_msg->step * img_msg->height);
      img_pub.publish(img_msg);

      if (camera_info_manager.isCalibrated())
      {
      auto info = boost::make_shared<sensor_msgs::CameraInfo>(camera_info_manager.getCameraInfo());
      info->header = img_msg->header;
      info_pub.publish(info);
      }
      }
      ros::spinOnce();
      rate.sleep();
      }

      return 0;
      }


      The video writing code (referred to this link):



      #include "opencv2/opencv.hpp"
      #include <iostream>

      using namespace std;
      using namespace cv;

      int main(){

      // Create a VideoCapture object and use camera to capture the video
      VideoCapture cap(0);

      // Check if camera opened successfully
      if(!cap.isOpened())
      {
      cout << "Error opening video stream" << endl;
      return -1;
      }

      // Default resolution of the frame is obtained.The default resolution is system dependent.
      int frame_width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
      int frame_height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);

      // Define the codec and create VideoWriter object.The output is stored in 'outcpp.avi' file.
      VideoWriter video("outcpp.avi",CV_FOURCC('M','J','P','G'),10,
      Size(frame_width,frame_height));
      while(1)
      {
      Mat frame;

      // Capture frame-by-frame
      cap >> frame;

      // If the frame is empty, break immediately
      if (frame.empty())
      break;

      // Write the frame into the file 'outcpp.avi'
      video.write(frame);

      // Display the resulting frame
      imshow( "Frame", frame );

      // Press ESC on keyboard to exit
      char c = (char)waitKey(1);
      if( c == 27 )
      break;
      }

      // When everything done, release the video capture and write object
      cap.release();
      video.release();

      // Closes all the windows
      destroyAllWindows();
      return 0;
      }


      Firstly, I tried incorporating video writing code (without grayscale) into publisher code. But it failed to run. All in all, image_publisher code should result a video after completing its task. What is the right way of doing this ?







      c++ opencv ros






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 6:25









      Ender AyhanEnder Ayhan

      877




      877
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You cannot send opencv Mat inside ros topic system since Image topic has another coding system.



          You need to use cv_bridge to convert images that you got from Opencv to ROS-image Format



          there are some details and examples Here






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54002104%2fhow-to-incorporate-videowriter-code-into-image-publisher-code-of-ros%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You cannot send opencv Mat inside ros topic system since Image topic has another coding system.



            You need to use cv_bridge to convert images that you got from Opencv to ROS-image Format



            there are some details and examples Here






            share|improve this answer




























              0














              You cannot send opencv Mat inside ros topic system since Image topic has another coding system.



              You need to use cv_bridge to convert images that you got from Opencv to ROS-image Format



              there are some details and examples Here






              share|improve this answer


























                0












                0








                0







                You cannot send opencv Mat inside ros topic system since Image topic has another coding system.



                You need to use cv_bridge to convert images that you got from Opencv to ROS-image Format



                there are some details and examples Here






                share|improve this answer













                You cannot send opencv Mat inside ros topic system since Image topic has another coding system.



                You need to use cv_bridge to convert images that you got from Opencv to ROS-image Format



                there are some details and examples Here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 4 at 12:47









                Mohammad AliMohammad Ali

                402310




                402310
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54002104%2fhow-to-incorporate-videowriter-code-into-image-publisher-code-of-ros%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

                    Npm cannot find a required file even through it is in the searched directory