commit f29ba428d682756d4247b3b8119dffce130b6266 Author: Eben Date: Mon Sep 21 21:44:29 2020 +0100 Pi Camera Stream diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..cbf17a2 Binary files /dev/null and b/.DS_Store differ diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..db2abec --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) SmartBuilds.io, Inc. and its affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3fd499e --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Make you own Raspberry Pi Camera Stream + +Create your own live stream from a Raspberry Pi using the Pi camera module. Build your own applications from here. + +## How it works +The Pi streams the output of the camera module over the web via Flask. Devices connected to the same network would be able to access the camera stream via + +``` + +``` + +## Screenshots +| ![Setup](img/readme/[].png) | ![Live Pi Camera Stream](img/readme/[].png) | +|---|---| +| Pi Setup | Pi - Live Stream | + +## Preconditions + +* Raspberry Pi 4, 2GB is recommended for optimal performance. However you can use a Pi 3 or older, you may see a increase in latency. +* Raspberry Pi 4 Camera Module or Pi HQ Camera Module (Newer version) +* Python 3 recommended. + +## Step 1 – Cloning Raspberry Pi Camera Stream +Open up terminal and clone the Camera Stream repo: + +``` +bash cd /home/pi +git clone [] +``` + +## Step 2 – Launch Web Stream + +Note: Creating an Autostart of the main.py script is recommended to keep the stream running on bootup. +```bash cd modules +sudo python3 /home/pi/[]/main.py +``` +## Download Beta image of Raspberry Pi Camera Stream +Any troubles installing, try out the already compiled Raspberry Pi (Raspbian OS) Image of [Raspberry Pi Camera Stream](https://smartbuilds.io). +![Raspbian Camera Stream Image](img/readme/[].png) diff --git a/camera.py b/camera.py new file mode 100644 index 0000000..6992fa0 --- /dev/null +++ b/camera.py @@ -0,0 +1,28 @@ +#Modified by smartbuilds.io +#Date: 27.09.20 +#Desc: This scrtipt script.. + +import cv2 +from imutils.video.pivideostream import PiVideoStream +import imutils +import time +import numpy as np + +class VideoCamera(object): + def __init__(self, flip = False): + self.vs = PiVideoStream().start() + self.flip = flip + time.sleep(2.0) + + def __del__(self): + self.vs.stop() + + def flip_if_needed(self, frame): + if self.flip: + return np.flip(frame, 0) + return frame + + def get_frame(self): + frame = self.flip_if_needed(self.vs.read()) + ret, jpeg = cv2.imencode('.jpg', frame) + return jpeg.tobytes() \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..fa5fb62 --- /dev/null +++ b/index.html @@ -0,0 +1,189 @@ + + + + + + + +Make - PiStream + + + + + +
+ + + +
+ + + + + + + + + + + + + + + diff --git a/main.py b/main.py new file mode 100644 index 0000000..f233a4a --- /dev/null +++ b/main.py @@ -0,0 +1,26 @@ +#Modified by smartbuilds.io +#Date: 27.09.20 +#Desc: This scrtipt script.. +# main.py + +# import the necessary packages +from flask import Flask, render_template, Response +from camera import VideoCamera +app = Flask(__name__) +@app.route('/') +def index(): + # rendering webpage + return render_template('index.html') +def gen(camera): + while True: + #get camera frame + frame = camera.get_frame() + yield (b'--frame\r\n' + b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n') +@app.route('/video_feed') +def video_feed(): + return Response(gen(VideoCamera()), + mimetype='multipart/x-mixed-replace; boundary=frame') +if __name__ == '__main__': + # defining server ip address and port + app.run(host='0.0.0.0',port='5000', debug=False)