Install using Poetry¶
Best option for managing VidGear as a dependency in a Poetry-managed project.
VidGear's pyproject.toml is PEP 517/621 compliant, so it can be consumed directly by Poetry.
Don't have Poetry installed?
Follow the official Poetry installation guide before proceeding. You can verify your install with:
Prerequisites¶
When installing VidGear with Poetry, you need to manually install the following prerequisites:
Critical Prerequisites
¶
-
OpenCV¶
Must require OpenCV(3.0+) python binaries installed for all core functions. You can easily install it directly via pip:
OpenCV installation from source
You can also follow online tutorials for building & installing OpenCV on Windows, Linux, MacOS and Raspberry Pi machines manually from its source.
Make sure not to install both pip and source version together. Otherwise installation will fail to work!
Other OpenCV binaries
OpenCV maintainers also provide additional binaries via pip that contains both main modules and contrib/extra modules
opencv-contrib-python, and for server (headless) environments likeopencv-python-headlessandopencv-contrib-python-headless. You can also install any one of them in similar manner. More information can be found here.
API Specific Prerequisites¶
-
FFmpeg¶
Require only for the video compression and encoding compatibility within StreamGear API and WriteGear API's Compression Mode, and for hardware-accelerated decoding within FFGear API.
FFmpeg Installation
- For WriteGear API's Compression Mode: Follow this dedicated FFmpeg Installation doc for its installation.
- For StreamGear API: Follow this dedicated FFmpeg Installation doc for its installation.
- For FFGear API: Follow this dedicated FFmpeg Installation doc for its installation.
-
Picamera2¶
Required only if you're using Raspberry Pi Camera Modules (or USB webcams) with the PiGear API. Here's how to install Picamera2 python library:
Using Legacy
picameralibrary with PiGear (v0.3.3and above)PiGear API (version
0.3.3onwards) prioritizes the newer Picamera2 library under the hood for Raspberry Pi camera modules. However, if your operating system doesn't support Picamera2, you can still use the legacypicameralibrary. Here's how to easily install it using pip:You could also enforce the legacy picamera API backend in PiGear by using the
enforce_legacy_picamerauser-defined optional parameter boolean attribute.Picamera2 is only supported on Raspberry Pi OS Bullseye (or later) images, both 32 and 64-bit.
Picamera2 is NOT supported on:
- Images based on Buster or earlier releases.
- Raspberry Pi OS Legacy images.
- Bullseye (or later) images where the legacy camera stack has been re-enabled.
As of September 2022, Picamera2 is pre-installed on images downloaded from Raspberry Pi. So you don't have to install it manually.
- On Raspberry Pi OS images, Picamera2 is now installed with all the GUI (Qt and OpenGL) dependencies.
-
On Raspberry Pi OS Lite, it is installed without the GUI dependencies, although preview images can still be displayed using DRM/KMS. If these users wish to use the additional X-Windows GUI features, they will need to run:
If Picamera2 is not already installed, then your image is presumably older and you should start with system upgrade:
If you have installed Picamera2 previously using pip, then you should also uninstall this (
pip3 uninstall picamera2).Thereafter, you can install Picamera2 with all the GUI (Qt and OpenGL) dependencies using:
Or, If you DON'T want the GUI dependencies, use:
This is NOT the recommended way to install Picamera2.
However, if you wish to install Picamera2 with all the GUI (Qt and OpenGL) dependencies with pip, use:
sudo apt install -y python3-libcamera python3-kms++ sudo apt install -y python3-pyqt5 python3-prctl sudo apt install -y libatlas-base-dev ffmpeg python3-pip pip3 install numpy --upgrade pip3 install picamera2[gui]Or, If you DON'T want the GUI dependencies, use:
Installation¶
Add VidGear to an existing Poetry project:
Adding vidgear with only selective dependencies
Starting with version v0.2.2, you can run any VidGear API by installing only the specific dependencies required by the API in use (except for some Core dependencies).
This is useful when you want to manually review, select and install minimal API-specific dependencies on bare-minimum vidgear from scratch:
-
Add bare-minimum vidgear as follows:
-
Then, you must install Critical dependencies (if not already):
-
Finally, manually install your API-specific dependencies as required by your API (in use):
APIs Dependencies CamGear yt_dlpPiGear picamera,picamera2(see pip install doc for its installation)VideoGear Based on CamGear or PiGear or FFGear backend in use ScreenGear dxcam,mss,pyscreenshot,PillowWriteGear FFmpeg: See this doc âž¶ StreamGear FFmpeg: See this doc âž¶ FFGear FFmpeg: See this doc âž¶ NetGear pyzmq,simplejpegWebGear starlette,jinja2,uvicorn,simplejpegWebGear_RTC aiortc,starlette,jinja2,uvicornNetGear_Async pyzmq,msgpack,msgpack_numpy,uvloopStabilizer Class -
# Add latest stable release with all Core dependencies
poetry add vidgear[core]
# Or add latest stable release with all Core & Asyncio dependencies
poetry add vidgear[asyncio]
Or, install directly from source in a Poetry-managed environment:
# clone the repository and get inside
git clone https://github.com/abhiTronix/vidgear.git && cd vidgear
# Install it into Poetry's virtualenv with all Core dependencies
poetry install --extras core
# Or with all Core & Asyncio dependencies
poetry install --extras asyncio
Running commands inside Poetry's virtualenv
Use poetry run to execute VidGear-powered scripts without activating the shell:
Or spawn a shell inside the virtualenv: