0% found this document useful (0 votes)
21 views6 pages

A Report of Line Detecting Program

The program detects lines in video frames through several steps: image processing to binarize frames, selecting regions of interest, contour detection to find coordinate points, and exporting marked coordinates. It calculates the horizontal center point but struggles with right angles and detecting when the line is out of view. While the program can locate points accurately generally, it performs poorly in special cases due to issues with the surrounding point distances and delayed out of view detection.

Uploaded by

ssyxz10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views6 pages

A Report of Line Detecting Program

The program detects lines in video frames through several steps: image processing to binarize frames, selecting regions of interest, contour detection to find coordinate points, and exporting marked coordinates. It calculates the horizontal center point but struggles with right angles and detecting when the line is out of view. While the program can locate points accurately generally, it performs poorly in special cases due to issues with the surrounding point distances and delayed out of view detection.

Uploaded by

ssyxz10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

A Report of Line Detecting Program

Method
In general, the main function of the program includes image processing, get region of
interest (roi) of each frame, contour capturing, coordinate marking, and video exporting
(as shown in figure 1).

The image processing step was designed to convert the original images to binarized
frames. The roi selecting was applied to crop the images to tiny parts for analysing.
Based on the region of interest, contour will be accessed so an appropriate coordinate
of each frame could be computed. Eventually, the computed coordinates were marked
by “coordinate marking” section.

Figure 1. flowchart of the main function

In image processing part, initially the original image was resized so the full image could
be shown on the screen (otherwise, only part of the images could be shown). Track
bars were afterwards used to figure out the appropriate HSV value for image
binarization (track bar related codes were commented, and some parts might be
missing).

The binarized image was then cropped to access the ROI (480 pixels wide, 1 pixel
high, shown in figure 2) of the image and the ROI processed image was exported for
further computation.

Figure 2. Region of interest for the video

The flow chart for image processing section is shown in Figure 3:

Figure 3. Image preprocessing section

In the processed image, the contour was accessed, left extreme point and left extreme
point was figured out based on the contour, so horizontal center of the contour was
accessed by taking average value:
𝑥𝑙𝑒𝑓𝑡 + 𝑥𝑟𝑖𝑔ℎ𝑡
𝑥𝑚𝑖𝑑𝑑𝑙𝑒 =
2
𝑦𝑚𝑖𝑑𝑑𝑙𝑒 = 150 (𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡)
The y-axis coordinate was kept 150 since the y-axis coordinate of ROI was the
constant 150.

Figure 4. corresponding points on contour


In figure 4, the contour can be imaged as the line between the 2 extreme points.
There are also circumstances that there is no contour at all in the ROI. Therefore, in
the program, if the contour number is 0, the extreme point coordinates would be kept
equal to the previous extreme points.

Figure 5. Flow chart of contour accessing section

In information printing section, horizontal center of the black track was highlighted with
red dot and the coordinates was printed on each frame of the video.

To detect the out of view circumstance, 4 surrounding points (shown in figure 6) were
defined. In binarized figures, if all the surrounding point coordinates have the color of
white, then “out of view” would be printed on the screen. Otherwise, normal information
would be shown.

Figure 6. Surrounding points of center point

The upper point, lower point is 37 pixels, 16 pixels from the center point respectively.
The left point, right point is 35, 5 pixels from the center point. The reason that the
distances are different will be stated in “discussion” part.

The color value was extracted from a scalar and stored in an integer, 0 represents
white and 255 stands for black. Hence if all 4 values are 0, then the message “out of
view” would be shown.
Figure 7. Flow chart of information printing section

Loop was already used in main function; Therefore, loop was not used in any other
sections.

Result
In the processed video, the position of central point and the related information can be
shown accurately and when there is no black track, “out of view” was printed.

Figure 8. Central point information

Figure 9. Case of out of view

There are still issues remains, when a right angle was detected, the coordinate should
only have tiny changes, but it changes quite significantly and frequently. The reason is
that in the frames which a right angle was detected, there are more than 1 contour.
However, only the central point for the first contour could be shown.

Another issue is that the “out of view” message shown up appears be too late, there
are a few frames still printing incorrect point information rather than “out of view”
message. Such circumstance was caused by the distance of the lower point from the
central point.
Figure 10. Out of view anomaly detection

Discussion
The initial idea is to fix 4 surrounding points, and they have equivalent distance from
the central point. But there are times when horizontal coordinate of central point is
quite large (around 474). Since the width of the image is only 480 pixels, the right point
cannot be too far from the central point.

The distance between lower point and central point cannot be too large either,
otherwise “out of view” message would be shown up much later.

Gaussian Blur was applied when testing the code to solve the issue that there are
moments when contour number is more than 1. However, the previous problem was
not solved, and there are even more frames which there is no contour.

To estimate, the program can locate the central point in a relatively high accuracy. But
it performs poorly in special circumstances such as right angle and “out of view”
phenomenon.
Appendix I

https://nottinghamedu1-
my.sharepoint.com/:v:/g/personal/ssyxz10_nottingham_edu_cn/EcpCLnREbfNGjXqzr
Peaij4B6aq7nlHfJKVk7_j2VUYLKA?e=e5iiCO

Appendix II

https://nottinghamedu1-
my.sharepoint.com/:u:/g/personal/ssyxz10_nottingham_edu_cn/EbPIpNRFraNArRTH
__3tVKUBRgFRom91vPRYaJKTeok4YQ?e=2ypUzf

You might also like