Turning a simple camera into a flood warning service

A Research and Innovation story

In an urban environment with rivers that can burst out of their banks within a blink of an eye, every minute counts. Early warning can make that difference, but in order to issue early warning, forecasting systems, fed by monitoring need to be in place. The most tangible and practical forecast can be provided by a gauge that measures water levels and river flows upstream, several hours travel time distance from the area of interest. But flow observations are difficult to establish and maintain, because equipment is expensive, sensitive to damage during high flows, and mostly needs to be positioned on a bridge, exposed to theft and vandalism. That is why Resilience Academy partner Delft University of Technology, conducted an MSc study to figure out if simple CCTV cameras can do the job. MSc student Gerben Gerritsen worked with Uhuru Labs and Open Map Development Tanzania to establish a camera-based flow observation site observing flows in the Chuo Kikuu river in Dar es Salaam.

By Hessel Winsemius, Gerben Gerritsen, Frank Annor, Frederick Mbuya, Ivan Gayton

Left: Freddie Mbuya fixing camera rig to his compound perimeter wall. Right: Chuo Kikuu in flood.

The MSc project spinned off from a project “Community Water Watch”, funded by the Netherlands Enterprise Agency, collaborating with the Tanzania Urban Resilience Program. A first pilot flood dashboard was set up by a team consisting of Deltares, the Trans-African Hydro-Meteorological Observatory (TAHMO), Delft University of Technology and FloodTags. This pilot forecasting and situational awareness system now simulates floods from IoT rain observations and hydrological models, and provides situational awareness by placing Red Cross Volunteers’ WhatsApp Group messages on a map, through an innovative text mining solution made by FloodTags.

Flood dashboard by the Community Water Watch consortium

It was recognized that especially short term forecasts can have a much better skill by simply measuring river flow a few hours distance (as the water travels) upstream. Also, the used hydrological models need to be calibrated to improve their performance, and that requires time series of river flows as well. Simple? No, this is not simple at all! Measuring flows is tough as exemplified in the introduction of this blog!

A relationship between flow and water levels is also called a “rating curve”. Establishing a rating curve means measuring water levels and flow at the same moment, and doing this for several moments, preferably in a range of low to high flows. Water levels is simple: make a fixed staff gauge, for instance with a rod or by painting it on a perimeter wall, bridge or anything that you can easily relate to, and simply take a reading. Flow is hard! You have to physically touch the water and take instruments along with you, for instance a relatively cheap propeller device with which you measure velocities at several points in a cross section, or a more expensive (in the order of 20,000 USD) Acoustic Doppler Current Profiler, that you can drag across the stream. This device uses acoustics and the principle of Doppler to estimate flows across an entire depth.

It is quite easy to see the difficulties here. You need lots of samples during different flow conditions to get a good relationship between depth and discharge. You also have to be aware when to go into the field, especially when you wish to observe a high discharge. And what about safety: we would not recommend anyone going into the water above knee-deep when velocities are in the order of 2 meters per second. You will be dragged away, and the risk of you or your equipment being hit by debris is large. In summary, establishing a rating curve is difficult, time consuming and at times dangerous, and equipment needed can be easily damaged during the cause.

Resilience Academy is about enabling local technology for urban resilience. Therefore Gerben Gerritsen, MSc student with Delft University of Technology, assisted by Freddie Mbuya — Uhuru Labs and OpenMap Development Tanzania, started investigating whether a dry period bathymetric survey, and a low-cost automatic CCTV camera can be used for monitoring flows using strictly open-source software and methods. Commercial proprietary methods exist, but these are difficult to sustainably implement in a city such as Dar. You’d have to rely on international consultancy, a pre-specified camera platform that is difficult to import and sustain locally, and proprietary licensed software. The problems related to equity and equality with this are described in another excellent blog by Ivan Gayton. If a locally available camera can work with an open-source software solution, then this has huge advantages. Not only is the technology widely available, does it relieve an observer of the dangerous task to physically go into the water, whilst guaranteeing that critical events are not missed, it also provides a basis for wider local research and innovation. Once embedded in universities, this will lead to students getting new transformative skills with affordable and scalable technology when they start thinking about their future work in for instance innovative tech industries or with governments.

Orthorectified movie of the Chuo Kikuu experimental site. You can see that through orthorectification, it looks as if the video is taken from above the stream.

