Convert raw depth data from depth image to meters (Kinect v2)
Hello,
I am using Kinect v2 and I am trying to convert its raw values from the depth image to meters. I am subscribing to the image_depth_rect
topic. Firstly, I would like to ask if I need to calibrate the depth image with the color image I get from the sensor ?
I have searched for similar issues, but all I found is info about the sensor from the previous version. I also found some stuff outside from ROS which didn't help.
Is there an equation to convert the unsigned 16bit data that I get in meters?
Currently I am using the following callback function for the depth image topic:
void kinectdepthCallback(const sensor_msgs::ImageConstPtr& msg2){
cv_bridge::CvImagePtr cv_ptr2;
try{
cv_ptr2 = cv_bridge::toCvCopy(msg2, sensor_msgs::image_encodings::TYPE_16UC1);
}
catch (cv_bridge::Exception& e){
ROS_ERROR("Could not convert from '%s' to '16UC1'.", e.what());
return;
}
cv::imshow("Depth Image",cv_ptr2->image);
cv::waitKey(20);
ROS_INFO("The object is in depth: %d",cv_ptr2->image.at<int>(x,y));
}
where (x,y) are some points of the detected object but I get wrong results.
To be more specific, I detect an orange marker but I cannot get its depth from the Kinect v2. I present the following images:
Color image with detected object:
Thresholded image:
Depth image is black:
Terminal messages from the above code:
I don't know what is wrong and I get zero depth even if the object is at approximately a 19 - 20 cm. I have tried to find the depth in bigger depths like 60 cm, but I was still getting 0 results.
Thanks for answering in advance,
Chris
does this help: http://answers.ros.org/question/16061... ?
In the example he just gets the raw data from kinect. I am using a kinect v2 and I am trying to make this data into meters. Unless Kinect v2 and its tools do this automatically, which is something I don't know...
Hi, I have simple python code for detecting and tracking the object based on color by using webcam. My question is how can I use the same code but by using Kinect v2 (NOT webcam).
can u plz help with this, and tell me how to use Kinect v2 as webcam in linux? or share your method ?
You want to use Kinect v2 in linux or in ROS? This topic has to do with integrating Kinect v2 into ROS as a node and manipulating its data with
cv_bridge
. Take a look here for that.If you want to use Kinect v2 in linux, you need to install the drivers from here and ask in another more relative forum for that. A simple googling of your issue will also help you with your problem also.
Good luck!
For integrating Kinect v2 into ROS, also check this.
Thanks for you guys, I know how to use kinect v2 with ROS, but I don't know how to use it as a webcam, because my code is in python and using webcam, but I want to modify it so it would use kinect v2 not webcam. That's why I ask Chris to pass the code, cuz its for color detection by using kinect v