You are on page 1of 7

Measurement 42 (2009) 604–610

Contents lists available at ScienceDirect

Measurement
journal homepage: www.elsevier.com/locate/measurement

Liquid-level measurement using a single digital camera


Ti-Ho Wang a, Ming-Chih Lu a, Chen-Chien Hsu b,*, Cheng-Chuan Chen a, Jia-Dong Tan b
a
Department of Electronic Engineering, St. John’s University, 499 Tam King Rd., Sec. 4, Tam-Sui, Taipei County 25135, Taiwan
b
Department of Electrical Engineering, Tamkang University, 151 Ying-Chuan Rd., Tam-Sui, Taipei County 25137, Taiwan

a r t i c l e i n f o a b s t r a c t

Article history: An imaged-based measurement system using a single digital camera and a circular float to
Received 7 January 2007 measure fill levels in liquid tanks is proposed in this paper. By choosing the float in a dif-
Received in revised form 11 July 2008 ferent color from that of the liquid in the tank, pixel counts of the float in the image cap-
Accepted 11 October 2008
tured by the camera can be calculated with the use of chrominance filtering and
Available online 26 October 2008
thresholding techniques. Based on an established relationship between the pixel counts
of the diameter of the float in the image and the photographing distance, the measuring
system can effectively measure the liquid level based on the images captured. Because
Keywords:
Liquid level
pixel counts of the float in the image are first determined for calculating the diameter of
Digital camera the float, a subpixel resolution during the measurement can be achieved. As a result, mea-
Measurement system suring precision as well as accuracy via the proposed system can be significantly improved.
Image Ó 2008 Elsevier Ltd. All rights reserved.
Subpixel resolution

1. Introduction imposed a critical constraint on liquid-level measurement.


As a result, the establishment and calibration of these mea-
The determination of fill levels in liquid tanks is still un- suring systems were generally difficult for practical
der development as the measurement techniques have to implementations.
meet the increasing requirements of modern processes in To improve measuring performance and overcome the
chemistry, food industry or biotechnology. In some appli- above-mentioned difficulties, this paper presents a novel
cations, it is not possible to install mechanical measure- liquid-level measurement system using a single digital
ment devices, e.g., pressure sensors. For this reason, camera (or digital video camera) and a circular float. The
contactless and non-invasive methods [1–3] which do setup of the measuring system is simple and straightfor-
not include electrical connections inside tanks [4–7] have ward that the digital camera is mounted above the liquid
been developed over the past years. These techniques, tank for capturing images of the circular float on the liquid
however, cannot record images for monitoring chemical surface. An appropriate size of the circular float is chosen
reactions occurring within the liquid tank during the in accordance with the dimension of the liquid tank to ob-
measurement. Existing image-based measuring techniques tain better measuring performance. Color of the float
[8–13], though worked to some extents in recording should be different from that of the liquid for easier iden-
images while measuring the liquid level, required two laser tification of the float. With the use of the chrominance fil-
beams precisely formed in parallel from the projectors. tering and thresholding (binarization) techniques, pixel
Furthermore, the float needed to be centrally positioned counts of the float in the image captured by the camera
on the liquid surface in the tank by wires, which inevitably can be easily identified for calculation. Subsequently, the
diameter of the float in the image in terms of pixel counts
can be determined with better precision. Based on an
established relationship between the pixel counts of the
* Corresponding author. Tel.: +886 2 2621 5656; fax: +886 8 2620
9814.
diameter of the float in the image and the photographing
E-mail addresses: jameshsu@mail.tku.edu.tw, wilonda@gmail.com distance, the proposed system can effectively measure
(C.-C. Hsu). the liquid level (volume) while recording images for

0263-2241/$ - see front matter Ó 2008 Elsevier Ltd. All rights reserved.
doi:10.1016/j.measurement.2008.10.006
T.-H. Wang et al. / Measurement 42 (2009) 604–610 605

