Skip to content

Commit 6cb66a0

Browse files
committed
fix bug arrived due to depth conversion to SI units
1 parent f089d7f commit 6cb66a0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

include/ros_openpose/cameraReader.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ namespace ros_openpose
115115
// K.at(5) = intrinsic.ppy
116116

117117
// our depth frame type is 16UC1 which has unsigned short as an underlying type
118-
auto depth = mDepthImageUsed.at<unsigned short>(static_cast<int>(pixelY), static_cast<int>(pixelX));
118+
// auto depth = mDepthImageUsed.at<unsigned short>(static_cast<int>(pixelY), static_cast<int>(pixelX));
119+
auto depth = mDepthImageUsed.at<float>(static_cast<int>(pixelY), static_cast<int>(pixelX));
119120

120121
// no need to proceed further if the depth is zero or less than zero
121122
// the depth represents the distance of an object placed infront of the camera

src/cameraReader.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ namespace ros_openpose
8282
// however I found that it is only changing encoding.
8383
// therefore in case of '16UC1' encoding (depth values are in millimeter),
8484
// a manually conversion from millimeter to meter is required.
85-
mDepthImage = (depthMsg->encoding == sensor_msgs::image_encodings::TYPE_16UC1) ?
86-
depthPtr->image * 0.001f : // convert to meter (SI units)
87-
depthPtr->image; // no conversion needed
85+
if (depthMsg->encoding == sensor_msgs::image_encodings::TYPE_16UC1)
86+
depthPtr->image.convertTo(mDepthImage, CV_32FC1, 0.001f); // convert to meter (SI units)
87+
else
88+
mDepthImage = depthPtr->image; // no conversion needed
8889
}
8990
catch (cv_bridge::Exception& e)
9091
{

0 commit comments

Comments
 (0)