'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.
The segfault is obvious: your depth image is empty and you try to access a non existing element. What you show is no ros-node. Why don't you use one of the available openni-ros-nodes like openni_camera?
Thanks. but i could not find any ros-node for kinect. I know openni_camera but I do not know how to apply this driver in my node. Is there any example?