Skip to content

Commit c19ca04

Browse files
committed
added instructions to build a wheel
1 parent 0fe5259 commit c19ca04

4 files changed

Lines changed: 39 additions & 11 deletions

File tree

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ This is a simple and lightweight Python extension that allows developers to enum
33

44
```python
55
from windows_capture_devices import get_capture_devices
6-
import av
7-
8-
if __name__ == "__main__":
9-
device_list = get_capture_devices()
10-
11-
# TODO: pyav example
6+
device_list = get_capture_devices()
127
```
138

149
We use this extension in the `WebcamSource` of our [**multisensor-pipeline**](https://github.com/DFKI-Interactive-Machine-Learning/multisensor-pipeline).
@@ -23,6 +18,19 @@ We use this extension in the `WebcamSource` of our [**multisensor-pipeline**](ht
2318
```commandline
2419
python setup.py build install
2520
```
21+
* Build a wheel
22+
```commandline
23+
pip install wheel
24+
python setup.py bdist_wheel
25+
```
26+
27+
## PyAV Example
28+
We include an example for grabbing an image frame using PyAV in `demo.py`. The demo has additional dependencies:
29+
30+
```commandline
31+
conda install av -c conda-forge
32+
pip install Pillow
33+
```
2634

2735
## Credits
2836
This repository is forked from https://github.com/yushulx/python-capture-device-list.

demo.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from windows_capture_devices import get_capture_devices
2+
import av
3+
from PIL import Image
4+
5+
6+
if __name__ == "__main__":
7+
# get list of device names
8+
device_list = get_capture_devices()
9+
10+
# initialize a webcam handle using PyAV and the DirectShow backend
11+
cam_device = av.open(format="dshow", file=f"video={device_list[0]}")
12+
video_stream = cam_device.streams.video[0]
13+
14+
# grab one frame from the video stream and save it
15+
for frame in cam_device.decode(video_stream):
16+
img = frame.to_image()
17+
break
18+
19+
assert isinstance(img, Image.Image)
20+
img.save(f"test_{device_list[0]}.jpg")
21+
print(f"Success! An image from the {device_list[0]} webcam was stored.")
22+
23+
# clean up
24+
cam_device.close()

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import setuptools
12
from distutils.core import setup, Extension
23

34
setup(

test.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)