ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Ok one way to solve this is using cv_bridge. It uses 16UC1 encoding.

void dataCallback(const sensor_msgs::ImagePtr & msg) { vector<unsigned short=""> depth; cv_bridge::CvImagePtr cv_depth = cv_bridge::toCvCopy(msg,sensor_msgs::image_encodings::TYPE_16UC1); for(int i=0; i<cv_depth->image.rows; i++) { for(int j=0; j<cv_depth->image.cols; j++) { unsigned short dd = *(cv_depth->image.ptr<unsigned short="">(i,j)); depth.push_back(dd); } } }

Cheers

Ok one way to solve this is using cv_bridge. It uses 16UC1 encoding.

void dataCallback(const sensor_msgs::ImagePtr & msg) { {

vector<unsigned short=""> short> depth;
 cv_bridge::CvImagePtr cv_depth = cv_bridge::toCvCopy(msg,sensor_msgs::image_encodings::TYPE_16UC1);
  for(int i=0; i<cv_depth->image.rows; i++) {
   for(int j=0; j<cv_depth->image.cols; j++) {
     unsigned short dd = *(cv_depth->image.ptr<unsigned short="">(i,j));
    short>(i,j));
    depth.push_back(dd);
   }
 }
 

}

Cheers