Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

'Segmentation fault (core dumped)' error for opencv with kinect & ROS

Dear All,

I am trying to get depth values and then convert them to millimeter for distance measuring (Although I am not sure if it is a good way or not). Anyway, this is the code I am using as a node in a ROS's catkin package:

int main( int argc, char* argv[] )

{

    VideoCapture capture(CV_CAP_OPENNI); 

   for(;;)

   { Mat depthMap;

     Mat bgrImage;

    capture.grab();

     capture.retrieve( depthMap, CV_CAP_OPENNI_DEPTH_MAP ); // Depth values in mm (CV_16UC1)

    capture.retrieve( bgrImage, CV_CAP_OPENNI_BGR_IMAGE );

    cout << "rows: " << depthMap.rows << " cols: " << depthMap.cols << endl;
    cout << "depth: " << depthMap.at<unsigned short>(0,0) << endl;

   /* imshow("RGB image", bgrImage);*/

    if( waitKey( 30 ) >= 0 )

break;
 }
  return 0;
  }

My problem is that I receive this error when I use rosrun to run this node:

rows: 0 cols: 0
Segmentation fault (core dumped)

I have already checked some topics about this problem here bit I am still confused and I could solve this error. I would appreciet it if you help me out.