monitoring process occurring in the tank. Because pixel ital camera, h0, needs to be taken into account. How the
counts of the float in the image are first calculated for critical parameter h0 is obtained for a specific camera will
determining the diameter of the float, a subpixel resolution be described in details later in this paper. Note that the dig-
during the measurement can be achieved. As a result, mea- ital camera has a distance h1 moved backward to circum-
suring precision as well as accuracy via the proposed sys- vent the near depth of field (DOF) limit inevitably
tem can be significantly improved. It is worthy noting encountered via existing approaches [13]. To prevent pos-
that the measuring system performs satisfactorily in mea- sible contact with the liquid, a tempered glass can be
suring liquid levels irrelevant to the shape of the tank un- positioned between the camera and liquid in the tank,
der measurement. forming a non-contact measuring system. A mask can also
The paper is organized as follows. Section 2 introduces be mounted covering the digital camera to prevent nega-
the proposed liquid-level measurement system based on tive influence from the environment to the digital camera
images captured by a digital camera. Relationship between and liquid. Two spot lights are installed for providing
pixel counts of the diameter of a circular float in an image lighting within the tank so as to enhance image quality.
frame and the photographing distance will be described in A circular float made of non-corrosive floating material
details in this section. The determination of intrinsic with a known diameter will be used as a means for mea-
parameters for digital cameras is given in Section 3. Exper- suring the liquid level. To provide better stabilization, a
iment results mimicking the measurement process of fill sinker is positioned underneath the float to reduce fluctu-
levels in a liquid tank are presented in Section 4. Conclu- ation of the float on the surface of the liquid. The float is
sions are drawn in Section 5. basically a disc with mono color on its surface, preferably
different from that of the liquid in the tank, for easier
2. Measurement of liquid level based on images identification from the image. The thickness of the float
is Hfloat when it sits on the bottom in the tank. As shown
Because of the linear relationship between the pixel in Fig. 1, the pixel counts of the diameter of the float in an
counts of objects in an image frame and the photographing image frame, N(ha) and N(hb), at positions Pa and Pb, are a
distance, we can then use a digital camera to capture function of the photographing distance, ha and hb, respec-
images for measuring fill levels in liquid tanks. tively. Based on the relationship between the photograph-
ing distance and the pixel counts in the image, the liquid
2.1. Setup of the proposed liquid-level measuring system level can then be determined on the basis of the pixel
counts of the diameter of the float in the image captured
Fig. 1 shows the proposed liquid-level measuring sys- by the camera.
tem, in which a digital camera (or digital video camera)
with a maximum view angle, 2hmax, is mounted above 2.2. Relationship between pixel counts and photographing
the liquid tank in such a way that the optical axis of the distance
camera is perpendicular to the surface plane of the liquid.
To achieve better measuring accuracy, the distance be- Because of the disposition of the circular float on the
tween the optical origin (OP) and the front end of the dig- surface of the liquid, the pixel counts of the diameter of

h0

h1 2θ max

hb ha

N (ha )
Pa

ht hg

N (hb )
Pb

H float N (hg )
Pg

Fig. 1. Schematic diagram of the proposed liquid-level measuring system.


606 T.-H. Wang et al. / Measurement 42 (2009) 604–610

the float, N(ha) (or N(hb)), can be calculated from the hori- 2.3. Subpixel resolution in determining the diameter of the
zontal scan line of the image. Based on a triangular rela- float
tionship between the photographing distance and pixel
counts of objects in an image frame, the distance between Though N(ha) can be obtained by a direct counting of
the float and the digital camera can then be determined for the pixels of the diameter of the float from the horizontal
calculating the liquid level, and subsequently the volume scan line of the image, the resolution is not satisfactory,
of the liquid. Fig. 2 shows the relationship between the particularly when there is a long photographing distance.
photographing distance and pixel counts of the diameter To improve measuring accuracy, N(ha) can be alternatively
of the float in an image captured by the digital camera obtained via the pixel counts of the circular float in the im-
via the proposed liquid-level measuring system. A muzzle age as:
limiting the view angle to 2hs is used to reduce the radial rffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi
P
distortion of the lens. Because of the linear relationship be- Nfloat
Nðha Þ ¼ 2  ð4Þ
tween pixel counts of an object in an image frame and its p
horizontal distance, we have based on the relationship between the radius and area of a
P
Dm1 N max circle, where N float is the total pixel counts of the circular
¼ ; ð1Þ float in the image frame at photographing distance ha. By
R Nðha Þ
doing so, the measuring precision of the diameter of the
where R is the diameter of the float, Nmax is the maximal float in terms of pixel counts has achieved a subpixel reso-
pixel counts in a horizontal scan line of an image frame lution. As a result, the measuring precision and accuracy of
which is fixed and known as a priori irrelevant of photo- the proposed approach can be significantly improved.
graphing distances, and N(ha) is the pixel count of the
diameter of the float at photographing distance ha, respec- 2.4. Measurement of the liquid level
tively. Based on a triangular relationship as depicted in
Fig. 2, we have: Note that liquid level is referred to as the distance be-
1 tween the bottom of the tank and the surface plane of
h0 þ ha ¼ Dm1 cotðhs Þ; ð2Þ the liquid. For example, ht  ha and ht  hb stand for liquid
2
levels 1 and 2, respectively. Because the distance hg is gen-
where Dm1 is the real-world horizontal distance formed by erally known as a priori when the float sits on the bottom
the field of view at liquid level 1. Substituting Eq. (1) into of the tank, we can use this parameter to further simplify
Eq. (2), we obtain the distance measurement between the the derivation of the liquid level.
camera and the liquid level at position Pa (liquid level 1) Based on Eq. (3), the liquid level at position Pa (liquid
without Dm1 as: level 1) can be written as:
   
