Created
May 14, 2019 01:20
-
-
Save DonHaul/a690fc8fc8d91522485783e180c076ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rospy | |
from sensor_msgs.msg import Image | |
import numpy as np | |
import cv2 | |
from cv_bridge import CvBridge | |
rospy.init_node('my_node', anonymous=True) | |
topicRGB = "/rgb/image_color" | |
topicDepth ="/depth_registered/image_raw" | |
rgbmsg = rospy.wait_for_message(cameraName + topicRGB, Image) | |
depth_registeredmsg = rospy.wait_for_message(cameraName + topicDepth, Image) | |
#bridge to convert ROS image into numpy array | |
br = CvBridge() | |
#converts ros img to numpy array | |
rgb = br.imgmsg_to_cv2(rgbros, desired_encoding="bgr8") | |
depth= br.imgmsg_to_cv2(depthros, desired_encoding="passthrough") | |
cv2.imshow('image',rgb) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() | |
cv2.imshow('image',depth) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment