Ask Your Question
0

segmentation fault on iplimage

asked 2014-06-13 08:49:51 -0600

hvn gravatar image

Hi,

I have this piece of code that compiles well but ends with segmentation fault:

IplImage* image_in;    
cv_bridge::CvImagePtr cv_im_ptr;   
image_in->imageData = (char *) cv_im_ptr->image.data;

So far I fail to see why this goes wrong. Hints and suggestions welcome.

edit retag flag offensive close merge delete

Comments

you probably should use a cv::Mat instead of an IplImage

really, they're trying to get rid of the c-api since 2010

berak gravatar imageberak ( 2014-06-13 09:00:16 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-06-13 09:01:52 -0600

unxnut gravatar image

You have not allocated any space for your image_in. Replace the first line with:

IplImage * image_in = new IplImage;

But it will be better to use cv::Mat instead of IplImage.

edit flag offensive delete link more

Comments

1

hey, not new, but cvCreateImage(...) , it's C !

berak gravatar imageberak ( 2014-06-13 09:07:26 -0600 )edit

OK, thanks. However, both with "new IplImage" and "IplImage* image_in = cvCreateImage(cvSize(320, 240), 8, 1);" I get the same error.

hvn gravatar imagehvn ( 2014-06-13 14:46:01 -0600 )edit

The manual says that you should not assign imageData directly. Please check http://docs.opencv.org/modules/core/doc/old_basic_structures.html?highlight=iplimage#IplImage. Also, you seem to be modifying the address pointed to by imageData. That is not correct either.

unxnut gravatar imageunxnut ( 2014-06-13 16:18:04 -0600 )edit

Thank you.

hvn gravatar imagehvn ( 2014-06-15 05:21:35 -0600 )edit

Question Tools

Stats

Asked: 2014-06-13 08:49:51 -0600

Seen: 336 times

Last updated: Jun 13 '14