1 Nmax 1 Nmax Nmax
h0 þ ha ¼ R cotðhs Þ ð3Þ hg  ha þ Hfloat ¼   R  cotðhs Þ þ Hfloat
2 Nðha Þ 2 Nðhg Þ Nðha Þ
ð5Þ

h0

h1 2θ S

hb ha
Dm1
N (ha )
Pa
R
N max
ht hg

Dm 2
N (hb )
Pb
R
N max
N ( hg )
H float R
Pg

Fig. 2. Relationship between the pixel counts of the diameter of the float and photographing distance via the proposed liquid-level measuring system.
T.-H. Wang et al. / Measurement 42 (2009) 604–610 607

Note that the intrinsic parameter h0 is no longer With reference to Fig. 4, when the horizontal ruler is posi-
required in calculating the liquid level via Eq. (5). That is, tioned at (A1, A2) and (B1, B2), the distance between the front
measurement via the proposed approach will not be end of the CCD camera and (A1, A2) and (B1, B2) is hm1 and hm2,
affected by the optical origin (OP) of the digital camera. respectively. Based on a triangular relationship, we have:
Any kinds of digital camera can be used to measure the
1
liquid level via the proposed approach. h0 þ hm2 ¼ Dm2 cot hs ð6Þ
2
1
2.5. Flow chart in measuring liquid level via the proposed h0 þ hm1 ¼ Dm1 cot hs ð7Þ
2
approach
Subtracting Eq. (6) from Eq. (7), we obtain:
Fig. 3 shows the procedures to measure fill levels in a 1
liquid tank via the proposed approach. The image captured hm1  hm2 ¼ ðDm1  Dm2 Þ cot hs
2
by the camera is first fetched for chrominance filtering so 2ðhm1  hm2 Þ
as to better identify the float in the image from the back- cot hs ¼ ð8Þ
Dm1  Dm2
ground color of the liquid. We then threshold the image
by a value T via a binarization process for counting pixels Alternatively, we can obtain:
of the float in the image. The diameter of the float is then h0 þ hm2 Dm2
calculated based on the pixel counts of the float to improve ¼
h0 þ hm1 Dm1
measuring precision and accuracy. When pixel counts of
the diameter of the float become available, the liquid level by dividing Eq. (6) by Eq. (7). Thus, the intrinsic parameter
can be obtained via Eq. (5). of the distance between the optical origin and front end of
the camera for a specific camera can be obtained as:
3. Intrinsic parameters of digital cameras hm1 Dm2  hm2 Dm1
h0 ¼ ð9Þ
Dm1  Dm2
To construct a measuring system suitable for all kinds of
digital cameras, two intrinsic parameters h0 and coths of When the intrinsic parameters h0 and cot hs become
the camera need to be established. Fig. 4 shows the pro- available via the proposed approach, the distance between
posed method for obtaining an accurate h0 and cot hs for the float and the digital camera can be determined by Eq.
a digital camera, in which a muzzle limiting the view angle (3), and subsequently the liquid level by Eq. (5).
of 2hs is imposed on the camera.
4. Experiment results

In this section, we present experimental results to dem-


onstrate the effectiveness of the proposed liquid-level
measuring system. To reduce the radial distortion effect
of lens, a muzzle can be mounted on the camera, limiting
the field of view of the camera. As a result, edges of the im-
age frame, where larger radial distortion generally occurs,
will not deteriorate the measuring results. Though the res-
olution is decreased by doing so, it is, however, not a seri-
ous problem as total pixels of digital cameras are
continuously increased.

