Rosanswers logo


This is Kathir. While using cv and ros bridge, I am not able to ardrone's camera's output in my computer. Could somebody help me to fix this ?

Should I have to change the topics in publisher or subscriber ? Why am I not getting the video feed ??

How to get video stream ? As per the code, imshow() should produce a window but in my code, nothing is happening.

#!/usr/bin/env python
import roslib
import sys
import rospy
import cv2
from std_msgs.msg import String
from sensor_msgs.msg import Image  
from cv_bridge import CvBridge, CvBridgeError

class image_converter:

 def __init__(self):
   print('Image converter constructor ')
   self.image_pub = rospy.Publisher("image_topic_2",Image,queue_size=1)

   self.bridge = CvBridge()
   self.image_sub = rospy.Subscriber("image_topic",Image,self.callback)

 def callback(self,data):
     cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
   except CvBridgeError as e:

   (rows,cols,channels) = cv_image.shape
   if cols > 60 and rows > 60 :
     cv2.circle(cv_image, (50,50), 10, 255)
   print('Above imshow function')
   cv2.imshow("Image window", cv_image)

     self.image_pub.publish(self.bridge.cv2_to_imgmsg(cv_image, "bgr8"))
   except CvBridgeError as e:

def main(args):
 ic = image_converter()
 print('inside main ')
 rospy.init_node('image_converter', anonymous=True)
 except KeyboardInterrupt:
   print("Shutting down")

 if __name__ == '__main__':
   print('Function call started ')

rostopic hz :

 rostopic hz /ardrone/image_raw
   subscribed to [/ardrone/image_raw]
   average rate: 31.109
      min: 0.011s max: 0.051s std dev: 0.00873s window: 31
   average rate: 31.077
      min: 0.011s max: 0.059s std dev: 0.00947s window: 62
   average rate: 30.875
      min: 0.011s max: 0.061s std dev: 0.00909s window: 92
   average rate: 30.508

rosgraph is :


Originally posted by Kathir on ROS Answers with karma: 21 on 2017-01-21

Post score: 0

Original comments

Comment by Kathir on 2017-02-01:
@Mani : Can you help me to fix it ?


1 Answer 1


Rosanswers logo

In your subscriber you need to subscribe to the actual topic name not image_topic, that doesn't exist. For example, I setup my subscriber as follows:

image_sub = rospy.Subscriber("ardrone/image_raw", Image, image_cb)

Then, in your image_cb function you can do what you want with your image. In summary, the reason why you're not getting anything is because you're subscribed to a topic that doesn't publish an image. In fact, it doesn't publish anything. ROS let's you subscribe to topics that don't currently exist and it won't even tell you that. So, you have to be careful that you're actually subscribing to the appropriate topics.

You should echo the topic using rostopic echo <topic_name> to ensure that something is being published along that topic and run rostopic info <topic_name> to get information about that topic such as what nodes are publishing and subscribing to it and what data (message) type is carried along that topic.

Originally posted by jayess with karma: 6155 on 2017-03-17

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.