Ok! Let’s give a little bit more technical insight. What did we do exactly? To measure the river flow, we use a method called “Particle Image Velocimetry” (PIV) on short movie snap shots of a stream section where we know the bathymetry (i.e. the under-water topography). This wikipedia article gives insight in what PIV is, does and what it can be used for. In summary, with PIV, you trace how “stuff” moves through the water. Your eyes also spot things moving in a stream as exemplified by the movie above. If you are able to spot these movements with your eyes, then computers can also compute that movement for you! In fact, through PIV computers can calculate the actual velocities in metres per second on the surface for you by looking at movements of “stuff” from frame to frame. It’s because we are not exactly above the channel, that the frames need to be converted into a real distance plane through a process called “orthorectification”, which is applied on the movie example above. This is done using 6 control points for which the relative position horizontally and vertically are exactly known. The figure below shows the entire process schematically. You can see the control points as black-and-white markers in the field next to the stream so that they can easily be recognized. Once the velocities at the surface are known, we can use the bathymetry to interpret what’s going on beneath the surface. By using physical principles, Gerben also managed to interpret what’s going on in parts of the river section that are obscured by vegetation or shade, making this solution work even in partly obscured and less ideal sites. If you want to know more about this, we invite you to read his thesis work.

Particle Image Velocimetry explained in graphics (source: Gerritsen, G. (2020) “Flood Wave Monitoring using LSPIV”, MSc thesis — Delft University of Technology, Delft, The Netherlands)

The bathymetric profile can be taken with yet another innovation, introduced through Resilience Academy activities, Real-Time Kinematics GPS positioning with the uBlox ZED-F9P chipset. Earlier MSc thesis work by Kirsten van Dongen with OMDTZ showed that elevation can be acquired within 5 cm accuracy, and OMDTZ is now providing services to acquire such bathymetry in streams such as the Msimbazi. Another blog about that was published recently by OMDTZ. Please check it out for more information.

Bathymetric profile surveyed at the Chuo Kikuu experimental site.

To develop, test and demonstrate the feasibility of this method, we worked with Uhuru Labs. An experimental site was established on the perimeter of Freddie’s house (CEO of Uhuru Labs) at the Chuo Kikuu. The channel bathymetry was surveyed. Results are displayed above. During one single event, the relationship between water depth and discharge was entirely estimated without any contact with the water using two open-source libraries: a) OpenCV for lens corrections, orthorectification and gray scale corrections, and;

b) OpenPIV for Particle Image Velocimetry. Gerben and his fellow student Sten Schurer, who worked on a similar case in the Luangwa river in Zambia put together Python scripting to combine the operations and add the interpretation of obscured areas and processing into flows and their uncertainty. These scripts provide a good basis for operationalizing this work in open-source software, finally opening up this technology for use in low income countries.

Situation surrounding the Chuo Kikuu experimental site

During one single event, Gerben automatically collected 73 short videos, and converted these into flow and water depth estimates. The results are shown below. Each dot in the graph represents one estimate of water depth (vertical axis) and discharge (horizontal axis). Consequently a full rating curve was established using one single event. No lengthy field work, no dangerous situations, and no expensive hardware were needed whatsoever.

Now, we only need to record water depths and we can simply look up the discharge in the graph below. This is perfectly possible with a simple staff gauge, still photos taken by the same camera, and a little bit of automated image analysis. This is the next stage. TAHMO is already installing a batch of more permanent cameras as we write up this blog. We hope to get Tanzanian students working on refining rating curves, and a method to automatically read water levels from still photos.

Relationship between water level and discharge, measured through cameras during one single high flow event.

Once we are able to conduct operational readings in this way from solely a simple fixed camera and some open-source software, it is not difficult to imagine that a local service provider (startup, or a basin authority) can rapidly extend the river gauging network, not just in Dar es Salaam, but in Tanzania, Africa and beyond. Such additional sites can be pivotal for warning downstream located communities. Imagine for instance that a text message can be sent automatically to downstream communities, when a certain flow threshold is observed in this location. This will give those communities time to take precautionary actions, and prevent unnecessary impacts on their livelihoods, simply because there is a CCTV camera that watches the stream for them continuously. Resilience Academy members will keep working on this, ensuring that the technology can be deployed and maintained with local people, local devices and open knowledge.



Universities in Tanzania working on Climate Risk Data Repository, University Student internships cooperation and develop open-access edu materials and training.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Resilience Academy

Universities in Tanzania working on Climate Risk Data Repository, University Student internships cooperation and develop open-access edu materials and training.