Subscribe to Kinect depth intensity value (not mm)
Greetings,
I would like to get Kinect's depth value for each pixel as intensity (0-255) as put them in an array. Right now I am subscribing to /camera/depth/image_raw
. When I rostopich echo
I get that, but when I subscribe to it with a callback, I get values in mm. My callback is:
void MyClass::rgbdSubscriberCallback(const sensor_msgs::ImageConstPtr& msg2) {
cv_bridge::CvImagePtr cv_ptr; Eigen::MatrixXd A(480, 640);
try{
cv_ptr=cv_bridge::toCvCopy(msg2,sensor_msgs::image_encodings::TYPE_16UC1); //16UC1, sensor_msgs::image_encodings::BRG8
cv::imshow("Depth Image",cv_ptr->image); cv::waitKey(30); // display image
for(int i=0; i<(cv_ptr->image).rows; i++) {for(int j=0; j<(cv_ptr->image).cols; j++) {
A(i,j)=(cv_ptr->image.at<short int>(cv::Point(i,j)));///255.0;
}
std::cout<<"Maximum Kinect Depth is: "<<A.array().maxCoeff()<<std::endl; // >30000
}
catch (cv_bridge::Exception& e) {ROS_ERROR("cv_bridge exception: Could not convert from '%s' to '16UC1'.", e.what());}
}
I think I am serializing the data to make it displayable in cv::Mat, but I do not want to use this mat's pixel values, I want the (0-255) intensities from the topic I mentioned. I am subscribing with the openni driver and I've seen people complain their values are (0-255), but this is exactly what I want.
Thank you.
seems like an encoding issue, just check the encoding value of your message and use same encoding in your node