napari plugin for reading videos.
Project description
napari-video
Napari plugin for working with videos.
Relies on pyvideoreader as a backend which itself uses opencv for reading videos.
Installation
pip install napari[all] napari_video
Usage
From a terminal:
napari video.avi
Or from within python:
import napari
from napari_video.napari_video import VideoReaderNP
path='video.mp4'
vr = VideoReaderNP(path)
with napari.gui_qt():
viewer = napari.view_image(vr, name=path)
Internals
napari_video.napari_video.VideoReaderNP
exposes a video with a numpy-like interface, using opencv as a backend.
For instance, open a video:
vr = VideoReaderNP('video.avi')
print(vr)
video.avi with 60932 frames of size (920, 912, 3) at 100.00 fps
Then
vr[100]
will return the 100th frame as a numpy array with shape(902, 912, 3)
.vr[100:200:10]
will return 10 frames evenly spaced between frame number 100 and 200 (shape(10, 902, 912, 3)
).- Note that by default, single-frame and slice indexing return 3D and 4D arrays, respectively. To consistently return 4D arrays, open the video with
remove_leading_singleton=False
.vr[100]
will then return a(1, 902, 912, 3)
array. - We can also request specific ROIs and channels. For instance,
vr[100:200:10,100:400,800:850,1]
will return an array with shape(10, 300, 50, 1)
.
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
napari_video-0.2.9.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for napari_video-0.2.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ee7980b0ee0bfc453c7a36a61afe0148958f8d7728a0e62772d1a223ea3fe82 |
|
MD5 | 9c709509c67b89f654bbe740a63dd7ff |
|
BLAKE2b-256 | 621756ec5233fea77b5689c4376abd5c23d68984944a8dd8970afe16f788e871 |