Segmentation fault on Ubuntu, but not on Raspbian

asked 2016-04-08 03:23:59 -0500

klein_homer gravatar image

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);
       ROS_ERROR ("no Data");


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


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


edit retag flag offensive close merge delete


Compiled and ran your code on Ubuntu 14.04 no problem, but I'm not running a VM. If you replace the cv::imshow("view", image); with a print statement instead do you still get the segmentation fault? Maybe it's related to rendering within the VM with OpenCV?

jacobperron gravatar image jacobperron  ( 2016-04-08 13:50:38 -0500 )edit