Goal of project is to store detected images in a distributed database. Hyperledger fabric is used to store detected images. This readme file explains how to setup the IoT network which sends detected images to IoT Gateway.
Project is created using:
- Python 3
- Flask
- HTML,CSS for frontend
- python requests to send post data
In this project Pi acts as a IP camera. Before running code, check if pi camera is working. You can also use a web-cam to run this project. Open termianl
$ sudo raspi-config
Selelt Interface, then enable Pi camera and select Finish. Check that camera is working by running this command in terminal
$ raspistill -o imgname.jpg
Clone the project using the following command
$git clone git@github.com:vybhav-bhadri/pi-face_detection.git
This project is using openCV which creates camera objects, and haar cascade classifier is used for facial detection. Install openCV using the folllowing commnads.
$sudo apt update
$sudo pip install python3-opencv
Navigate to the repository directory
$ cd pi-face_detection
Install all the dependencies by running this command
$pip install -r requirements.txt
Start server
$python3 run.py
In code main.py has logic to send JSON Data, camera.py has the logic to detect faces
payload = json.dumps({"Face_Id":face_id,"ImageData": im_b64,"Timestamp":timestamp,"Device_Id":device_id},default=str)
To send post request to an api end point
response = requests.post(api_test, data=payload, headers=headers)
Stream can be viewed by entering localhost:5000 in your browser.You can also access the stream locally by entering ip address of the rasberry pi running the server. To find the local IP address of your Pi, open terminal and run
$ifconfig
To access stream remotely, use ngrok to expose a local tunnel. Start the local server and run ngrok with this command, visit ngrok and check documentation for setup.
$./ngrok http 5000
This will generate a link and use this link to access stream.