ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Help with streaming AR.Drone camera images to openCV

asked 2013-09-14 02:42:34 -0600

MichaelJ gravatar image

updated 2014-01-28 17:17:57 -0600

ngrennan gravatar image

Hello all.

I am using the AR.Drone 2.0 and setup the ardrone_autonomy driver link:text 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!

edit retag flag offensive close merge delete


How are the images currently streamed? Can it be used as a sort of IP cam? OpenCV has support for IP cams.

davinci gravatar image davinci  ( 2013-09-15 04:40:36 -0600 )edit

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?

MichaelJ gravatar image MichaelJ  ( 2013-09-15 04:56:01 -0600 )edit

Do you want to get the stream from the AR.Drone in order to process it with OpenCV?

Pedro_85 gravatar image Pedro_85  ( 2013-10-30 06:36:23 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-10-30 11:29:16 -0600

Pedro_85 gravatar image

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.

edit flag offensive delete link more


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?

MichaelJ gravatar image MichaelJ  ( 2013-10-30 11:38:57 -0600 )edit

Yes I'm working with the ardrone_autonomy package. The images are of good quality. Good luck!

Pedro_85 gravatar image Pedro_85  ( 2013-10-30 11:44:27 -0600 )edit

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?

MichaelJ gravatar image MichaelJ  ( 2013-10-30 13:26:23 -0600 )edit

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!

huevos gravatar image huevos  ( 2014-12-17 09:23:32 -0600 )edit

I have some probelm with huevos, if you dont mind please upload your CvBridge.h thanks

ffazlurr gravatar image ffazlurr  ( 2015-07-01 01:28:08 -0600 )edit

Hello! I`m new in ROS. What I have to do to run the code above? Do I have to compile? Thanks

renanchagas gravatar image renanchagas  ( 2015-08-24 20:24:00 -0600 )edit

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

enthurzan gravatar image enthurzan  ( 2017-07-06 10:21:27 -0600 )edit

answered 2013-09-18 23:48:45 -0600

davinci gravatar image

Here is the image stream described:

You can import the mjpeg stream in OpenCV or in ROS through cv bridge. Here is an example for OpenCV:

edit flag offensive delete link more


Thanks for the reply. Is there any examples that use the AR.Drone 2.0 camera? The first link is for ardrone 1.0 and is just a browser to control the drone. I want to perform image processing on the images. The second link is too generic for me. Is the ardrone camera called an ip camera?

JP gravatar image JP  ( 2013-09-19 01:51:29 -0600 )edit

I think you can treat it as an ip camera (network camera) with an mpjeg image stream that you can process in OpenCV. How do you mean to generic? It is a start to read out the images and after that you can start processing.

davinci gravatar image davinci  ( 2013-09-19 02:30:48 -0600 )edit

I say it is too generic because there are no ardrone_autonomy imports that work specifically for the ardrone camera. I would have to modify the code to get it to work and that will cause more problems I think.

JP gravatar image JP  ( 2013-09-19 02:37:21 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2013-09-14 02:42:34 -0600

Seen: 6,275 times

Last updated: Oct 30 '13