video stream needed for ARDRONE
Hi,
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):
try:
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
except CvBridgeError as e:
print(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)
cv2.waitKey(3)
try:
self.image_pub.publish(self.bridge.cv2_to_imgmsg(cv_image, "bgr8"))
except CvBridgeError as e:
print(e)
def main(args):
ic = image_converter()
print('inside main ')
rospy.init_node('image_converter', anonymous=True)
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
cv2.destroyAllWindows()
if __name__ == '__main__':
print('Function call started ')
main(sys.argv)
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 :
/ardrone/image_raw/compressedDepth/set_parameters
/ardrone_driver/set_logger_level
/ardrone/front/image_raw/compressedDepth/set_parameters
/ardrone/setledanimation
/ardrone/image_raw/theora/set_parameters
/image_converter_3034_1485929043890/set_logger_level
/ardrone/front/image_raw/compressed/set_parameters
/ardrone/front/set_camera_info
/ardrone/setflightanimation
/ardrone/setrecord
/image_converter_3034_1485929043890/get_loggers
/rosout/set_logger_level
/ardrone/image_raw/compressed/set_parameters
/ardrone_driver/get_loggers
/ardrone/togglecam
/ardrone/flattrim
/ardrone/bottom/image_raw/theora/set_parameters
/ardrone/bottom/set_camera_info
/ardrone/bottom/image_raw/compressed/set_parameters
/ardrone/bottom/image_raw/compressedDepth/set_parameters
/rosout/get_loggers
/ardrone/setcamchannel
/ardrone/front/image_raw/theora/set_parameters
@Mani : Can you help me to fix it ?