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

klein_homer's profile - activity

2019-05-29 20:16:59 -0500 received badge  Taxonomist
2016-04-11 00:34:18 -0500 received badge  Popular Question (source)
2016-04-08 03:25:34 -0500 asked a question Segmentation fault on Ubuntu, but not on Raspbian

Hello Guys,

I'm using a VM with Ubuntu 14.04 running on Win7 for programming with QTcreator. The code should run on a Raspberry Pi with Raspbian Jessie.

I just wrote this code for a subscriber to an imagestream. It compiles without errors, but if I run it per rosrun on Ubuntu it stopps running at the line:

cv::imshow("view", image)

with the Error Segmentation fault (core dumped).

If I copy the package to the Raspberry and compile it, it runs without any problems. Can anyone help me with it? It's very annoying to copy the wohle package alle the time, to check if it's working.

On both Systems run ROS Indigo and OpenCV 2

#include <ros/ros.h>
#include <raspicam/raspicam_cv.h>
#include <cv_bridge/cv_bridge.h>
#include <image_transport/image_transport.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <sensor_msgs/image_encodings.h>
#include <sensor_msgs/Image.h>
using namespace cv;
using namespace std;

void imageCallback (const sensor_msgs::ImageConstPtr& msg )
{    
   Mat image;
   image = cv_bridge::toCvCopy(msg, msg->encoding.c_str())->image;

   if (!image.empty())
   {
         cv::imshow("view", image);
    }
    else
   {
       ROS_ERROR ("no Data");
   }

}

int main ( int argc,char **argv )
{
   ros::init(argc, argv, "process_image");
   ros::NodeHandle n;

   cv::namedWindow("view");
   cv::startWindowThread();

   image_transport::ImageTransport it(n);
   image_transport::Subscriber pub_image_sub = it.subscribe("image_pipe", 1, imageCallback);

   ros::spin();

   cv::destroyWindow("view");
}
2016-03-17 05:13:50 -0500 received badge  Enthusiast