⭐️Explore Our website»
⭐️Explore the doxygen»
Built by cyclists, for cyclists, keep safe with Cycle Buddy!
We are a group of graduate students currently studying at the University of Glasgow. This github page represents our coursework for Real-Time Embedded Programming Project supervised by Dr. Bernd Porr and Dr. Nicholas Bailey. Our team, is enriched by two members majoring in Robotics & Ai, one member majoring in Electronics and Electrical Engineering.
Our project, Cycle Buddy, is a system that detects cars that endanger everyday cyclists.
Once the car overpasses the biker's path with a relative high speed and within a close distance, the system can detect this unjust act and stimulates a camera to capture the car's plate number and recognizes it using a Computer Vision API.
Then it will send the plate number, its photo and the relevant sensor readings to the mobile application through socket connections, which then stores the proof data in an online real-time database. With those infomation recorded as evidence, the bikers can then use it to contact local law enforcements to report the issue.
Figure 1: Indoor circuit of Cycle Buddy
Figure 2: System design concept
-
Android Studio (Mobile Phone Application)
Android Studio provides the fastest tools for building apps on every type of Android device. We use it for connecting the raspberry pi and get real-time information from the raspberry pi, such as car distance, car velocity, and bike velocity.
-
Visual Studio 2019 (Raspberry pi threads)
Visual Studio 2019 has the latest features to bring real-time collaboration so it is convenient for us to write C++ code for their project.
-
Firebase (Real time database)
Firebase is Google’s mobile application development platform that helps you build, improve, and grow your app. It manages our data and stores our license plate numbers which are from the Pi camera.
-
Cmake (Build up the full project)
CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of our choice.
-
Doxygen (document generation tool)
Doxygen is a document generation tool that extracts documents from code, organizes them, and outputs them into beautiful documents (HTML, PDF, RTF, etc.).
With the Doxygen tool, programmers can write code directly in the document, no longer need to write a separate document for a function of the code, thus keeping the document and code as consistent as possible.
This API can recognize the license plate number directly from the picture, we find a GB (Great Britain, UK) lib trained model and use it.
-
Putty
Simplifies SSH connections to the Raspberry Pi.
-
VNC (Other Remote Desktop Services are also fine)
Use ssh services to log in to the raspberry pi so that we do not need to use HDMI or screen to connect to the raspberry pi. It is also convenient to use UI to code in raspberry pi.
-
Typora
Edit markdown and Html files for Doxygen and web page in a clear setup.
-
Search for the car information
Here is the government website to search for the car information, so when we get the license plate number, we can extract the car information to alert the authorities.
-
Raspberry Pi 3 Model B + (£33.90, 1 is needed, not included)
The Raspberry Pi 3 Model B is the earliest model of the third-generation Raspberry Pi. In our project, It can receive the real-time signals of the GPIO from all the sensors and deal with the real-time data.
-
Hall sensor (£4.49, 1 is needed)
We use a hall sensor to detect the velocity of the bike. The theory is to put the magnets on the axle of the bicycle wheel. Make sure the hall sensor is close to magnets enough so that it can detect the magnetic field when the bike runs. Hence estimating the bike's velocity from the rotations of the wheel.
-
Ultrasonic sensor(£3.99, 1 is needed)
The Ultrasonic sensor is to detect the distance between the bicycle and car. Alongside, calculating the velocity of the incoming car by differentiating its position.
-
Pi camera (£10.99, 1 is needed)
The Pi camera is used to capture the picture of the car plate. We found a feasible location for the Pi camera so that it has a strategic point to always capture a clear view of the plate number.
- Male/Male, Female/Female and Male/Female wires ,magnets (approximately £ 2.34)
- GPIO Breakout Kit Expansion Board For Raspberry Pi 3 B+ (£14.49)
- Power supply for Raspberry Pi or Power bank. (£ 13.56)
Overall, it costs us £49.86 except the Raspberry Pi 3 Model B + for the project.
See the open issues for a list of proposed features (and known issues).
The system is split into three threads:
- Main Thread that extracts information from the remaining threads and sends them to the mobile application
- Ultrasonic Sensor thread, event driven thread that captures readings from the sensor and sends the data through a socket connection to the application which plots it in real time.
- Hall Effect Sensor thread, event driven thread that captures readings from the sensor and sends the data through a socket connection to the application which plots it in real time.
- WiringPi
- Raspicam
- OpenALPR
- JSON
- Cmake
- Pyrebase
Before install any packages, please run the following:
sudo apt-get update && upgrade
-
WiringPi:
sudo apt-get install wiringpi
-
Raspicam : (For Pi camera)
Download folder from that link and:
a.tar xvzf raspicamxx.tgz
b.cd raspicamxx
c.mkdir build
d.cd build
e.cmake ..
f.make
g.sudo make install
-
OpenALPR: (Github page)
sudo apt-get update && sudo apt-get install -y openalpr openalpr-daemon openalpr-utils libopenalpr-dev
-
JSON Library: (Github page)
sudo apt-get install -y nlohmann-json-dev
If the above method does not work, please try the following:
a.git clone https://github.com/nlohmann/json.git
b.cd json
c.mkdir build
d.cd build
e.cmake ..
f.make
g.sudo make install
-
Cmake : (Website)
Click and download it from the website above.
-
Pyrebase: Github page
pip3 install pyrebase
pip install pyrebase
-
Android APK File:
Just download the Android Application onto your phone and enjoy!
This project is built using Cmake and Makefiles in order to allow users to easily run our code and tets it.
Please follow these necessary steps:
- Clone the project with:
git clone https://github.com/OmarJabri7/Cycle_Buddy.git
- Change directorites and relocate in Cycle_Buddy project:
cd Cycle_Buddy
- Make Build directory containing all executables:
mkdir build && cd build
- Link the necessary executables and libraries using CMake (in build dir):
cmake ..
- Build the project using make (in build dir):
make
- Before Testing and Running the system:
Be sure to either use our GPIO setup, or change to your own in:
GPIO numbering - Generate Unit tests and check if all components pass (in build dir):
make test
- Go to main directory:
cd ..
- Make sure you have permissions to execute run.sh:
chmod +x run.sh
- Run the bash script labeled run.sh:
./run.sh
Youtube Links:
How to setup the system
How to run the system (full flow of execution example)
- The Gif below demonstrates the real time nature of the system, where each sensor reading is sent to the android application and plotted in real time:
- It is clear to note how the timestamp emerging from the raspberry pi is the same as the one displayed in the android app. This reinforces the real-time responsiveness of our system.
- The image below demonstrates how the system triggers the Pi Camera to capture an image of the car plate and recognizes it using the OpenAlpr API:
Figure 4: Indoor and Outdoor results
-
On the left, we have the results from the indoor testing, where the car plate is displayed on a phone screen.
-
On the right, we have the results from the outdoor testing, where the car plate is captured by the camera on the streets of Glasgow.
-
Moral of the story is, that the api is capable enough to recognize the car plates within any environment. Moreover, the data displayed under the Car Plate are the sensor readings at the instant of capturing the image. Thus, ensuring that the system operates in real time.
- The final thing to notice is how the system saves the relevant data once the image is captured, reinforcing the idea of a real-time embedded system:
Figure 5: Real time & Results snapshot
- Notice how the car plate is equivalent (green square), alongside car distance, velocity and bike velocity (red square).
This is an open-source project, therefore, just fork it and build up the project according to the README.md in every document.
Distributed under the GPL-3.0 License. See LICENSE
for more information.
- System build: Omar Jabri - @Omar Jabri
- System design: Chang Liu - @Chang Liu
- System integration: Yifan Xie - @Yifan Xie
⭐️ Project address - @Project address
⭐️ Project address - @Cycle Buddy Website
For a wrap up, we would like to show our appreciation to:
- Dr. Bernd Porr for guiding us on the necessary modules to use in the system and for valuable tips and advices regarding the real-time aspect behind our system
- Dr. Nicholas Bailey for showing us the necessary tricks and tools to document and market our product in a professional and efficient manner.
- All teaching assistants for being there whenever we had questions and doubts and aiding us on moving forward.