Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assignment 2 - Rearview Camera

The goal of this assignment was to create a rearview camera which could assist drivers when reversing their vehicle. I decided to create this type of device as my own car is an older model and has no reverse assistance. The camera begins recording when the device moves. While recording, it detects and identifies any objects within the frame, if an object takes up a certain percentage of the frame is creates a proximity alert for the driver.

Installation

This program is written using Python and some HTML, it can be downloaded and used on a Raspberry Pi or similar device. If using a Raspberry Pi, I recommend the 4B Model with an attached SenseHAT and a Raspberry Pi Camera as this is the hardware that I used.

In order to ensure that this program runs on your device, you must ensure that it is set up correctly with all of the relevant libraries installed.

Set Up Raspberry Pi

  1. Install Raspberry Pi OS onto a microSD card – ensure that you set a hostname, username and password
  2. While the device is off (and unplugged), insert the microSD and boot up the device. Once the device is active, find Raspberry Pi using:
nmap -sn <Network> 

If you have trouble finding your device IP Address, you can ping the hostname of your device to see if it is on your network

ping <hostname>
  1. Once the device is active, access it's Secure Shell (SSH) Protocol to securely send commands to your device. You can access SSH with the following command - replace user, Ip address, and hostname with your own information:
ssh user@ipaddress/hostname
  1. Check that your Raspberry Pi is up to date with before installing any additional libraries.
sudo apt-get update
sudo apt-get upgrade
  1. Now we can install all the libraries necessary to run this program. Start with installing SenseHAT -
sudo apt-get install sense-hat 

This will allow us to use the accelerometer within the SenseHAT to act as our motion detection for the camera activation. 6. Next, install the Pi Camera. For this, we need the picamera library, as well as OpenCV to ensure the camera functions as required.

sudo apt install python3-picamera
sudo pip3 install opencv-python 
  1. Numpy is used so that the program can work with arrays. These are used when dealing with the coordinates needed to detect movement and relevant objects.
sudo pip3 install numpy 
  1. Lastly, we need to install Blynk. This was the library I had the most trouble getting installed, as the general installation only installed older versions of the library, which does not run with our program. The most effective workaround I have found is the following:
pip install git+https://github.com/vshymanskyy/blynk-library-python 
  1. With this, your Raspberry Pi should be correctly set up to run the rearview program.

Usage

Start running the program using:

python rear_camera_v3.py

When it runs effectively you should be able to watch the stream through the webpage (http://:5000).

image

If BLYNK functions correctly, you should be able to check your data in the device dashboard.

Screenshot 2024-12-30 220238

If BLYNK fails, then the data should be visible on the same webpage that streams the video.

While the device is in motion and there are objects detected in frame, the LEDs should flash green. If an object gets too close to the camera (i.e. it takes up a certain percentage of the frame) this will set off the proximity alert and the LEDs should flash red.

Support

The following YouTube videos can help with getting you started:

Used Sources & Additional Resources

Previous Rearview Examples

Video Streaming

SenseHAT

Object Detection

Additional Resources

Contribute

Contributions and improvements are always welcome!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages