Hi, I wrote a subscriber to subscribe the image message send from the topic /gi/simulation/left/image_raw and convert it using CV.bridge(). However, the problem is that, this subscriber only shows a single frame of image when the subscriber starts. Is there a way that my subscriber can achieve the similar effect when I using rviz to subscribe to the same topic. In simple, how to achieve real time image capture by using the subscriber. The code for subscriber is shown below: Thank you for the help.
#!/usr/bin/env python
import rospy
import sys
import cv2
from cv_bridge import CvBridge
from sensor_msgs.msg import Image
def process_image(msg):
bridge = CvBridge()
img = bridge.imgmsg_to_cv2(msg, "bgr8")
cv2.imshow("image",img)
cv2.waitKey(0)
if __name__ == '__main__':
while not rospy.is_shutdown():
rospy.init_node('image_sub')
rospy.loginfo('image_sub node started')
rospy.Subscriber("/gi/simulation/left/image_raw", Image, process_image)
rospy.spin()
Originally posted by mingcheng on ROS Answers with karma: 3 on 2019-10-02
Post score: 0