Skip to content

System that detects danger levels relative to drivers. Once a driver overpasses a biker, the system detects this unauthorised act, and responds by recognising the car plate in order to contact law enforcements..

License

Notifications You must be signed in to change notification settings

OmarJabri7/Cycle_Buddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cycle Buddy - Team 16

⭐️Explore Our website»

Logo

⭐️Explore the doxygen»

Built by cyclists, for cyclists, keep safe with Cycle Buddy!

              

Contributors Forks Stars Issues License

Contents

  1. About
  2. Software
  3. Hardware
  4. Roadmap
  5. Packages
  6. Usage
  7. Results & Real-Time Responsiveness
  8. Contributing
  9. License
  10. Contact
  11. Acknowledgments

About

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.

⭐️ Doxygen about the project

Circuit of Cycle Buddy:



Figure 1: Indoor circuit of Cycle Buddy



Figure 2: System design concept





Software

Necessary:

  • 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.

  • OpenALPR - Automatic License Plate Recognition (API)

​ 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.

Optional:

  • 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.


Hardware

Main device:

  • 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.

Sensors:

  • 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.

Other auxiliary tools :

  • 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.


Roadmap

See the open issues for a list of proposed features (and known issues).

Threading Pipeline

The system is split into three threads:

  1. Main Thread that extracts information from the remaining threads and sends them to the mobile application
  2. 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.
  3. 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.

Package Prerequisites

  • WiringPi
  • Raspicam
  • OpenALPR
  • JSON
  • Cmake
  • Pyrebase

Packages Installations

Before install any packages, please run the following:
sudo apt-get update && upgrade

  1. WiringPi:
    sudo apt-get install wiringpi

  2. 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

  3. OpenALPR: (Github page)
    sudo apt-get update && sudo apt-get install -y openalpr openalpr-daemon openalpr-utils libopenalpr-dev

  4. 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

  5. Cmake : (Website)

    Click and download it from the website above.

  6. Pyrebase: Github page
    pip3 install pyrebase
    pip install pyrebase

  7. Android APK File:
    Just download the Android Application onto your phone and enjoy!

Usage

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:

  1. Clone the project with:
    git clone https://github.com/OmarJabri7/Cycle_Buddy.git
  2. Change directorites and relocate in Cycle_Buddy project:
    cd Cycle_Buddy
  3. Make Build directory containing all executables:
    mkdir build && cd build
  4. Link the necessary executables and libraries using CMake (in build dir):
    cmake ..
  5. Build the project using make (in build dir):
    make
  6. Before Testing and Running the system:
    Be sure to either use our GPIO setup, or change to your own in:
    GPIO numbering
  7. Generate Unit tests and check if all components pass (in build dir):
    make test
  8. Go to main directory: cd ..
  9. Make sure you have permissions to execute run.sh:
    chmod +x run.sh
  10. 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)


Results & Real-Time Responsiveness:

  1. 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:



Figure 3: Real time demo

  • 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.
  1. 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:

results-appresults_outdoor

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.


  1. 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).


Contributing

This is an open-source project, therefore, just fork it and build up the project according to the README.md in every document.


License

Distributed under the GPL-3.0 License. See LICENSE for more information.


Contact




⭐️ Project address - @Project address

⭐️ Project address - @Cycle Buddy Website

Acknowledgments

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.

About

System that detects danger levels relative to drivers. Once a driver overpasses a biker, the system detects this unauthorised act, and responds by recognising the car plate in order to contact law enforcements..

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages