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

asked 2015-01-16 18:50:27 -0600

A.M Dynamics gravatar image

updated 2015-01-17 13:47:30 -0600

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)

edit retag flag offensive reopen merge delete

Closed for the following reason OpenCV Question: THe OpenCV community prefers to answer questions at: http://answers.opencv.org/questions/ by tfoote
close date 2015-01-18 03:07:29.163692

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?

kokirits gravatar image kokirits  ( 2015-01-17 05:26:27 -0600 )edit