RTSP client wrapper around gstreamer/opencv
Project description
RTSP Package
/((((((\\\\
=======((((((((((\\\\\
(( \\\\\\\
( (* _/ \\\\\\\
\ / \ \\\\\\________________
| | | </ __ ((\\\\
o_| / ____/ / _______ \ \\\\ \\\\\\\
| ._ / __/ __(_-</ _ \ \ \\\\\\\\\\\\\\\\
| / /_/ \__/___/ .__/ / \\\\\\\ \\
.______/\/ / /_/ / \\\
/ __.____/ _/ ________( /\
/ / / ________/`---------' \ / \_
/ / \ \ \ \ \_ \
( < \ \ > / \ \
\/ \\_ / / > )
\_| / / / /
_// _//
/_| /_|
Convenience-wrapper around OpenCV-Python RTSP functions.
Features
- read most-recent RTSP frame as Pillow Image on demand
- preview stream in OpenCV. 'q' to quit preview.
- URI shortcuts for rapid prototyping
- integers load a USB or webcam from starting with interface 0 via OpenCV, e.g.
rtsp.Client(0) - 'picam' uses a Raspberry Pi camera as source e.g.
rtsp.Client('picam')
- integers load a USB or webcam from starting with interface 0 via OpenCV, e.g.
Examples
Use RTSP access credentials in your connection string e.g.
RTSP_URL = f"rtsp://{USERNAME}:{PASSWORD}@192.168.1.221:554/11"
One-off Retrieval
import rtsp
client = rtsp.Client(rtsp_server_uri = 'rtsp://...', verbose=True)
client.read().show()
client.close()
Stream Preview
import rtsp
with rtsp.Client(0) as client: # previews USB webcam 0
client.preview()
Continuous Retrieval
import rtsp
with rtsp.Client(rtsp_server_uri = 'rtsp://...') as client:
_image = client.read()
while True:
process_image(_image)
_image = client.read(raw=True)
Resize Retrieval Image
import rtsp
RTSP_URL = "rtsp://..."
client = rtsp.Client(rtsp_server_uri = RTSP_URL)
width = 640
height = 480
client.read().resize([width, height]).show()
client.close()
Rotate Retrieval Image
import rtsp
RTSP_URL = "rtsp://..."
client = rtsp.Client(rtsp_server_uri = RTSP_URL)
client.read().resize([client.read().size[0], client.read().size[0]]).rotate(90).resize([client.read().size[1], client.read().size[0]]).show()
client.close()
Save Retrieval Image (With the TimeStamp Format and Set Number of Save Image)
import rtsp
import datetime
RTSP_URL = "rtsp://..."
IMAGE_COUNT = 10
client = rtsp.Client(rtsp_server_uri = RTSP_URL)
while client.isOpened() and IMAGE_COUNT > 0:
client.read().save("./"+ str(datetime.datetime.now()) +".jpg")
IMAGE_COUNT = IMAGE_COUNT - 1
client.close()
Roadmap:
I don't plan to develop this module any further, as more complex applications are better suited to use OpenCV, Gstreamer, or ffmpeg directly.
To do:
- might improve parsing for RTSP server URIs
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rtsp-1.1.12.tar.gz.
File metadata
- Download URL: rtsp-1.1.12.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1483997543f4b1393321c002692661ffa1d5b30c63ed09c7bb1d886137835cc
|
|
| MD5 |
f7a53c1f73c3e1922ecb7a07cb2c3858
|
|
| BLAKE2b-256 |
720f40584433bdea428c0a3f2a085eaf5bc99f355119807bdc9bbb02cbfb7676
|
File details
Details for the file rtsp-1.1.12-py3-none-any.whl.
File metadata
- Download URL: rtsp-1.1.12-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
746eefa8b06792b3aeeaa5e70878f84d49954c9509fc6f475e024f070faf73a5
|
|
| MD5 |
f1dd95ba50690ea91c5f0962e5a805ff
|
|
| BLAKE2b-256 |
ba98bffb8b7777f67ad5790aff618029e9b089cfa77a2f364a246c1f42ebdc80
|