Line Detection: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:
<p>
<p>
The purpose of detecting lines is to identify the lines that enclose the field and be able to referee an out of pitch ball or a goal scored. Along with ball detection, a vision based method was required to gain accuracy while refereeing without using invasive methods on the ball or the pitch.</p>
The purpose of detecting lines is to identify the lines that enclose the field and be able to referee an out of pitch ball or a goal scored. Along with ball detection, a vision based method was required to gain accuracy while refereeing without using invasive methods on the ball or the pitch.</p>
==Methodology==


<p>
<p>
Line 10: Line 12:
<p>  2. Apply a color mask to get only the lines on the frame</p>
<p>  2. Apply a color mask to get only the lines on the frame</p>
<p>  3. Line Detection</p>
<p>  3. Line Detection</p>
[[File:Camera calibration app.jpg|thumb|right|upright=1.5|Camera Calibration App. Source: MATLAB]]
<blockquote>
<h3>Undistort image (If applicable)</h3>
<p>In order to undistort the image to get the real perspective you should get the transformation matrix between the frame and the real world. Thus, the camera parameters should be known. If this are not known you can always calibrate the camera based on the output of a specific object with several frames from different perspectives. The commonly used technique is to use a calibration template with black and white squares of the same length disposed alternatively like a ‘chessboard’. Then, you will only need to know the real size of the squares to calibrate it. In this project, the ‘Camera Calibration’ App from MATLAB was used to get the camera parameters.</p>
</blockquote>
[[File:Undistorted matlab.jpg|thumb|right|upright=2|Original frame (left). Result after undistorting the image (right)]]
<blockquote>
<p>
The result after applying the correct transformation matrix should be getting the real straight lines within the frame:</p>
</blockquote>

Revision as of 11:42, 27 March 2016

Design Choice

The purpose of detecting lines is to identify the lines that enclose the field and be able to referee an out of pitch ball or a goal scored. Along with ball detection, a vision based method was required to gain accuracy while refereeing without using invasive methods on the ball or the pitch.

Methodology

Similar to the circular shape matching described in the ball detection approach, here the Hough transform is used to detect lines. Before doing so, several steps must be performed:.


1. Undistort image to get straight lines (In case a wide/fisheye camera is used)

2. Apply a color mask to get only the lines on the frame

3. Line Detection

Camera Calibration App. Source: MATLAB

Undistort image (If applicable)

In order to undistort the image to get the real perspective you should get the transformation matrix between the frame and the real world. Thus, the camera parameters should be known. If this are not known you can always calibrate the camera based on the output of a specific object with several frames from different perspectives. The commonly used technique is to use a calibration template with black and white squares of the same length disposed alternatively like a ‘chessboard’. Then, you will only need to know the real size of the squares to calibrate it. In this project, the ‘Camera Calibration’ App from MATLAB was used to get the camera parameters.

Original frame (left). Result after undistorting the image (right)

The result after applying the correct transformation matrix should be getting the real straight lines within the frame: