# DASL Wiki

### Site Tools

ardrone_line_transform

# Differences

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

 ardrone_line_transform [2016/11/01 11:04]dwallace ardrone_line_transform [2016/11/06 02:33] (current)dwallace Both sides previous revision Previous revision 2016/11/06 02:33 dwallace 2016/11/01 11:04 dwallace 2016/11/01 11:04 dwallace created 2016/11/06 02:33 dwallace 2016/11/01 11:04 dwallace 2016/11/01 11:04 dwallace created Line 1: Line 1: ====== Detecting Lines Using Hough Line Transform ====== ====== Detecting Lines Using Hough Line Transform ====== - =Introduction= + ===== Introduction ===== This tutorial we will learn how to detect lines in an image and also the application of detecting lines in an image. ​ This tutorial we will learn how to detect lines in an image and also the application of detecting lines in an image. ​ Line detection is one of the most basic algorithms in computer vision technology. It has variety of applications like pattern recognition,​object comparison,​Lane detection,​SLAM... line detection is involved in the basic level in all of the algorithms mentioned above. ​ Line detection is one of the most basic algorithms in computer vision technology. It has variety of applications like pattern recognition,​object comparison,​Lane detection,​SLAM... line detection is involved in the basic level in all of the algorithms mentioned above. ​ - =Types of Line detection= + ===== Types of Line detection ​===== - OpenCv offers two types of line detection ​ + - 1)Progressive Probabilistic hough transform(PPHT) + OpenCv offers two types of line detection - 2)Standard hough transform.(SHT) + - 3)Multi Scale Hough Transform. + 1) Progressive Probabilistic hough transform(PPHT) + 2) Standard hough transform.(SHT) + 3) Multi Scale Hough Transform. + + ===== Hough Line Transform ===== - =Hough Line Transform= The idea involved in this mechanism is that any point in a binary image could be part of some set of possible lines. Each line is parameterized by a slope '​a'​ and an intercept '​b'​ and then a point in the original image is transformed to a locus of a points in the (a,b) plane corresponding to all lines passing through that point. If we convert every non-zero pixel in the input image into such a set of points in the output image and sum over all such contributions,​then lines that appear in the input image will appear as local maxima in the  output image. Since each point'​s contributions is being summed the (a.b) plane is called accumulator plane. This is pretty much the concept the involved in Standard Hough Transform. The idea involved in this mechanism is that any point in a binary image could be part of some set of possible lines. Each line is parameterized by a slope '​a'​ and an intercept '​b'​ and then a point in the original image is transformed to a locus of a points in the (a,b) plane corresponding to all lines passing through that point. If we convert every non-zero pixel in the input image into such a set of points in the output image and sum over all such contributions,​then lines that appear in the input image will appear as local maxima in the  output image. Since each point'​s contributions is being summed the (a.b) plane is called accumulator plane. This is pretty much the concept the involved in Standard Hough Transform. - ==Probabilistic hough transform== + ==== Probabilistic hough transform ==== - This method is a variation of the standard hough transform. It takes in the extent of the lines than just the orientation of the lines. The reason its called Probabilistic is that accumulates only a fraction of the points in the accumulator plane and not all of them.(source:​Learning OpenCv).  ​ + - ===Trying out Probabilistic Hough transform ​through ​the drone'​s eye=== + This method is a variation of the standard hough transform. It takes in the extent of the lines than just the orientation of the lines. The reason its called Probabilistic is that accumulates only a fraction of the points in the accumulator plane and not all of them.(source:​Learning OpenCv).  ​ - 1.Go to folder named "​src"​ in the package "​roscv"​(which you would have created in the previous tutorials). + === Trying out Probabilistic Hough transform through ​the drone'​s eye === - 2.Create a file called "​plines.cpp"​. + - 3.Paste the following code in it and save the file. + - + 1. Go to folder named "src" ​in the package "​roscv"​(which you would have created in the previous tutorials). + 2. Create a file called "​plines.cpp"​. + 3. Paste the following code in it and save the file. + ​ #include <​ros/​ros.h>​ #include <​ros/​ros.h>​ #include <​stdio.h>​ #include <​stdio.h>​ Line 138: Line 142: } } - + + + === Make changes in the CMakeLists.txt === - ===Make changes in the CMakeLists.txt=== Step 1: Open up the file named "​CMakeLists.txt"​ and search for the lines beginning with "​rosbuild_add_executable"​. In that add the file you created which is "​plines.cpp"​. Save and close the file. Step 1: Open up the file named "​CMakeLists.txt"​ and search for the lines beginning with "​rosbuild_add_executable"​. In that add the file you created which is "​plines.cpp"​. Save and close the file. Step 2: Open up a terminal and enter the commands one after the other: ​ Step 2: Open up a terminal and enter the commands one after the other: ​ -
