Uses Flask to set up a webserver and streams raspberry pi camera feed on to /feed
Use ifconfig's wlan0 (or equivalent) inet address to access the feed on a different device on the same network.
Then you should be able to go to your browser and connet to http://<inet address>:5000/feed to see the feed on a computer that's conneted to the same network as the raspberry pi.
File Structure:
.
├── backend
│ └── notification_service.py # Notification Microservice
├── camera_test.py # test files for camera
├── frontend # Frontend Admin Panel
│ ├── server.py
│ └── templates
│ └── index.html
├── haarcascade_frontalface_alt2.xml
├── kafka_test.py
├── louis.pickle
├── server.py # main server
└── webhook.py # util for controlling the server
- Raspberry Pi 4 B
- Raspberry Pi Camera V2
- (Optional) Cooling gadgets
ssh-keygen -t ed25519 -C "your_email@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Then add the following catted content to your Github Account
cat ~/.ssh/id_ed25519.pubIn your terminal, run
ssh git@github.comTo check if you have set up ssh keys successfully
- Should be already installed with your raspberry pi system distro
Remove externally-managed-environment warning
sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.oldThen install the necessary dependencies
sudo apt-get install python3-opencv
sudo apt-get install build-essential cmake
sudo apt-get install libgtk-3-dev
sudo apt-get install libboost-all-dev
wget https://github.com/prepkg/dlib-raspberrypi/releases/latest/download/dlib_64.deb
sudo apt install -y ./dlib_64.deb
rm -rf dlib_64.deb
pip3 install face_recognition --no-deps
pip install git+https://github.com/ageitgey/face_recognition_modelsWARNING: installing dlib from pre-compiled binary
wget https://github.com/prepkg/dlib-raspberrypi/releases/latest/download/dlib_64.deb
sudo apt install -y ./dlib_64.deb
rm -rf dlib_64.debIs only available on 64 bit machines.
First clone the repo:
git clone git@github.com:louisunlimited/CS437_Final_Project.git
cd CS437_Final_ProjectThen create an .env file containing the following variables
KAFKA_SERVER_URL=
KAFKA_USERNAME=
KAFKA_PASSWORD=
SERVER_HOST=
WEBHOOK_PORT=3000
SERVER_PORT=5000Where
SERVER_HOSTis your local ip addresswlan0:inet, you can find this withifconfigon your pi
Run
python3 server.pyTo start camera server
Confirm the server is working by going to http://{rasp_ip}:{SERVER_PORT}/feed
Run
python3 webhook.pyConfirm the server is working by going to http://{rasp_ip}:{WEBHOOK_PORT}
sudo touch /etc/systemd/system/server.servicepaste the following into server.service: CHANGE\ and accordingly.
[Unit]
Description=Primary Flask Application
After=network.target
[Service]
User=<USER>
WorkingDirectory=<PWD>/CS437_Final_Project
ExecStart=/usr/bin/python3 <PWD>/server.py
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Then run
sudo systemctl enable server.service
sudo systemctl start server.serviceto start these system services,
You can check the status with
sudo systemctl status server.serviceNow we do the same for the webhook service
sudo touch /etc/systemd/system/webhook.servicepaste the following into webhook.service: CHANGE\ and accordingly.
[Unit]
Description=Primary Flask Application
After=network.target
[Service]
User=<USER>
WorkingDirectory=<PWD>/CS437_Final_Project
ExecStart=/usr/bin/python3 <PWD>/server.py
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Then run
sudo systemctl enable webhook.service
sudo systemctl start webhook.serviceto start these system services,
You can check the status with
sudo systemctl status webhook.serviceNow if you reboot your raspberry pi, as soon as your pi is connected to the internet, the above two service should be up as well,
You can issue a reboot like this
sudo rebootCongrats! Now you are all set!