ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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
2 | No.2 Revision |
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