-                                                                                                                                        roscd roscv
-                                                                                                                                        cmake .
-                                                                                                                                        rosmake
-                                                                                                                                        ​
-                                                                                                                                        ==Test the Code==                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       +                                                                                         roscd roscv
+                                                                                         cmake .
+                                                                                         rosmake
+
+                                                                                         ==== Test the Code ====
1.Make sure you are connected to the ardrone.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     1.Make sure you are connected to the ardrone.
2. Enter the following commands in a separate terminal:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           2. Enter the following commands in a separate terminal:
-
-                                                                                                                                        roscore
-                                                                                                                                        rosrun ardrone_brown ardrone_driver
-                                                                                                                                        rosrun roscv roscv
-                                                                                                                                        ​
-                                                                                                                                        here is a picture of line detection using probabilistic hough transform.<​br>​
+                                                                                         roscore
+                                                                                         rosrun ardrone_brown ardrone_driver
+                                                                                         rosrun roscv roscv
-                                                                                                                                        [[image:hline.png|700px|Probabilistic hough transform]]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 +                                                                                         here is a picture of line detection using probabilistic hough transform.<​br>​
+
+                                                                                         {{dylanw:hline.png}}\\
-                                                                                                                                        =Standard Hough Transform=                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              +                                                                                         ===== Standard Hough Transform ​=====
Like wise lets implement the standard hough line transform.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Like wise lets implement the standard hough line transform.
Line 168:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Line 172:
1.Go to folder named "​src"​ in the package "​roscv"​(which you would have created in the previous tutorials). 2.Create a file called "​slines.cpp"​. 3.Paste the following code in it and save the file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1.Go to folder named "​src"​ in the package "​roscv"​(which you would have created in the previous tutorials). 2.Create a file called "​slines.cpp"​. 3.Paste the following code in it and save the file.
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               +
#include <​ros/​ros.h>​                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              #include <​ros/​ros.h>​
#include <​stdio.h>​                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                #include <​stdio.h>​
Line 288:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Line 292:
return 0;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         return 0;
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 }
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       +
-                                                                                                                                        ==Make changes in the CMakeLists.txt==                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  +
+                                                                                         ==== Make changes in the CMakeLists.txt ====
Step 1: Open up the file named "​CMakeLists.txt"​ and search for the lines beginning with "​rosbuild_add_executable"​. In that add the file you created which is "​slines.cpp"​. Save and close the file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Step 1: Open up the file named "​CMakeLists.txt"​ and search for the lines beginning with "​rosbuild_add_executable"​. In that add the file you created which is "​slines.cpp"​. Save and close the file.
-                                                                                                                                        ==Test the Code==                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       +                                                                                         ==== Test the Code ====
1.Make sure you are connected to the ardrone.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     1.Make sure you are connected to the ardrone.
2. Enter the following commands in a separate terminal:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           2. Enter the following commands in a separate terminal:
-
+
-                                                                                                                                        roscore                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 +                                                                                         roscore
-                                                                                                                                        rosrun ardrone_brown ardrone_driver                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     +                                                                                         rosrun ardrone_brown ardrone_driver
-                                                                                                                                        rosrun roscv roscv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      +                                                                                         rosrun roscv roscv
-                                                                                                                                        ​                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  +
here is a picture of line detection using probabilistic hough transform.<​br>​                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      here is a picture of line detection using probabilistic hough transform.<​br>​
-                                                                                                                                        [[image:pline.png|700px|Standard hough transform]]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      +                                                                                         {{dylanw:pline.png}}\\
-                                                                                                                                        =Conclusion=                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            +                                                                                         ===== Conclusion ​=====
In this tutorial we wrote the code for standard hough transform as well as probabilistic hough transform.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         In this tutorial we wrote the code for standard hough transform as well as probabilistic hough transform.
But one has to know ,how to make use of the lines extracted ,in the next two tutorials I have designed basic navigation algorithm based on probabilistic hough transform and standard hough transform.This shows the application of hough line detection.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         But one has to know ,how to make use of the lines extracted ,in the next two tutorials I have designed basic navigation algorithm based on probabilistic hough transform and standard hough transform.This shows the application of hough line detection. 