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
Copy file name to clipboardExpand all lines: examples/analog-gauge-reader/README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# Analog Gauge Reader
2
2
3
-
This sample application takes an image or frame of an analog gauge an reads the value using computer vision.
4
-
It consists of two parts: the calibration, and the measurement. During calibration, the user gives the application an image
5
-
of the gauge to calibrate, and it prompts the user to enter the range of values in degrees. It then uses these
3
+
This sample application takes an image or video frame of an analog gauge and reads the value using functions from the OpenCV\*computer vision library.
4
+
It consists of two parts: calibration and measurement. During calibration, the application calibrates an image
5
+
of a gauge (provided by the user) by prompting the user to enter the range of values of the gauge in degrees. It then uses these
6
6
calibrated values in the measurement stage to convert the angle of the dial into a meaningful value.
7
7
8
8
## What you’ll learn
@@ -12,11 +12,11 @@ calibrated values in the measurement stage to convert the angle of the dial into
12
12
## Gather your materials
13
13
* Python\* 2.7 or greater
14
14
* OpenCV version 3.3.0 or greater
15
-
*A picture of a gauge to try (or you can use the sample one provided)
15
+
*An image of a gauge (or you can use the sample one provided)
16
16
17
17
## Setup
18
18
1. Take a picture of a gauge or use the gauge-1.jpg provided. If you name it something other than gauge-1.jpg make sure to
19
-
change that in the main() function.
19
+
change that in the `main()` function.
20
20
2. Run the application (download the .zip at the end of this article first) and enter the requested values, using the output file gauge-#-calibration.jpg to determine the values. Here's an example of what the calibration image looks like:
21
21

22
22
@@ -37,19 +37,19 @@ gauge-2.jpg is provided for the user to try.
37
37
Code is included in this folder of the repository in the .py file.
38
38
39
39
## How it works
40
-
The main functions used in OpenCVare HoughCircles (to detect the outline of the gauge and center point) and HoughLines (to detect the dial).
40
+
The main functions used from the OpenCV\* library are `HoughCircles` (to detect the outline of the gauge and center point) and `HoughLines` (to detect the dial).
41
41
42
42
Basic filtering is done as follows:
43
-
For cirles (this happens in calibrate_gauge())
43
+
For cirles (this happens in `calibrate_gauge()`)
44
44
* only return circles from HoughCircles that are within reasonable range of the image height (this assumes the gauge takes up most of the view)
45
45
* average the resulting circles and use the average for the center point and radius
46
-
For lines (this happens in get_current_value())
47
-
* apply a threshold using cv2.threshold.cv2.THRESH_BINARY_INV with threshold of 175 and maxValue of 255 work fine
46
+
For lines (this happens in `get_current_value()`)
47
+
* apply a threshold using `cv2.threshold.` and `cv2.THRESH_BINARY_INV` with threshold of 175 and maxValue of 255 work fine
48
48
* remove all lines outside a given radius
49
49
* check if a line is within an acceptable range of the radius
50
50
* use the first acceptable line as the dial
51
51
52
-
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 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 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
52
+
There is a considerable amount of trigonometry involved to create the calibration image, mainly sine and cosine to plot the calibration image lines and arctangent to get the angle 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 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
53
53
implementation assumes the gauge is aligned in the image, but it can be adjusted by changing the value of 9 to something else.
54
54
55
55
IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments.
0 commit comments