Hello @shankk,
Terminal Check:
$ rostopic list
It will give you the list of topics been published.
$ rostopic echo /image_publish_topic_name
You can get an array of integers with random numbers that means your image is published and it is perfect.
Your output can be in this form described in the above image.
Browser Check:
You can view this stream in your browser.
I think a browser will be a good Substitute.
import rclpy
from rclpy.node import Node
from cv_bridge import CvBridge
from sensor_msgs.msg import Image
class ImageNode(Node):
def __init__(self):
super().__init__("image_save_jpg")
self.subscriber_ = self.create_subscription(
Image, "Your_image_channel_name", self.callback, 10)
self.get_logger().info("Images saved has been started.")
self.counter = 0
def callback(data):
br = CvBridge()
rospy.loginfo("receiving video frame")
# Convert ROS Image message to OpenCV image
current_frame = br.imgmsg_to_cv2(data)
# saved image to jpg , counter for unique name
cv2.imwrite("path"+self.counter+".jpeg", img)
self.counter += 1
def main(args=None):
rclpy.init(args=args)
node = SmartphoneNode()
rclpy.spin(node)
rclpy.shutdown()
if __name__ == "__main__":
main()
I hope this helps you,