4.1. Key steps of the proposed measuring method

For practical implementation, key steps below can be


followed to establish the proposed measuring system
according to the schematic diagram in Fig. 1:

(1) A digital camera is mounted above the liquid tank in


such a way that the optical axis of the camera is per-
pendicular to the surface plane of the liquid.
(2) The digital camera has a distance h1 moved back-
ward to circumvent the near depth of field (DOF)
limit.
(3) A circular float with a thickness Hfloat is deployed on
the surface of the liquid.
(4) Obtain the distance measurement h0 + hg between
the camera and the liquid level at position Pg via
Eq. (3), which is generally known as a priori when
Fig. 3. Determination of liquid level based on images captured by the
digital camera using the proposed measuring system. the float sits on the bottom of the tank.
608 T.-H. Wang et al. / Measurement 42 (2009) 604–610

Vertical
ruler
Digital
camera
OP

h0
2θ s

h m2
Horizontal
ruler
hm1

B1 B2
Dm2

A1 A2
D m1

Fig. 4. Mechanism for obtaining the intrinsic parameters for a digital camera.

(5) Calculate the distance measurement h0 + ha between that the disposition of the blue discs has an insignificant ef-
the camera and the liquid level to be determined at fect on the measuring accuracy. As a result, we conclude
an arbitrary position Pa via Eq. (3). that the drift of the float in a liquid tank has no significant
(6) Liquid level at position Pa in the fuel tank can be cal- effect on the measurement accuracy of liquid level via the
culated via Eq. (5). proposed approach as long as the float is positioned not
far from the optical axis, which can be easily achieved with
the use of extension arms constructed underneath the float
4.2. Preparations for the experiments limiting its drifting range on the surface of the liquid. In
comparison to existing researches [9–12], where mean er-
(1) Digital camera used: Panasonic DMC-LX1 digital ror in measurement is up to ±8.8%, the proposed approach
camera, with horizontal resolution of 3248 pixels has a much satisfactory measuring performance.
and vertical resolution of 2160 pixels.
(2) By limiting the field of view of the camera, 3/4 of the 5. Conclusions
total pixels around the central area in the horizontal
scan line are used to reduce the radial distortion In this paper, a novel image-based measuring system is
effect. That is, 2436 pixels in terms of horizontal proposed for measuring fill levels in liquid tanks while
resolution. recording images for monitoring physical status in the
(3) Intrinsic parameters obtained: hs = 0.4 cm, cot(hs) = tank. The proposed approach has substantially overcome
2.352. problems and difficulties encountered in the previous re-
searches and demonstrated itself as a simple yet accurate
way in measuring liquid level for real-world applications.
4.3. Experiment results The simplicity of the proposed approach, where any digital
cameras can be adopted as long as the intrinsic parameters
In an attempt to simulate the measurement of liquid le- are obtained via the proposed identification method, has
vel in a tank, experiments are set up to measure the dis- made the proposed measuring system attractive for practi-
tance between three blue discs and the digital camera at cal applications. Because pixel counts of the float in the im-
various distances as shown in Fig. 5, where the discs having age are first determined for calculating the diameter of the
an identical diameter of 10 cm are deployed in such a way float, a subpixel resolution during the measurement can be
that A1 lies perpendicular to the optical axis of the digital achieved. As shown in the paper, measurement perfor-
camera, and A2 and A3 each has a 10 cm difference from mance has nothing to do with the mounting amplitude
A1 in vertical and horizontal directions, respectively. This and horizontal movements of the camera in the proposed
is to verify the measuring accuracy of the proposed ap- measurement system. As a result, precision calibration
proach by mimicking the disposition of the circular float equipment is no longer required and measuring precision
in different places in the tank. As shown in Table 1 the mea- as well as accuracy via the proposed system can be signif-
surements at various photographing distances between the icantly improved. As demonstrated in this paper, the pro-
camera and the three blue discs differently positioned all posed measurement method has no contact with the
yield a mean error of less than ±1%. This suffices to show liquid while measuring the liquid level. This advantage
T.-H. Wang et al. / Measurement 42 (2009) 604–610 609

Fig. 5. Images of three blue discs at different photographing distances mimicking the measurement process of distance between the float in a liquid tank
and the camera.

Table 1
Measurement of distances between the camera and three blue discs differently positioned at various distances.

