A Python package for easily streaming OpenCV footage, even with authentication
Project description
Flask-OpenCV-Streamer
A Python package for easily streaming OpenCV footage, even with authentication
Installation
Install via PyPi using Pip / PipEnv:
pip install flask_opencv_streamer
Usage
Usage is quite straight forward. After importing, you can create as many streamer objects as you wish.
Example Code:
Without authentication (no login required to view page)
from flask_opencv_streamer.streamer import Streamer
import cv2
port = 3030
require_login = False
streamer = Streamer(port, require_login)
# Open video device 0
video_capture = cv2.VideoCapture(0)
while True:
_, frame = video_capture.read()
streamer.update_frame(frame)
if not streamer.is_streaming:
streamer.start_streaming()
cv2.waitKey(30)
With authentication (A password will be generated for you, expiring every 24 hrs)
from flask_opencv_streamer.streamer import Streamer
import cv2
port = 3030
require_login = True
login_file = "logins.txt"
login_key = "loginkey.txt
streamer = Streamer(port, require_login, login_file=login_file, login_key=login_key)
# Open video device 0
video_capture = cv2.VideoCapture(0)
while True:
_, frame = video_capture.read()
streamer.update_frame(frame)
if not streamer.is_streaming:
streamer.start_streaming()
cv2.waitKey(30)
If there is no logins file or key found at the path given, it will create one for you. Logins will be stored in a .txt
file logins.txt
but will be encrypted. Therefore, unless someone has the key (in this example, loginkey.txt
) the logins.txt
file will be able to show logins or passwords. It is very unsafe to keep the login key somewhere publicly accessible; it's suggested you hide it well and do not upload it anywhere.
Adding or removing your own logins
Currently, there is no streamlined way to add or remove logins. Fortunately it only needs to be done once per login and can be done very easily:
from flask_opencv_streamer.login_mgr import LoginManager
login_file = "logins.txt"
login_key = "loginkey.txt"
lm = LoginManager(login_file, login_key)
lm.add_login("user", "hotdog123")
lm.add_login("admin", "password")
lm.remove_login("guest")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for flask_opencv_streamer-1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0f834a64929a47cdf1a0a1316b6428f94e417ba597e2b357c272c9ec664b588 |
|
MD5 | 02e8b07b016024c69dc2c8557fc04454 |
|
BLAKE2b-256 | fab82b6291c235465473932411844802fbf2e903e622902785601d3f408f5fdb |
Hashes for flask_opencv_streamer-1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 452e880b0b0a11255158a3662829fe46b25719a0c57dd86b5b0d5406103f9aa9 |
|
MD5 | 442eda8330ae2c126af0fa05a83f4415 |
|
BLAKE2b-256 | 766798a6c27a404a3c5b3e806897b68694d7fe192d76f788de15e7313de8a8a2 |