Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

segfault on cv::imshow("Image window", cv_ptr->image)

Hi,

When I try to show an image with

cv_ptr->image.data = image_in_mat.data;
cv::namedWindow("Image window");
cv::imshow("Image window", cv_ptr->image);

I get a segfault on the last line while it compiles fine. The segfault tells it's a memory issue but why ?

segfault on cv::imshow("Image window", cv_ptr->image)

Hi,

When I try to show an image with

cv_ptr->image.data = image_in_mat.data;
cv::namedWindow("Image window");
cv::imshow("Image window", cv_ptr->image);

I get a segfault on the last line while it compiles fine. The segfault tells it's a memory issue but why ?

Ok, I tried many things now and I have this piece of code and 2 points of failure (imshow and publish) I don't get:

try
{
    cv::imshow(OPENCV_WINDOW, cv_ptr->image);
}
catch (cv::Exception& cv_ex)
{
    ROS_ERROR("cv exception: %s", cv_ex.what());
    return;
}
cv::waitKey(0);
image_pub.publish(cv_ptr->toImageMsg());

Why are these causing segfaults ?