Keywords

1 Introduction

Currently, there is not an automated system in hospitals to check the number of oxygen cylinders in a hospital storage room. The process of monitoring the number of oxygen cylinders in a hospital is done manually, and the count is entered into spreadsheets electronically to maintain record. This process is prone to human error and may prove to be catastrophic when unrecognized in times of shortage. This is what happened in Gorakhpur, India in the year 2017 which led to the death of 60 infants in a hospital [1]. Also, considering the current covid-19 pandemic situation, it is very much essential to maintain enough stock of oxygen cylinders to serve the need of severely affected patients who are in need of oxygen [2]. Hence, we propose an oxygen cylinder monitoring system which can be considered as a solution for the said problem.

Oxygen cylinder monitoring system is a low-cost solution for alarming issues such as deaths due to shortage of essential necessities like oxygen cylinders. This can be implemented on a commercial scale in an economic and simple to use manner in hospital storage facilities [3]. It can also be extended to monitor other important medical gases like Carbon Dioxide, Nitrogen, Nitrous Oxide and commercially used gases like Medical Air (which would be indicating to the clean supply of compressed air used for driving the ventilators, as a carrier for anesthesia agents and also incubators in hospitals).

Our project mainly focusses on providing the count of the oxygen cylinders present in a storage at any point of time. The device is semi-autonomous which requires the human user to input the number of oxygen cylinders in case of newly added cylinders. It is proposed to use a communication module so that the oxygen cylinder supplier can directly receive the message which reduces the notification delay due to human fallacies. Also, a mobile or a web application would have an even more effective impact where it could be monitored by Health Officials. Convolutional neural networks (CNNs) are used in designing oxygen monitoring system (OMS), since it can be used in analyzing image data.

This paper is organized as follows. Section 2 discusses the hardware components and software tools used in implementing this work. This chapter further discusses the working principle of the hardware prototype and also the work flow of the software in detail. Result of this work is explained in Sect. 3.

2 Methods and Materials

2.1 Hardware

2.1.1 Components

The main components for this oxygen cylinders monitoring system are Raspberry Pi and a web camera (Fig. 1).

Fig. 1
figure 1

Hardware setup of the proposed system

Raspberry Pi 4B

The Raspberry Pi 4B is a very compact, cost-effective, a powerful, and a miniaturized computer that is capable of being integrated with a standard computer. It comes in different models offering a wide range of specifications, namely, such as the Raspberry Pi 2, Raspberry Pi 3, Raspberry Pi 3B, Raspberry Pi 3B+, Raspberry Pi 4, Raspberry Pi 4B launched by the Raspberry Pi foundation [4].

USB Webcam

A webcam is typically a small video camera capable of recording a video that can feed or streams a video in a real time to a computer or through a computer to a computer network such as the Internet [5]. They are usually small and can be attached in any desired location. It is interfaced to the Raspberry Pi’s USB port through a USB hence making it easy to use.

2.2 Software

2.2.1 Programming Language and Platforms

Python: This is a general-purpose, high level, interpreted programming language used to program the Raspberry Pi. The execution command is written using this language is interpreted by the processor which in turn produces the desired results.

2.2.2 Operation System

The operating systems which was used in this prototype of Raspberry Pi is Raspbian (now Raspberry Pi OS). It is the operating system officially supported by the Raspberry Pi foundation for the series of Raspberry Pi. It comes in hand with ample amounts of software already installed for educational, programming and general-purpose uses. It has Scratch, Python, Java, Sonic pi and many more installed.

2.2.3 Machine Learning Algorithms

The machine learning algorithm used in this prototype is a convolution neural network (CNN) [6]. Typically, a feed forward neural network or a multiple hidden layer perceptron model with many layers in an artificial neural network (ANN) is usually known as deep neural networks (DNNs). CNN is an efficient algorithm for recognition which is extensively employed in the fields like recognition of patterns and processing of images. It has many advantageous aspects which include simplicity of the structure, requirement of less training parameters as well as examples and finally adaptability. It improves the model by reducing the complexity of the network by taking only a few features which are predominant for the identification and reducing associated weights [7].

