Rosanswers logo

Hello all.

I am using the AR.Drone 2.0 and setup the ardrone_autonomy driver link:[text](https:// github.com/AutonomyLab/ardrone_autonomy) and I also installed ROS from the official website (fuerte). I am using Ubuntu 12.0.4 also.

What I would like to do is be able to write a program that takes the camera stream from the AR.Drone 2.0 and sends them to openCV. openCV is installed with my ROS distribution inside the vision_opencv folder (it has cv_bridge and openCV2 which is what I would like to use).

I have played around with openCV2 from the openCV website for single images so openCV seems to work well. I am slightly confused on how to solve the above problem because I am new to ROS and openCV. I have followed the tutorials but they do not teach me how to deal with this problem as far as I understand.

I think there are two problems to what I want to do. 1) send camera images directly from the AR.Drone to ROS. 2) send images from ROS format to openCV and do this the other way around. I read that cv_bridge does this but slightly overwhelmed by it.

Ideally, I want a GUI with the images going into openCV but how will I know if the images are successfully going into openCV? openCV is just a package and doesnt seem to have an interface like MATLAB so I want to also understand what kind of output I should expect to know if the program is working correctly. Any help will be great!

Originally posted by MichaelJ on ROS Answers with karma: 15 on 2013-09-14

Post score: 1

Original comments

Comment by davinci on 2013-09-15:
How are the images currently streamed? Can it be used as a sort of IP cam? OpenCV has support for IP cams.

Comment by MichaelJ on 2013-09-15:
Currently, the images stream using Qt from the code provided by the ardrone_tutorials. The ardrone sends the images through the generates an ad-Hoc wifi. What does IP stand for?

Comment by Pedro_85 on 2013-10-30:
Do you want to get the stream from the AR.Drone in order to process it with OpenCV?


1 Answer 1


Rosanswers logo

The AR.Drone Autonomy package publishes the video captured by the cameras in the topic /ardrone/image_raw topic. I have prepared a simple code that works with opencv so that you get the idea:

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <sensor_msgs/image_encodings.h>
#include <cv_bridge/cv_bridge.h>
#include <cv_bridge/CvBridge.h>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
static const char WINDOW[]="RGB Image";
static const char WINDOW2[]="Gray Image";

void process(const sensor_msgs::ImageConstPtr& cam_image){
   sensor_msgs::CvBridge bridge; 
   Mat img_rgb = bridge.imgMsgToCv(cam_image,"bgr8"); 
   Mat img_gray;



int main(int argc, char **argv){
  ros::NodeHandle n;
  image_transport::ImageTransport it(n);
  image_transport::Subscriber image_sub = it.subscribe("/ardrone/image_raw",1,process);

  return 0;

If you are interesed in switching between the front and bottom cameras you can use the command:

rosservice call /ardrone/togglecam

You can also subscribe to /ardrone/bottom/image_raw if you want to work only with the bottom camera.

I hope this helps.

Originally posted by Pedro_85 with karma: 182 on 2013-10-30

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by MichaelJ on 2013-10-30:
That helps so much, thank you! Out of curiosity, are you working with the ardrone_autonomy package? Have you been getting a nice stream output or does it produce blurry/double images?

Comment by Pedro_85 on 2013-10-30:
Yes I'm working with the ardrone_autonomy package. The images are of good quality. Good luck!

Comment by MichaelJ on 2013-10-30:
Thanks. So when you ran rosrun image_view image_view image :=/ardrone/front/image_raw, was the image quality good? Did you change any code in the ardrone autonomy or calibrate the camera?

Comment by huevos on 2014-12-17:
Hello, I have the cv_bridge.h but not the CvBridge.h , my prog can't be run because of this include. How can I fix this? Thank you!

Comment by ffazlurr on 2015-07-01:
I have some probelm with huevos, if you dont mind please upload your CvBridge.h thanks

Comment by renanchagas on 2015-08-24:
Hello! I`m new in ROS. What I have to do to run the code above? Do I have to compile? Thanks

Comment by enthurzan on 2017-07-06:
I tried running this program, but I got this error when I built it even after I installeed the vision_opencv package

fatal error: cv_bridge/CvBridge.h: No such file or directory

compilation terminated. findtag/CMakeFiles/detect.dir/build.make:62: recipe for target 'findtag/CMakeFiles/detect.di


Your Answer

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