Horizontaly Scalable, Distributed system to churn out video feeds & infer analytics
Intent of this project is to build a Minimalistic, Horizontally Scalable, Distributed system to churn out volumes of data & provide meaningful insights into the same.
The current use case we are pursuing is that of churning CCTV footage & provide a Search Interface to query something like:
- How many Cars and Motor Bikes passed through given area in the given time period?
- What all the visitors cars entered in the residential complex? How much time they were parked in?
- many more...
Answers to these queries may be useful for Security or finding patterns etc.
One can find many solutions for solving problems related to Computer Vision & data analytics in-general. However, most of these solutions are either in the form of technology (e.g. training a good face recognition model) or full blown product, which could be over-sophisticated.
Our goal is to build something that works, which is easily testable & has minimal number of moving components, which can be used as a base for developing a full-blown product.
This project doesn't focus on the Technology aspect. i.e. we are not focusing on, how best we can develop a license-plate recognition system. Instead, we leverage all open-source code & rather focus on orchestrating them in a highly cohesive, loosely coupled way.
This is currently tested on Ubuntu-Linux. However, only thing it expects is to have docker & docker-compose installed. Since everything runs inside the container, it should work on Windows & Mac as well (barring the helper bash scripts), though I haven't tested it.
-
Change directory to that of the app
cd cctv-surveillance -
Spin up Kafka Cluster
docker-compose -f ../docker-compose-kafka.yml up -d # This spins up Kafaka as well as services for visualizing & administrating Docker Containers (Portainer) and Kafka message (Kafdrop) -
Edit the environment for options, especially for picking up the input video data files
source .env -
Download YOLO weights file
wget -O services/object_detector/yolov3.weights "https://pjreddie.com/media/files/yolov3.weights" -
Run the App, by spinning up all required services
docker-compose up -d
-
Point your browser to http://localhost:9001 to browse through docker containers
-
For outputput images, browse to your docker-volume
cctv_surveillance_resultswhich should be mounted at/var/lib/docker/volumes/cctv_surveillance_results/_dataon host machine
- Though the current use-case is for churning out CCTV footage data, this project can be used to build any app that works on Stream of data. Each app is mapped to separate folder e.g. cctv_surveillance.
- Every app is simply a composition of multiple microservices, which communicate to each other through Kafka Message Broker
- The Kafka Messages are serialised with Protocol Buffer.
- The CCTV Surveillance app is structured as follows:
Video Frames Stream |- | motion-detector (A) | object-detector (B) | license-plate-detector (TODO) | face-detector (C) | face-matcher (D) | logstash pipeline (E) | ElasticSearch | Kibana (TODO) A: motion-detector: Most of video frames from CCTV involves non-activity & can be thrown right-away. This service takes a diff btw current frame & baseline frame, to determine if there is an activity B: object-detector: Applies YOLO object detector to see what objects are seen in the frame e.g. human, car, cat etc. C: face-detector: If there is human detected, then try to detect the face D: face-matcher: If a human face is detected, then check if it matches with anyone in database E: Logstash is simply *watching* the Kafka messages produced by various microservices, as well as their logs. It applies transformation pipeline & finally indexed them into Elasticsearch. This code is maintained inside HCL Open Source repository under MIT license. This is not an official HCL ERS product
- Code for "Object Detection" and "Motion Detection" for CCTV is taken from following excellent tutorials by Adrian Rosebrock
- References