Typically, the structure of a convolution neural network consists of two types of layers. They are a feature extraction layer (layers where filters are used to extract the data) and a feature mapping layer (a pooling layer where the image size is reduced by keep the features intact) [8]. The feature extraction layer is responsible for extracting local features from the input of every neuron connected to the local receiving fields of the previous layers. Once the features are extracted, the relationship between the extracted feature and other features would be determined. The other layer is responsible for the mapping of the features where every computing layer of the neural network composes a plurality of the feature map. Each feature map is a plane, the weight of the neurons in the plane is equal which helps the network learn in parallel. This is a major advantage attributed to a convolution neural network. The activation function used in a neural network is a sigmoid function which makes a feature map have full shift invariance. Every convolution neural network has a convolution layer which would be followed by a pooling layer (also known as computing layer). The pooling layer is used to calculate the local average and the second is to extract, and this distinct dual feature extraction structure reduces the size of the data (here resolution since it is an image). The process of the CNN is depicted in Fig. 2 which depicts the process the input being subjected to convolution filters and max-pooling layers and finally the output from the fully connected neurons.

Fig. 2
figure 2

Shows a representation of a multi-class classification convolution neural network

A convolution neural network algorithm consists of two very essential processes which would be convolution and pooling. The process of convolution uses a set of standard filters in start so that it can derive features which can be used to develop the trainable filters [9]. This convoluted image is now further subjected to a process called pooling which reduces the size of the image keeping the features intact. This process helps a lot as the model can now be trained faster and would more effective. The convolutions used here were of the size 3X3 filters which make the input of size MXN pixels to result in an image of size M-2XN-2 (since the edge pixels could not have a convolution output thus canceling layers on all the 4 sides). The pooling layer helps us in reducing the size by grouping pixels and returning a pixel that represents the group of selected pixels (the pooling layer used here was a max-pooling layer which takes a set of 4 pixels and returns the max value as the pixel represented.) thereby reducing the size of the image (data) which also has the features enhanced [10].

2.2.4 Python Libraries

TensorFlow is a free and open-source software library for dataflow and differentiable programming useful across a range of tasks. It is a symbolic math library used for machine learning applications such as neural networks [11].

OpenCV (Open-Source Vision Library) is an open-source computer vision and machine learning software library. It was built to provide a common infrastructure for computer vision applications [12].

H5py package is a python interface to the HDF5 binary data format. It lets you store amounts of numerical data and easily manipulate that data from Numpy. A HDF5 (Hierarchical Data Format) file is a container for two kinds of objects: datasets which are array-like collections of data and groups which are folder-like containers that hold the datasets and other groups [13].

Scipy is a python based ecosystem of open-source software for mathematics, science and engineering used for scientific and technical computing. It contains modules for optimization, linear algebra, integration, interpolation, special functions, FFT, signal and image processing, ODE solvers and other tasks common in science and engineering. It has core packages that include Numpy, Pandas, Matplotlib [11].

Numpy is a library for the python programming language which is predominantly used in the data science community for handling data for machine learning implementations. It helps extensively by adding support for large, multi-dimensional arrays and matrices (as mainly most data is stored in these data structures), along with a large collection of high-level mathematical functions to operate on these arrays. From a company point of view, this library finds its main uses in cleaning the data before it is further processed and refined [11].

Pillow is a python imaging library is a free and open-source library for the python programming language that provides support for opening, manipulating and saving many different image file formats [11].

2.3 Working Methodology

2.3.1 Circuit and Setup

The proposed OMS is designed by interfacing USB web camera with a Raspberry Pi. The working model is shown in Fig. 1 The task of powering the raspberry pi can be done by using power bank (as done in this prototype, also as a backup) but it is suggested to use it via an electrical socket so that it could be switched on at all times leaving no room for fallacies. Adhesives are used to secure the components in the desired locations, and care is taken so that the USB camera is properly fixed.