Actual distance (cm) Disc A1 Disc A2 Disc A3


Measured distance Error (%) Measured distance Error (%) Measured distance Error (%)
80 80.0200 0.0250 80.0803 0.1004 80.4968 0.6210
100 99.6464 0.3536 99.5634 0.4366 99.8149 0.1851
120 119.2064 0.6613 119.0564 0.7863 119.9267 0.0611
140 138.5641 1.0257 138.3812 1.1563 138.9582 0.7441
160 158.1681 1.1449 158.1403 1.1623 158.4086 0.9946
180 177.8394 1.2003 178.1817 1.0102 177.9712 1.1271
200 197.7060 1.1470 198.0316 0.9842 198.2183 0.8909
240 237.2227 1.1572 237.2565 1.1431 237.4144 1.0774
280 276.1171 1.3867 276.3632 1.2989 275.9943 1.4306
320 315.9127 1.2773 316.8547 0.9829 316.3042 1.1549
360 356.2217 1.0495 356.5932 0.9463 356.0735 1.0907
400 396.0580 0.9855 397.1778 0.7055 396.5659 0.8585
500 496.1329 0.7734 496.2316 0.7537 496.5280 0.6944
600 600.6874 0.1146 602.2581 0.3763 599.1288 0.1452
700 705.9626 0.8518 710.7848 1.5407 705.6820 0.8117
800 803.4414 0.4302 803.8542 0.4818 804.6818 0.5852
Mean error (%) 0.8490 0.8666 0.7795

has made the proposed approach attractive for use in real- References
world applications, preventing safety concerns such as
linkages, exploration, erosion, etc. Simulation results have [1] J. Rautenberg, B. Henning, Novel approach level measurement in
liquid tanks, in: Proceedings of the Word Congress on Ultrasonics,
shown that measuring performance is irrelevant to the September 7–10, 2003, pp. 749–752, Paris, France.
shape of the liquid tank. [2] Peter Hauptmann, Niels Hoppe, Alf Püttmer, Application of ultrasonic
sensors in the process industry, Meas. Sci. Technol. 13 (8) (2002) R73–R83.
[3] G. Bucci, C. Landi, Numerical method for transit time measurement
Acknowledgement in ultrasonic sensor applications, IEEE Transactions on
Instrumentation and Measurement 46 (6) (1997) 1241–1246.
This work was partially supported by the National [4] C. Vázquez, A.B. Gonzalo, S. Vargas, J. Montalvo, Multi-sensor system
using plastic optical fibers for intrinsically safe level measurements,
Science Council, Taiwan, under Grant NSC-94-2218-E-
Sens. Actuators A: Phys. 116 (1) (2004) 22–32.
129-002.
610 T.-H. Wang et al. / Measurement 42 (2009) 604–610

[5] F. Pérez-Ocón, M. Rubiño, J.M. Abril, P. Casanova, J.A. Martínez, Fiber- [10] M.-C. Lu, W.-Y. Wang, C.-Y. Chu, Optical-based distance measuring
optic liquid-level continuous gauge, Sens. Actuators A: Phys. 125 (2) system (ODMS), The Eighth International Conference on Automation
(2006) 124–132. Technology (2005) 282–283.
[6] K. Anjan umar Ghosh, Navjot Singh Bedi, Prashanta Paul, Package [11] M.-C. Lu, Image-based height measuring system for liquid or
design for low-cost optical liquid-level sensors, Optical Engineering particles in tanks, ROC Patent of Invention 201536, 2004.
39 (5) (2000) 1405–1412. [12] M.-C. Lu, Vorrichtung zum Messen des Füllstands von Lagergut,
[7] Golnabi, Hossein, Design and operation of a fiber optic sensor for German Patent of Invention 20319293.1, 2003.
liquid level detection, Optics and Lasers in Engineering 41 (5) (2004) [13] Ming-Chih Lu, Wei-Yen Wang, Chun-Yen Chu, Image-based distance
801–812. and area measuring systems, IEEE Sensors Journal 6 (2) (2006) 495–
[8] David A. Forsyth, Jean Pone, Computer Vision: A Modern Approach, 503.
Prentice Hall, 2002. pp. 801–812.
[9] M.-C. Lu, W.-Y. Wang, H.-H. Lan, Image-based height measuring
system for liquid or particles in tanks, Proc. IEEE Int. Conf.
Networking, Sensing and Control 1 (2004) 24–29.

You might also like