A OpenCV Python Multi-Threaded Video Streaming Wrapper Library
Project description
VidGear is a lightweight python wrapper around OpenCV Video I/O module that contains powerful multi-thread modules(gears) to enable high-speed video frames read functionality across various devices and platforms. It is a reworked implementation of imutils library's video modules with all major bugs fixed and comes with addition features like direct network streaming(GStreamer Pipeline supported) and flexible direct source parameters/attributes manipulation of OpenCV's VideoCapture Class properties on the go. This library is also very well compatible with Raspberry Pi Camera module's Picamera library and provides us the ability exploit its various features like brightness, saturation, sensor_mode
etc. easily. This library supports Python 2.7 and all above versions.
Features:
Key features which differentiates from the other existing multi-threaded open source solutions:
- Multi-Threaded high-speed OpenCV video-frame capturing(resulting in High FPS)
- Flexible Direct control over the video stream
- Lightweight
- Built-in Robust Error and frame synchronization Handling
- Multi-Platform compatibility
- Full Support for Network Video Streams(Including Gstreamer Raw Video Capture Pipeline)
Prerequisites
- Critical: VidGear must require
OpenCV
(with contrib) library to be installed on your machine which is critical for its core algorithms functioning. You can build it from from scratch or install it from PyPi as follows(Latest versions recommended):pip install opencv-python pip install opencv-python-contrib
- Additional: If you are using Raspberry Pi Camera Modules such as OmniVision OV5647 Camera Module and Sony IMX219 Camera Module. It requires additional Picamera library installation on your Raspberry Pi machine prior to its installation (Latest versions recommended). You can install it from PyPi easily as follows:
Also, make sure to enable Raspberry Pi hardware specific settings prior using this library.pip install picamera
Installation
- From PyPI(Stable Only):
VidGear
can be easily installed as follows(available on Python Package Index (PyPI)):sudo pip install vidgear
- Clone this repository(Latest But experimental): You can also directly clone this repo. for latest patches(maybe experimental) and development purposes and thereby can install as follows:
git clone https://github.com/abhiTronix/vidgear.git cd vidgear sudo pip install .
- Conda Install: Anaconda prefers to use its own
conda package manager
, but it’s also possible to install packages usingpip
as follows:pip install vidgear
Documentation and Usage
You can checkout VidGear detailed Wiki-Section for detailed documentation with examples for each Class(Gear).
Basic example:
The basic example of VideoGear Class for webcam stream is as follows :
# import required libraries
from vidgear.gears import VideoGear
import cv2
stream = VideoGear(enablePiCamera = False, source=0).start()
# define various attributes and start the stream
# infinite loop
while True:
frame = stream.read()
# read frames
# check if frame is None
if frame is None:
#if True break the infinite loop
break
# do something with frame here
cv2.imshow("Output Frame", frame)
# Show output window
key = cv2.waitKey(1) & 0xFF
# check for 'q' key-press
if key == ord("q"):
#if 'q' key-pressed exit loop
break
cv2.destroyAllWindows()
# close output window
stream.stop()
# safely close video stream.
Contribution and Development
You are welcome to contribute with suggestions, feature requests and pull requests.
Author
- Abhishek Thakur @abhiTronix
License
Copyright © 2019 Abhitronix
This project is under the MIT License. See the LICENSE file for the full license text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file vidgear-0.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: vidgear-0.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ed2b621a7cfc5f87d7590e3b44fa004bceb895f7f6ef0b6c820236af13df716 |
|
MD5 | 2232321015ef0830c0cd283ae0a331d1 |
|
BLAKE2b-256 | 918dacb230e454d39f4304ea8e04202ef4a3120bd507dca42bdeb8521b7fb0e6 |