Now a days autonomous systems and their application in real life is biggest topic under research and applications. Which are generally done by computer vision support whether in Matlab or OpenCV. Few of the main features or main points for vision based applications are specific shape, object or line detection from the scene so by logic we can set some conditions. Today we will discuss one of the most important feature of image processing which is line detection through OpenCV. Before moving towards code we will discuss its different methods and techniques.
Line detection is very important for road and path based real time applications. It is really hard to recognize road for an autonomous system when lane or boundaries of road are not well defined, even in well richen and advanced libraries has no functionality for detecting line of desired curves, slopes or points. Mostly line detection techniques and algorithms are applied on autonomous vehicles and robots so their accuracy, robustness and speed are directly effected on safety. In present researches we have different methods for detecting curves and straight line which creates more complexity and difficulty because a scene can have both type of line so we need to implement both techniques at a time which effect the performance and speed of system. For lane detection first we capture frame from video before that must need to initialize the camera to starting frames so we can get real time frames at time of processing, then apply few effects like gray scaling, binaryzation and denoising to the captured frames. These effects are applied to frames because each effect helps to enhance performance and quality in detection. Gray scaling is applied because the frames we get are in RGB format which is a heavy format and its computation cost is too big to handle so it is difficult to handle RGB frames at real time. So frames conversion from RGB to gray is must and better thing for performance. Similarly denoising effects are also applied on frames because the frames we get from environment contains noise which effect accuracy in recognition. For better noise remove thresh hold technique is applied in this technique we ignore few range of pixels falling under a certain value in accumulator array so after thresh hold implementation we are assured that we are getting smooth and best values and noised data is ignored.
Binaryzation is another filter and effect applied to frames and images for better processing and speed. Whenever we get a frame or image it contains two parts one is its foreground and second is background for feature extraction and line detection we are concerned with foreground so we remove or differentiate our background from foreground so that we better detect the shape or object.
In OpenCV Hough transform is used for line detection. Hough transform use polar coordinates for line expression. Thus a line equation is written in
y = (- cos / sin ) x +( r / sin )
By solving we get
r = x cos + y sin
so we get different line passing through a single point. In general the pair (r, ) represent the line passing from pair(x,y). This method is known is Standard Hough line transform while Hough transform have two technique one we discussed earlier and second is probabilistic Hough transform. Probabilistic give us extreme line between two points we provide.