publishing a cv2 image with cv_bridge
I wrote a basic node that reads an image from a local folder and publishes it. However, the topic is empty, i can not display the image when i use the image viewer. The cv2 image is being loaded correctly because i can display it with cv2.imshow function so the problem is the way i convert it to imgmsg.
I am not sure if this line works as it should:
image_message = self.bridge.cv2_to_imgmsg(cv_image, "passthrough")
The whole node is as simple as this:
class image_publisher:
def __init__(self):
self.image_pub = rospy.Publisher("image_topic",Image)
cv_image = cv2.imread('/Pictures/image.png',0)
self.bridge = CvBridge()
image_message = self.bridge.cv2_to_imgmsg(cv_image, "passthrough")
self.image_pub.publish(image_message)