2.3.2 Working

This system setup has a camera placed near the exit door of a facility which helps in detecting the oxygen cylinders when being taken for use. The main focus of the project is that the camera sends a live image taken every 3 min. This 3-min time delay is considered because the model takes this specified time to execute and return a result. During this time interval, the image is processed and check for the oxygen cylinders in the image. If the system detects the oxygen cylinders, then the number of oxygen cylinders in the image are counted. If the total number of cylinders drops below, a threshold value then a message is displayed to notify the issue.

This implementation assumes that oxygen cylinders as shown in Figs. 3 and 7 are distinguishable on the basis of a color (which is Green in this use case) apart from other medical supply cylinders in the storage facilities. When an image consisting of a cylinder(s) with the appropriate color is obtained as an input then this process of detection, as in Figs. 4, and 8 would take place.

Fig. 3
figure 3

Green color marked oxygen cylinder on a stand support

Fig. 4
figure 4

Output of the machine leaning model in the console when input as in Fig. 3 is given

Code Summary

The flow diagram of the proposed work is given in Fig. 5. At first, the data has been collected, i.e., in this case, the input data is the images of the cylinders in a stock house. The entire dataset has been divided into training, validation and test sets. Now after dividing the data into the training, validation and test sets, the data has been reshaped and was normalized (to make all the features to be of the same scale which makes it easier for processing). Now using the keras library, we use a 2-D convolutional neural network to process the data [14]. We use max-pooling, followed by flattening and finally a dense layer to calculate the weights thus training the machine learning model. We can use different parameters to define the model. We have used an Adam optimizer, loss calculation using a binary categorical cross-entropy with the metric being used is accuracy [15]. The model learns the features from the training images to detect the desired objects from the set of images given as input [16]. We finally fit the model using these metrics and the data. We define a function to stop the model evaluation when the accuracy is reached to a desired threshold level (95% in this case) on the test data. Once the desired accuracy is obtained, we stop the model and it is capable of detecting a new test image on an unseen images thereby detecting the required object by using the feature learnt from the training data [17]. The code also draws a contour around the required object to be detected thus making it easier to cross verify the results as in the case of Figs. 6 and 9. Since a CNN used was a 2-D network, it can only detect the cylinders that are shown (clearly depicted) completely. When the multiple cylinders with slight colored to differentiate, Fig. 7, as oxygen cylinders are given as input [18], then we see a slight decrease in probability as the training had a few images of that sort hence the result obtained as in Fig. 8.

Fig. 5
figure 5

Flowchart for the oxygen monitoring system using convolution neural networks (CNNs)

Fig. 6
figure 6

The contour around the oxygen cylinder to represent the detected object

Fig. 7
figure 7

Multiple oxygen cylinders in a plane surface

Fig. 8
figure 8

Output of the machine leaning model in the console when input is a single-oxygen cylinder as in Fig. 3

Fig. 9
figure 9

The contour across each and every cylinder detected to represent detected objects

3 Results and Discussions

The prototype proposed detects all the oxygen cylinders present in an input image. It also gives a probability of the model predicting that the object would be an oxygen cylinder. The oxygen cylinders are detected based on the color which is green as in the use case presented here. It was also tested in various shades of lighting to observe the effects of lighting with the model always predicting the right output. It also maintains the count and updates it as soon as an oxygen cylinders are detected. The count when decreases beyond a previously set threshold it notifies the vendor (Fig. 10) once the count falls beyond the threshold. The prototype is robust and would have the capabilities to operate in incase of a power cut as it uses a portable power bank as a backup supply.

Fig. 10
figure 10

Output in the console when the threshold limit is exceeded

4 Conclusion

This project can be further developed by employing the use of a communication module like a GSM (Global System for Mobile Communications) that would be helpful for direct communication with oxygen cylinder supplier so as to reduce any human fallacy. Also, a website with a database which could see all the entries being logged in would be very helpful for health officials monitoring the quantity of all cylinders in all hospitals.