Robotics StackExchange | Archived questions

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

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 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 rosrun this node:

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

This error has been reported here but there is no clear answer for that and I do not know what to do. I would appreciate it if someone help me out. (The version of ros is hydro)

Asked by A.M Dynamics on 2015-01-16 19:50:27 UTC

Comments

Had the same problem when I overloaded the usb port where the kinect was connected due to the usb hub been full of phidget controllers and other sensors. What is your setup?

Asked by kokirits on 2015-01-17 06:26:27 UTC

Answers