video and data IO tools for Python
Project description
daio
Video and data IO tools for Python.
Links: API documentation, GitHub repository
Installation
- via conda or mamba:
conda install danionella::daio
- if you prefer pip:
pip install daio
- for development, clone this repository change to the directory containing
pyproject.toml
conda env create -n env_name -f environment.yml
conda activate env_name
pip install -e .
Use
Video IO
Write video:
from daio.video import VideoReader, VideoWriter
writer = VideoWriter('/path/to/video.mp4', fps=25)
for i in range(20):
frame = np.random.randint(0,255,size=(720,1280), dtype='uint8')
writer.write(frame)
writer.close()
Read video:
reader = VideoReader('/path/to/video.mp4')
frame_7 = reader[7]
first10_frames = reader[:10]
for frame in reader:
process_frame(frame)
reader.close()
You can also use with statements to handle file closure:
with VideoWriter('/path/to/video.mp4', fps=25) as writer:
for i in range(20):
frame = np.random.randint(0,255,size=(720,1280), dtype='uint8')
writer.write(frame)
#or
with VideoReader('/path/to/video.mp4') as reader:
frame_7 = reader[7]
HDF5 file IO
Write a Python dict to a HDF5 file:
from daio.h5 import save_to_h5, load_from_h5, lazyh5
some_dict = dict(a = 1, b = np.random.randn(3,4,5), c = dict(g='nested'), d = 'some_string')
save_to_h5('/path/to/datafile.h5', some_dict)
Load HDF5 contents to dict:
dict_loaded = load_from_h5('/path/to/datafile.h5', d)
Lazily load HDF5 with a dict-like interface (contents are only loaded when accessed):
h5 = lazyh5('/path/to/datafile.h5')
b_loaded = h5['b']
g_loaded = h5['c']['g']
h5.keys()
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
daio-0.0.2.tar.gz
(9.4 kB
view details)
Built Distribution
daio-0.0.2-py3-none-any.whl
(8.3 kB
view details)
File details
Details for the file daio-0.0.2.tar.gz
.
File metadata
- Download URL: daio-0.0.2.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09fb523e67671066331c7b924219f9ecae01e1548856c48768949c974952868e |
|
MD5 | cd3a98d2aa0baba8555be71670dae4bd |
|
BLAKE2b-256 | 0043a5a2d5bdac5490ad9a31f26daa8335519981a9c19762bd21aeadd15d925d |
File details
Details for the file daio-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: daio-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d47f62217b648e71e5ae3d05e2d38a364b75fc4a02ce62355e785b798b37bed |
|
MD5 | f851b0e7a941e3a43ce632092f49e7b6 |
|
BLAKE2b-256 | f1777b6259c33959f16cf10ea136a3639993c3892d164e9887c9823b67ed1793 |