pyobs-v4l 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Tim-Oliver Husser
4
+ thusser@uni-goettingen.de
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.
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyobs-v4l
3
+ Version: 1.0.0
4
+ Summary: pyobs module for V4L cameras
5
+ License: MIT
6
+ Author: Tim-Oliver Husser
7
+ Author-email: thusser@uni-goettingen.de
8
+ Requires-Python: >=3.9,<3.13
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
@@ -0,0 +1 @@
1
+ from .v4lcamera import v4lCamera
@@ -0,0 +1,46 @@
1
+ import asyncio
2
+ import time
3
+ import logging
4
+ from typing import Any
5
+ import cv2
6
+
7
+ from pyobs.modules.camera import BaseVideo
8
+
9
+
10
+ log = logging.getLogger(__name__)
11
+
12
+
13
+ class v4lCamera(BaseVideo):
14
+ def __init__(self, device: int = 0, **kwargs: Any):
15
+ BaseVideo.__init__(self, **kwargs)
16
+
17
+ # store
18
+ self._device = device
19
+
20
+ # thread
21
+ self.add_background_task(self._capture)
22
+
23
+ async def _capture(self) -> None:
24
+ # open camera
25
+ camera = cv2.VideoCapture(self._device)
26
+
27
+ # loop until closing
28
+ last = time.time()
29
+ while True:
30
+ # read frame
31
+ _, frame = camera.read()
32
+
33
+ # if time since last image is too short, wait a little
34
+ if time.time() - last < self._interval:
35
+ await asyncio.sleep(0.01)
36
+ continue
37
+ last = time.time()
38
+
39
+ # process it
40
+ await self._set_image(frame)
41
+
42
+ # release camera
43
+ camera.release()
44
+
45
+
46
+ __all__ = ["v4lCamera"]
@@ -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 <thusser@uni-goettingen.de>"]
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']