IJCSNS International Journal of Computer Science and Network Security, VOL.19 No.
12, December 2019 91
Automated Water Tap Controlling System Using Machine
Vision
Dr. Khalid Nazim Abdul Sattar,
Assistant Professor, Department of CSI, College of Science, Majmaah University, Majmaah 11952, Saudi Arabia,
Summary b. Detection of Human Hands: Using Skin color-
Water is essential for everybody in the earth. As we know only based techniques hand portion will be
2.5 percent of fresh water is available on the earth and only less segmented and detected.
than 1% of water is available for drinking purpose. All the c. Estimation of water capacity: Using simple
available fresh water is ground water, that acts as a reservoir algorithm like Edge Detection water filling
that can also be tapped to various uses. This system makes use
of image processing techniques and tries to minimize the
capacity of the containers will be estimated and
wastage of water from the taps. The main focus towards the monitored continuously.
system design was to ensure that the taps should be able
recognize objects placed below it and able to fill the container
with desired level of water automatically. The designed system 2. Literature Survey
detects the object as hand or bottle, if the detected object is
bottle then the water level will be indicated, the accuracy 2.1 Background
obtained for the detection of hand is 85.71% and for the bottle
is 77.77%. The proposed system is to provide an automated As we know Image Processing is an increasing area of
method to conserve water efficiently.[1,5,6]. research now a days. The primary objective for selecting
Key words: intelligent taps using image processing was to minimize
Image processing, Machine Vision, object detection, feature the wastage of water. use of computer vision techniques
extraction, Hough Transform.
referring to object classification and identification have
been used to implement autonomous system to control
1. Introduction and monitor the flow of water from the taps anything
else with pixels involved[14].
As we know the available fresh water on Earth is only The very purpose of using Python programming
3% and finding efficient methods to prevent water from language was to express concepts in fewer lines of code
further wastage is more efficient task[16]. The water is [13].
majorly wasted through taps., hence the main focus As per the experimental results shown in [1], the
towards the system design was to ensure that the taps intelligent system that was developed was accurate
should be able recognize objects placed below it and able enough to detect moving object and acquire the
to fill the container with desired level of water image with an accuracy of 94.26% .
automatically [6]. This proposed work focuses on An approach referring to hand segmentation integrating
detection of object for which, this system makes use of involving color and motion is taken into consideration by
image processing and try to minimize wastage of water the approach as experimented by Lim Wei Howe et.al[2].
from the tap. Whenever the object is placed under the tap The color segmentation method is used to determine the
it must detect the object through camera fixed on it. skin color and background information around the hand
The different camera features have important [3].
consequences on quality of images. In [4], Sobel’s algorithm is used for the edge detection
Further, use of computer vision techniques referring to and it is improved in to the horizontal and the vertical
object classification and identification have been used to edge direction.
implement autonomous system to control and monitor A feature extraction algorithm [5], for bottle inspection
the flow of water from the taps[19]. This proposed work that considers status of caps followed by level of the
consists of three important steps: liquid in the bottles.
a. Detection of water containers: Using deep In [6], use of fuzzy logic helped the researchers to
learning methods new objects have been develop a water saving tool to take care of water
detected, analyzed and recognized. For wastage.
estimating the shape and size of the bottle, this In[7], a system for water level measurement using
proposed work shall use geometrical features. PIC16F707 microcontroller is described. Selected
Manuscript received December 5, 2019
Manuscript revised December 20, 2019
92 IJCSNS International Journal of Computer Science and Network Security, VOL.19 No.12, December 2019
method uses capacitance to measure the dielectric Step 2: If the detected object is hand,
permittivity of a surrounding medium. Microcontroller
then
used here requires minimal number of external
components which ensures low cost of sensor hardware sprinkle the amount of water required for the
implementation. hand.
2.2 Functional Requirements a. If the detected object is not hand
then
2.1.1 Hand Detection it may be a bottle / container,
calculate the amount of water required to fill the
Input: Capture the video frames from webcam. bottle / container.
Process: The hand portion will be segmented and b. Monitor the amount of water level in the
detected by using skin color-based techniques. container/bottle.
Output: slide view the original frame along with the skin c. Stop.
detected frame [2,3,9,10].
The next section discusses the algorithms used for skin
2.1.2 Bottle Detection segmentation and bottle detection while developing the
system[2,3].
Input: Capture the video frames from webcam.
Process: objects have been detected, analyzed and 3.1 Algorithm for Skin Segmentation
recognized along with level of the water by using deep
learning methods. Input: capture the video from webcam
Output: The bottle is detected, and the bounding box is Output: slide view the original frame along with the
computed[4,7,8]. skin detected frame.
Step 1: Repeat Loop over for every frame
3. Methodology Step 2: If Frame is not read, encounter end video
Else
In this section the algorithms that are part of Go to step 3
implementation process are being explained., the Step 3: Resize the frame and convert it into HSV color
proposed architecture is as shown in fig 3.1, defines the
space
high-level design of the system.
Step 4: Verify the HSV pixel intensities
(upper and lower boundaries)
Step 5: If Lower boundaries = [0, 50, 90] &
Upper boundaries = [25,255,255],
Then pixel indicates a skin color tone
Else
Pixel Indicates no skin color tone
Step 6: the mask is subjected to a series of erosions
and dilations using elliptical kernel.
Step 7: Blur the mask to remove noise- use Gaussian
blur method.
Step 8 apply the skin mask to the desired frame.
3.2 Algorithm for Bottle Detection
Input: Capture the video from webcam and wait for min
Fig. 3.1 The Proposed Methodology of 2 seconds to warm-up the camera
Output: Display the contents of the bottle (colored
The methodology used in developing the systems is as bounding box, line that indicates the depth of the liquid).
described below:
Step 1: Repeat Loop over for every frame
Step 1: Detect the object by using a camera.
Step 2: If Frame is not read, encounter end of the video
IJCSNS International Journal of Computer Science and Network Security, VOL.19 No.12, December 2019 93
Else
Go to step 3
Step 3: Resize the frame to a maximum width of 600
pixels
Step 4: acquire frame dimension and convert into a blob
Step 5: Permit the blob through the network to get the
detection and prediction values.
Step 6: Perform probability check
Loop over the detection and check for the confidence Fig. 4.1 Hand Detection
Step 7: If (Confidence value < minimum confidence)
The object(bottle) is not detected c. Bottle Detection:
Else
When the bottle is given as an input, the bottle will be
The object(bottle) is detected and compute the
detected along with the bounding box with an accuracy.
bounding box
When multiple bottles are placed the system can detect
Step 8: Verify the depth of the bottle using Hough
the multiple bottles[8,11] as shown in the figure below:
transformation[17,18].
4. Experimental Consideration
Since the color tone of human skin varies, it is quite
difficult to design a segmentation or detection method.
Hence forth RGB colour space is not preferred for
colour-based detection and for its non-
uniform characteristics, in this context the HSV colour
approach is ideal and preferred[2,3].
a. Skin Color Segmentation:
Fig. 4.2 Bottle Detection
1. Apply Skin Segmentation to detect the hand.
2. Change the image from RGB to HSV color d. Hough Transform:
space.
3. Set threshold values for the HSV color Space. An algorithm for detecting water level in bottle is as
4. White Pixels (255) represent areas as skin. discussed below using Hough Transform [17,18].
Black Pixels (0) Pixels represent areas that are a. By using any suitable edge detection scheme,
not skin. determine all the edge points in the captured
5. Use Erosions and dilations and repeat the frame.
process to detect small false-positive skin b. Quantize (a, b) space into a 2-dimensional
regions in the image. matrix (HT) with appropriate quantization
levels.
b. Hand Detection: c. Initialize HT =0.
d. Increment by 1, the element from matrix H
Hand detection is done by using skin color segmentation, (ai ,bi ) if it is found to correspond to an edge
in which the hand region is segmented, and the non- skin point resulting in a histogram or a vote matrix
pixels will be excluded, the corresponding output is as showing the frequency of edge points
illustrated in the figure as shown below[9,10]. corresponding to certain (a, b) points lying on a
common line.
e. Finally, the histogram HT is thresholded where
only the large valued elements are taken, that
correspond to lines in the Frame.
94 IJCSNS International Journal of Computer Science and Network Security, VOL.19 No.12, December 2019
5. Results & Analysis 100
5.1 Performance Evaluation 80
The results obtained in the experimentation are tested for 60
the mapping efficiency, four criteria of class C1 are used
for performance evaluation[19]: 40
20
Table 5.1: Evaluation Criteria
Category Instance_type Terminology_used
False Positive classified as C1 fp 0
False Negative not classified as C1 fn Accuracy Precision Recall
True Positive classified as C1 tp
True Negative not classified as C1 tn
Fig. 5.2 Evaluation of Bottle Detection
5.1.1 Measures for Evaluation:
Recall = (tp) /(tp + fn) (1) 6. Future Scope & Conclusion
Precision = (tp) /(tp +fp) (2)
Accuracy = (tp + fn)/ (tp + tn + fp + fn) (3) The designed system just detects the level of water in the
bottle , which can be further enhanced by displaying its
a. Different test inputs were given for hand volume to be filled in terms of ml/ltrs and design the taps
detection, the corresponding values were to respond to human voice by performing speech
generated for accuracy, precision and recall are recognition operations.
as shown below in fig 5.1. It has been observed that there is no perfect technology,
Accuracy=85.71% and each technology has specific features that work in
Precision=91.66 well-defined problem specific situations.
Recall=91.66 This system makes use of image processing techniques
and tries to minimize the wastage of water from the taps.
100 It is designed in such a way that taps should be able
recognize the objects placed below it and should be able
80 to fill the container with desired level of water
automatically. Further results show that the accuracy
60 obtained for the detection of hand is 85.71% and for the
bottle is 77.77%.
40
Acknowledgments
20
The author would like to thank Deanship of Scientific
0
Research at Majmaah University for supporting this
Accuracy Precision Recall
work under Project Number No. R-1441-39.
Fig. 5.1 Evaluation of Hand Detection References
[1] A. S. Prabuwono, R. Sulaiman, A. R. Hamdan, and
b. b. Different test input were given for bottle Hasnaity A., “Development of intelligent visual inspection
detection, , the corresponding values were system (IVIS) for bottling machine”, in Proc. IEEE
generated accuracy, precision and recall as Tencon ’07, 2007.
shown below in fig 5.2. [2] Lim Wei Howe, Farrah Wong, Ali Chekima,” Comparison
Accuracy=77.77% of Hand Segmentation Methodologies for Hand
Gesture Recognition” IEEE Trans. comm, 2008.
Precision=85.71 [3] WEI WANG,JING PAN, ”Hand Segmentation using Skin
Recall=85.71 Color and Background Information”, Proceedings of the
2012 International Conference on Machine Learning and
Cybernetics, Xian, 15-17 July 2012 .
[4] K. J. Pithadiya, C. K. Modi, and J. D. Chauhan,
“Comparison of optimal edge detection algorithms for
liquid level inspection in bottles”, in Proc. Second
IJCSNS International Journal of Computer Science and Network Security, VOL.19 No.12, December 2019 95
International Conference on Engineering Trends in from Singhania University, Rajasthan, India. He has 19 years of
Engineering and Technology, 2009, pp. 447-452. research and teaching experience and his research expertise
[5] Leila Yazdi, Anton Satria Prabhuwono, Ehsan include but are not limited to Image processing, digital signal
Golkar ”Feature Extraction Algorithm for fill Level and
processing, Artificial Intelligence, Internet of Things,
Cap Inspection in Bottling Machine” in proc,2011
international conference on pattern analysis and Intelligent Cryptography, Data & Network Security and Data mining.
Robotics.
[6] Teddy matoro, Wirawan Istiono “Saving Water with
Water Level Detection in a Smart Home Bathtub Using
Ultrasonic Sensor and Fuzzy Logic”, in Proc. 2017 Second
International Conference on Informatics and Computing
(ICIC), 1-3 Nov. 2017.
[7] H. Zhu, “New algorithm of liquid level of infusion bottle
based on image processing,” in Proc. International
Conference on Information Engineering and Computer
Science, 2009.
[8] S. Ramli, M. M. Mustafa, and A. Hussain, “A
morphological-based approach for bottle shape
classification,” in Proc. International Conference on
Electrical Engineering and Informatics, 2007, pp. 214- 217.
[9] F. Quek, “Toward a Vision-Based Hand Gesture
Interface”, Proc. Virtual Reality Software and Technical
Conf. 1994, pp. 17-29.
[10] Pavlovic, V.I, Sharma, R., Huang, T.S, “Visual
Interpretation of Hand Gestures for Human Computer
Interaction: A Review”, IEEE Transactions on Pattern
Analysis and Machine Intelligence, 1997, Vol. 19, No. 7.
[11] S. Ramli, M. M. Mustafa, D. A. Wahab, and A.
Hussain, “Plastic bottle shapeclassification using partial
erosion-based approach,” in Proc. 6th International
Colloquium on Signal Processing & Its Applications
(CSPA'10), 2010.
[12] H. Lee, S. Jang, G. Shin, S. Hong, D. J. Lee, M. Chun, An
Ultrasonic Multi-Beam Concentration Meter with a
Neuro- Fuzzy Algorithm for Water Treatment Plants.
Sensors vol. 15, Issue 10, pp. 26961-26977 (2015).
[13] www.geeksforgeeks.org/python-language-introduction.
[14] www.blog.algorithmia.com/introduction-to-computer-
vision.
[15] www.wikipedia.org/wiki/Recurrent_neural_network
[16] Anisha, R. A. Menon and A. Prabhakar, "Electronically
controlled water flow restrictor to limit the domestic
wastage of water," 2017 International conference on
Microelectronic Devices, Circuits and Systems (ICMDCS),
Vellore, 2017, pp. 1-6.
[17] https://en.wikipedia.org/wiki/Hough_transform
[18] Dimple Kapoor, Ms. Minakshi Kumar, Pradeep Pant,
Automated Object Recognition from High Resolution
Satellite Images, International Journal of Advanced
Research in Computer Engineering & Technology
(IJARCET), Volume 3 Issue 12, December 2014.
Dr. Khalid Nazim Abdul Sattar,
Assistant Professor, Department of
CSI, College of Science, Majmaah
University, Az Zulfi, Kingdom of
Saudi Arabia, received his B. E.
Degree from Bangalore University, M.
Tech from VTU Belagavi, and Ph.D.
in Computer Science & Engineering