You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The vtest.avi video from https://github.com/opencv/opencv/blob/master/samples/data/vtest.avi
15
+
16
+
## Setup
17
+
1. Download the vtest.avi video from https://github.com/opencv/opencv/blob/master/samples/data/vtest.avi and put it in the same folder as the python script.
18
+
2.
19
+
20
+
Original image:
21
+
[](/images/gauge-1.jpg)
22
+
23
+
## Get the Code
24
+
The application can be downloaded as a .zip at the end of this article.
25
+
26
+
## How it works
27
+
The main functions used in OpenCV are HoughCircles (to detect the outline of the gauge and center point) and HoughLines (to detect the dial).
28
+
29
+
Basic filtering is done as follows:
30
+
For cirles (this happens in calibrate_gauge() )
31
+
* only return circles from HoughCircles that are within reasonable range of the image height (this assumes the gauge takes up most of the view)
32
+
* average the resulting circles and use the average for the center point and radius
33
+
For lines (this happens in get_current_value() )
34
+
* apply a threshold using cv2.threshold. cv2.THRESH_BINARY_INV with threshold of 175 and maxValue of 255 work fine
35
+
* remove all lines outside a given radius
36
+
* check if a line is within an acceptable range of the radius
37
+
* use the first acceptable line as the dial
38
+
39
+
There is a considerable amount of triginomotry involved to create the calibration image, mainly sin and cos to plot the calibration image lines and arctan to get the angle
40
+
of the dial. This approach sets 0/360 to be the -y axis (if the image has a cartesian grid in the middle) and it goes clock-wise. There is a slight
41
+
modification to make the 0/360 degrees be at the -y axis, by an addition (i+9) in the calculation of p_text[i][j]. Without this +9 the 0/360 point would be on the +x axis. So this
42
+
implementation assumes the gauge is aligned in the image, but it can be adjusted by changing the value of 9 to something else.
0 commit comments