그래서 결국, 나는 당신이 여기에서 볼 수있는 솔루션, 발견
:
def Depthcallback(self,msg_depth): # TODO still too noisy!
try:
# The depth image is a single-channel float32 image
# the values is the distance in mm in z axis
cv_image = self.bridge.imgmsg_to_cv2(msg_depth, "32FC1")
# Convert the depth image to a Numpy array since most cv2 functions
# require Numpy arrays.
cv_image_array = np.array(cv_image, dtype = np.dtype('f8'))
# Normalize the depth image to fall between 0 (black) and 1 (white)
# http://docs.ros.org/electric/api/rosbag_video/html/bag__to__video_8cpp_source.html lines 95-125
cv_image_norm = cv2.normalize(cv_image_array, cv_image_array, 0, 1, cv2.NORM_MINMAX)
# Resize to the desired size
cv_image_resized = cv2.resize(cv_image_norm, self.desired_shape, interpolation = cv2.INTER_CUBIC)
self.depthimg = cv_image_resized
cv2.imshow("Image from my node", self.depthimg)
cv2.waitKey(1)
except CvBridgeError as e:
print(e)
그러나, 결과는 내가 ROS의 image_view 노드에서 얻을 것과 같은 완벽한 아니지만, 그것을 여전히 꽤 받아 들일 수 있습니다!
적어도 C++ 버전에서 OpenCV는 '32FC1'이미지를 표시하는 데별로 좋지 않습니다. 적절한 범위 (0 ~ 255)로 스케일링하여 표시 목적으로 '8UC1'로 변환하십시오. – mikkola
[여기] (https://answers.ros.org/question/58902/how-to-store-the-depth-data-from-kinectcameradepth_registreredimage_raw-as-gray-scale) 지침에 따라 (일종의) 작업을 수행했습니다. -영상/). 문제는 그 결과가 ROS의 ** image_view ** 패키지에서 ** image_view ** 노드로 얻은 이미지와 비교할 때 꽤 잡음이라는 것입니다. – lefos99