How can i bridge and display images from realsense d435 camera?
I am a beginner in ros. I am looking to get image frames from an Intel Realsense D435 camera, bridge and show the image (with opencv) . At the same time, I look to print/ log out the information from the camera. After running code, the program continuously runs (due to rospy.spin() function) but does not print out anything.
Where could I be going wrong with the code? Could someone please explain a bit on how to use the ros messages in a python code. I am writing a subscriber node.'
class Depth_Retriever():
def __init__(self):
self.bridge = CvBridge()
self.sub = rospy.Subscriber('/camera/depth/image_rect_raw',Image,callback)
def callback(self,ros_pics):
try:
my_image = self.bridge.imgmsg_to_cv2(ros_pics, encoding = "passthrough")
except CvBridgeError as e:
print("CvBridge could not convert images from realsense to opencv")
height,width, channels = my_image.shape
my_height = my_image.shape[0]
print(my_height)
self.vert_len = ros_pics.height # retrieve height information from Image msg
print(self.vert_len)
def main():
rospy.init_node("Depth",anonymous = True)
rospy.spin()
if __name__ == '__main__':
main()
Thank you for help in advance.