Ask Your Question

chetan3061's profile - activity

2015-04-16 16:06:21 -0600 commented question segmentation fault on cv::imshow("windowName", cvImagePtr->image)

it gives me the rows and columns when i printed out mat.rows and mat.columns.

2015-04-16 15:52:59 -0600 commented answer segfault on cv::imshow("Image window", cv_ptr->image)

this is what i used and it gave me the segmentation fault

void callback(const sensor_msgs::ImageConstPtr& msg) {

Mat mat;

cv_bridge::CvImagePtr cvImagePtr; try {

    cvImagePtr = cv_bridge::toCvCopy(msg,sensor_msgs::image_encodings::BGR8);

     mat = cvImagePtr->image;

    //std::cout<<mat.rows<<"\n";


     } 

catch (cv_bridge::Exception &e) {

   ROS_ERROR("cv_bridge exception:  %s", e.what());

}

    imshow("windowName", cvImagePtr->image);

    cv::waitKey(3);

    destroyWindow("windowName");

}

2015-04-16 00:07:44 -0600 commented answer segfault on cv::imshow("Image window", cv_ptr->image)

i have the same problem, what did you do exactly to fix it.

2015-04-16 00:07:42 -0600 asked a question segmentation fault on cv::imshow("windowName", cvImagePtr->image)
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

void callback(const sensor_msgs::ImageConstPtr& msg) { 

    cv_bridge::CvImagePtr cvImagePtr; try {

        cvImagePtr = cv_bridge::toCvCopy(msg);

        //cv::Mat &mat = cvImagePtr->image;

        cv::imshow("windowName", cvImagePtr->image);

        cv::destroyWindow("windowName");

         } 

    catch (cv_bridge::Exception &e) {

       ROS_ERROR("cv_bridge exception:  %s", e.what());

}

}
int main(int argc, char **argv) {

ros::init(argc, argv, "nodeName"); 

cv::namedWindow("windowName");

ros::NodeHandle nh;

image_transport::ImageTransport it(nh); 

image_transport::Subscriber sub = it.subscribe("/ardrone/image_raw", 1, callback); 

ros::spin();

}