ros_and_opencv
Differences
This shows you the differences between two versions of the page.
ros_and_opencv [2016/11/01 11:03] – created dwallace | ros_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 | + | |
- | < | + | 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 |
- | ==ROS and OpenCV== | + | |
+ | ==== ROS and OpenCV ==== | ||
When you download ROS it comes along with OpenCV library | When you download ROS it comes along with OpenCV library | ||
- | 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:// | 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:// | ||
- | ''' | + | **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 " | + | Step 2: Go to " |
- | + | ||
- | + | ||
- | + | ||
- | <source lang=" | + | |
+ | <code c++ simplecanny.cpp> | ||
#include < | #include < | ||
#include < | #include < | ||
Line 113: | Line 113: | ||
return 0; | return 0; | ||
} | } | ||
+ | </ | ||
+ | **Note : Save and close the file** | ||
- | </ | ||
- | |||
- | ''' | ||
- | |||
- | <br> | ||
Step 3: Open up the file named " | Step 3: Open up the file named " | ||
- | < | ||
| | ||
+ | rosbuild_add_executable(roscv src/ | ||
+ | **NOTE: Save and close the file** | ||
- | | + | Step 4:Open up a terminal and enter(one after the other): |
- | + | ||
- | ''' | + | |
- | ''' | + | |
- | <br>Step 4:Open up a terminal and enter(one after the other): | + | |
cmake . | cmake . | ||
rosmake | rosmake | ||
- | < | ||
(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 |
- | </ | + | rosrun ardrone_brown ardrone_driver |
+ | | ||
- | < | + | **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