'Segmentation fault (core dumped)' error for opencv with kinect [closed]
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)
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?