Skip to content

Commit fa02d12

Browse files
authored
v1.0.0
version 1.0.0
2 parents 8685625 + 84d935c commit fa02d12

File tree

4 files changed

+61
-9
lines changed

4 files changed

+61
-9
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 21.12b0
4+
hooks:
5+
- id: black
6+
language_version: python3.9

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Tim-Oliver Husser
4+
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

pyobs_v4l/v4lcamera.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
1+
import asyncio
12
import time
23
import logging
4+
from typing import Any
5+
import cv2
36

47
from pyobs.modules.camera import BaseVideo
5-
import cv2
8+
69

710
log = logging.getLogger(__name__)
811

912

1013
class v4lCamera(BaseVideo):
11-
def __init__(self, device: int = 0, *args, **kwargs):
12-
BaseVideo.__init__(self, *args, **kwargs)
14+
def __init__(self, device: int = 0, **kwargs: Any):
15+
BaseVideo.__init__(self, **kwargs)
1316

1417
# store
1518
self._device = device
1619

1720
# thread
18-
self.add_thread_func(self._capture)
21+
self.add_background_task(self._capture)
1922

20-
def _capture(self):
23+
async def _capture(self) -> None:
2124
# open camera
2225
camera = cv2.VideoCapture(self._device)
2326

2427
# loop until closing
2528
last = time.time()
26-
while not self.closing.is_set():
29+
while True:
2730
# read frame
2831
_, frame = camera.read()
2932

3033
# if time since last image is too short, wait a little
3134
if time.time() - last < self._interval:
32-
self.closing.wait(0.01)
35+
await asyncio.sleep(0.01)
3336
continue
3437
last = time.time()
3538

3639
# process it
37-
self._set_image(frame)
40+
await self._set_image(frame)
3841

3942
# release camera
4043
camera.release()
4144

4245

43-
__all__ = ['v4lCamera']
46+
__all__ = ["v4lCamera"]

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[tool.poetry]
2+
name = "pyobs-v4l"
3+
version = "1.0.0"
4+
description = "pyobs module for V4L cameras"
5+
authors = ["Tim-Oliver Husser <[email protected]>"]
6+
license = "MIT"
7+
8+
[tool.poetry.dependencies]
9+
python = ">=3.9,<3.13"
10+
11+
[tool.poetry.dev-dependencies]
12+
black = "^21.12b0"
13+
pre-commit = "^2.16.0"
14+
15+
[build-system]
16+
requires = ["poetry-core>=1.0.0"]
17+
build-backend = "poetry.core.masonry.api"
18+
19+
[tool.black]
20+
line-length = 120
21+
target-version = ['py39']

0 commit comments

Comments
 (0)