User Tools

Site Tools


ros_and_opencv

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ros_and_opencv [2016/11/01 11:03] – created dwallaceros_and_opencv [2016/11/06 02:25] (current) dwallace
Line 1: Line 1:
 ====== How to Make ROS and OpenCV Work Together ====== ====== How to Make ROS and OpenCV Work Together ======
  
-=Introduction= +===== Introduction ===== 
-Last two tutorials we learned how to control the quadrotor ARDRONE using ROS and  also to access the frontal and bottom camera of the robot.Since we have access to vision of the quadrotor we shall learn how  to use OpenCV hence opening the doors of computer vision. OpenCV is a library of programming functions for real time computer vision. It makes doing image manipulations  easier and also help to develop complex vision based  algorithms.<br>I recommend you to go through the basics of OpenCv by following this link http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html. Also if you really interested in taking your computer vision knowledge to the next level,you should start reading this book http://www.cse.iitk.ac.in/users/vision/dipakmj/papers/OReilly%20Learning%20OpenCV.pdf. + 
-<br><br> +Last two tutorials we learned how to control the quadrotor ARDRONE using ROS and  also to access the frontal and bottom camera of the robot.Since we have access to vision of the quadrotor we shall learn how  to use OpenCV hence opening the doors of computer vision. OpenCV is a library of programming functions for real time computer vision. It makes doing image manipulations  easier and also help to develop complex vision based  algorithms.I recommend you to go through the basics of OpenCv by following this [[http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html|link]]. Also if you really interested in taking your computer vision knowledge to the next level, you should start reading this [[http://www.cse.iitk.ac.in/users/vision/dipakmj/papers/OReilly%20Learning%20OpenCV.pdf|book]]
-==ROS and OpenCV==+ 
 +==== ROS and OpenCV ==== 
 When you download ROS it comes along with OpenCV library  to check this open up a terminal and enter: When you download ROS it comes along with OpenCV library  to check this open up a terminal and enter:
  
-   roscd vision_opencv+  roscd vision_opencv
  
 This should take you to folder of the package vision_opencv or else you have to download the OpenCV stack from  This should take you to folder of the package vision_opencv or else you have to download the OpenCV stack from 
Line 14: Line 16:
 Now lets write a simple program to do canny edge detection on a video feed.In this case Lets take the video feed from the ARDRONE. Now lets write a simple program to do canny edge detection on a video feed.In this case Lets take the video feed from the ARDRONE.
  
-===Create a package===+=== Create a package === 
 This part you will create a ros package with the required dependencies.Dependencies can be defined as other packages which your package is dependent on.To have more info on package creation please have a look at http://www.ros.org/wiki/roscreate. This part you will create a ros package with the required dependencies.Dependencies can be defined as other packages which your package is dependent on.To have more info on package creation please have a look at http://www.ros.org/wiki/roscreate.
-'''Note: Make sure you create all the packages in your ROS working directory which you would have created in your home  folder while installing ROS  +**Note: Make sure you create all the packages in your ROS working directory which you would have created in your home  folder while installing ROS** 
-'''+
 Step 1: Step 1:
  
-<br>Open up a new terminal and enter :+Open up a new terminal and enter :
  
   roscreate-pkg roscv sensor_msgs opencv2 cv_bridge roscpp std_msgs image_transport turtlesim ardrone_brown std_srvs   roscreate-pkg roscv sensor_msgs opencv2 cv_bridge roscpp std_msgs image_transport turtlesim ardrone_brown std_srvs
  
-<br>Step 2: Go to "src" folder of the newly created package and create a file named "simplecanny.cpp" and in that file past the following code. +Step 2: Go to "src" folder of the newly created package and create a file named "simplecanny.cpp" and in that file past the following code.
- +
- +
- +
-<source lang="C">+
  
 +<code c++ simplecanny.cpp>
 #include <ros/ros.h> #include <ros/ros.h>
 #include <stdio.h> #include <stdio.h>
Line 113: Line 113:
   return 0;   return 0;
 } }
 +</code>
 +**Note : Save and close the file**
  
-</source> 
- 
-'''Note : Save and close the file''' 
- 
-<br> 
 Step 3: Open up the file named "CMakeLists.txt" and add the following lines. Step 3: Open up the file named "CMakeLists.txt" and add the following lines.
-<br>  
      
 +  rosbuild_add_executable(roscv src/simplecanny.cpp)
  
 +**NOTE: Save and close the file**
  
-   rosbuild_add_executable(roscv src/simplecanny.cpp) +Step 4:Open up a terminal and enter(one after the other):
- +
-'''NOTE: Save and close the file +
-''' +
-<br>Step 4:Open up a terminal and enter(one after the other):+
  
   cmake .   cmake .
   rosmake   rosmake
  
-<br><br> 
 (Make sure you get 0 failures for rosmake) (Make sure you get 0 failures for rosmake)
- 
  
 Step 5: Step 5:
 Now we are going to test our code with the ARDRONE. Now we are going to test our code with the ARDRONE.
 Turn on the ARDRONE and connect to it using WiFi.Now enter the following commands one after the other : Turn on the ARDRONE and connect to it using WiFi.Now enter the following commands one after the other :
-<br> <br> 
-<pre> 
-roscore   
- 
-rosrun ardrone_brown ardrone_driver  
  
-rosrun roscv roscv  +  roscore   
-</pre>+  rosrun ardrone_brown ardrone_driver  
 +  rosrun roscv roscv 
  
-<br><br> +**If everything works well you will be seeing two different windows and one window would be a resultant of the cannyedge detection. My threshold for this operation was between 50 and 125. You can further play with it according to the needs of the environment.I am talking about values of parameters in cvcanny(which should be found in simplecanny.cpp)**
-'''If everything works well you will be seeing two different windows and one window would be a resultant of the cannyedge detection. My threshold for this operation was between 50 and 125. You can further play with it according to the needs of the environment.I am talking about values of parameters in cvcanny(which should be found in simplecanny.cpp)'''+
ros_and_opencv.1478023392.txt.gz · Last modified: by dwallace