pyobs-v4l 1.0.0__tar.gz → 2.0.0.dev3__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.
- pyobs_v4l-2.0.0.dev3/.github/workflows/pypi.yml +26 -0
- pyobs_v4l-2.0.0.dev3/.github/workflows/ruff.yml +23 -0
- pyobs_v4l-2.0.0.dev3/.pre-commit-config.yaml +15 -0
- pyobs_v4l-2.0.0.dev3/.readthedocs.yml +17 -0
- pyobs_v4l-2.0.0.dev3/PKG-INFO +12 -0
- pyobs_v4l-2.0.0.dev3/README.md +60 -0
- pyobs_v4l-2.0.0.dev3/docs/Makefile +31 -0
- pyobs_v4l-2.0.0.dev3/docs/make.bat +36 -0
- pyobs_v4l-2.0.0.dev3/docs/requirements.txt +1 -0
- pyobs_v4l-2.0.0.dev3/docs/source/_static/pyobs.gif +0 -0
- pyobs_v4l-2.0.0.dev3/docs/source/conf.py +117 -0
- pyobs_v4l-2.0.0.dev3/docs/source/index.rst +50 -0
- pyobs_v4l-2.0.0.dev3/pyobs_v4l/__init__.py +1 -0
- pyobs_v4l-2.0.0.dev3/pyobs_v4l/gui.py +99 -0
- {pyobs_v4l-1.0.0 → pyobs_v4l-2.0.0.dev3}/pyobs_v4l/v4lcamera.py +2 -3
- pyobs_v4l-2.0.0.dev3/pyproject.toml +45 -0
- pyobs_v4l-2.0.0.dev3/uv.lock +2464 -0
- pyobs_v4l-1.0.0/PKG-INFO +0 -14
- pyobs_v4l-1.0.0/pyobs_v4l/__init__.py +0 -1
- pyobs_v4l-1.0.0/pyproject.toml +0 -21
- {pyobs_v4l-1.0.0 → pyobs_v4l-2.0.0.dev3}/LICENSE +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Publish package to PyPI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
tags:
|
|
5
|
+
- 'v*'
|
|
6
|
+
jobs:
|
|
7
|
+
build-n-publish:
|
|
8
|
+
name: Build and publish package to PyPI
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- name: Check out repository code
|
|
12
|
+
uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Set up Python
|
|
15
|
+
uses: astral-sh/setup-uv@v5
|
|
16
|
+
with:
|
|
17
|
+
enable-cache: true
|
|
18
|
+
python-version: "3.11"
|
|
19
|
+
|
|
20
|
+
- name: Build
|
|
21
|
+
run: uv build --sdist
|
|
22
|
+
|
|
23
|
+
- name: Publish
|
|
24
|
+
env:
|
|
25
|
+
PYPI_TOKEN: ${{ secrets.pypi_password }}
|
|
26
|
+
run: uv publish --token $PYPI_TOKEN
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: ruff
|
|
2
|
+
on: push
|
|
3
|
+
|
|
4
|
+
jobs:
|
|
5
|
+
ruff:
|
|
6
|
+
runs-on: ubuntu-latest
|
|
7
|
+
timeout-minutes: 10
|
|
8
|
+
|
|
9
|
+
steps:
|
|
10
|
+
- name: Check out repository code
|
|
11
|
+
uses: actions/checkout@v4
|
|
12
|
+
|
|
13
|
+
- name: Set up Python
|
|
14
|
+
uses: astral-sh/setup-uv@v5
|
|
15
|
+
with:
|
|
16
|
+
enable-cache: true
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
|
|
19
|
+
- name: Install packages
|
|
20
|
+
run: uv sync --all-extras --dev
|
|
21
|
+
|
|
22
|
+
- name: Run ruff
|
|
23
|
+
run: uv run --no-sync ruff check pyobs_v4l/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
|
|
3
|
+
- repo: https://github.com/psf/black-pre-commit-mirror
|
|
4
|
+
rev: 25.1.0
|
|
5
|
+
hooks:
|
|
6
|
+
- id: black
|
|
7
|
+
# It is recommended to specify the latest version of Python
|
|
8
|
+
# supported by your project here, or alternatively use
|
|
9
|
+
# pre-commit's default_language_version, see
|
|
10
|
+
# https://pre-commit.com/#top_level-default_language_version
|
|
11
|
+
language_version: python3.11
|
|
12
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
13
|
+
rev: v0.9.0
|
|
14
|
+
hooks:
|
|
15
|
+
- id: ruff
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyobs-v4l
|
|
3
|
+
Version: 2.0.0.dev3
|
|
4
|
+
Summary: pyobs module for V4L cameras
|
|
5
|
+
Author-email: Tim-Oliver Husser <thusser@uni-goettingen.de>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: <3.14,>=3.11
|
|
9
|
+
Requires-Dist: opencv-python<5,>=4.0
|
|
10
|
+
Requires-Dist: pyobs-core<3,>=2.0.0.dev1
|
|
11
|
+
Provides-Extra: gui
|
|
12
|
+
Requires-Dist: pyobs-core[gui]<3,>=2.0.0.dev1; extra == 'gui'
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
*pyobs* module for Video4Linux cameras
|
|
2
|
+
=======================================
|
|
3
|
+
|
|
4
|
+
This is a [pyobs](https://www.pyobs.org) module for USB webcams and other Video4Linux cameras.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
System dependencies
|
|
8
|
+
--------------------
|
|
9
|
+
On Debian/Ubuntu:
|
|
10
|
+
|
|
11
|
+
sudo apt install libv4l-dev
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Install *pyobs-v4l*
|
|
15
|
+
---------------------
|
|
16
|
+
Clone the repository:
|
|
17
|
+
|
|
18
|
+
git clone https://github.com/pyobs/pyobs-v4l.git
|
|
19
|
+
cd pyobs-v4l
|
|
20
|
+
|
|
21
|
+
Install it with [uv](https://docs.astral.sh/uv/):
|
|
22
|
+
|
|
23
|
+
uv sync
|
|
24
|
+
|
|
25
|
+
Alternatively, with plain `venv`/`pip`:
|
|
26
|
+
|
|
27
|
+
python3 -m venv .venv
|
|
28
|
+
source .venv/bin/activate
|
|
29
|
+
pip install .
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Configuration
|
|
33
|
+
-------------
|
|
34
|
+
The *v4lCamera* class is derived from *BaseVideo* (see *pyobs* documentation) and adds a single new parameter:
|
|
35
|
+
|
|
36
|
+
device:
|
|
37
|
+
Index of the /dev/videoN device to use (default: 0).
|
|
38
|
+
|
|
39
|
+
A basic module configuration would look like this:
|
|
40
|
+
|
|
41
|
+
class: pyobs_v4l.v4lCamera
|
|
42
|
+
name: V4L camera
|
|
43
|
+
device: 0
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
GUI
|
|
47
|
+
---
|
|
48
|
+
For testing a camera without a full *pyobs* setup, install the optional `gui` extra:
|
|
49
|
+
|
|
50
|
+
uv sync --extra gui
|
|
51
|
+
|
|
52
|
+
and run:
|
|
53
|
+
|
|
54
|
+
uv run v4l-gui
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
Dependencies
|
|
58
|
+
------------
|
|
59
|
+
* [pyobs-core](https://github.com/pyobs/pyobs-core) for the core functionality.
|
|
60
|
+
* [OpenCV](https://github.com/opencv/opencv-python) for accessing the camera.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line.
|
|
5
|
+
SPHINXOPTS =
|
|
6
|
+
SPHINXBUILD = sphinx-build
|
|
7
|
+
SPHINXPROJ = pyobs
|
|
8
|
+
SOURCEDIR = source
|
|
9
|
+
BUILDDIR = ../.doc-build
|
|
10
|
+
|
|
11
|
+
#.EXPORT_ALL_VARIABLES:
|
|
12
|
+
|
|
13
|
+
#PYTHONPATH:=../pyobs-core/:../pyobs-sbig/:../pyobs-fli:../pyobs-weather:../pyobs-archive:${PYTHONPATH}
|
|
14
|
+
|
|
15
|
+
# Put it first so that "make" without argument is like "make help".
|
|
16
|
+
help:
|
|
17
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
18
|
+
|
|
19
|
+
.PHONY: help Makefile
|
|
20
|
+
|
|
21
|
+
html:
|
|
22
|
+
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
|
|
23
|
+
|
|
24
|
+
livehtml:
|
|
25
|
+
sphinx-autobuild -b html --watch ../pyobs_v4l $(ALLSPHINXOPTS) "$(SOURCEDIR)/" "$(BUILDDIR)/html/"
|
|
26
|
+
|
|
27
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
28
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
29
|
+
%: Makefile
|
|
30
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
31
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
set SPHINXPROJ=pyobs
|
|
13
|
+
|
|
14
|
+
if "%1" == "" goto help
|
|
15
|
+
|
|
16
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
17
|
+
if errorlevel 9009 (
|
|
18
|
+
echo.
|
|
19
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
20
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
21
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
22
|
+
echo.may add the Sphinx directory to PATH.
|
|
23
|
+
echo.
|
|
24
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
25
|
+
echo.http://sphinx-doc.org/
|
|
26
|
+
exit /b 1
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
|
30
|
+
goto end
|
|
31
|
+
|
|
32
|
+
:help
|
|
33
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
|
34
|
+
|
|
35
|
+
:end
|
|
36
|
+
popd
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sphinx-rtd-theme
|
|
Binary file
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# This file does only contain a selection of the most common options. For a
|
|
4
|
+
# full list see the documentation:
|
|
5
|
+
# http://www.sphinx-doc.org/en/stable/config
|
|
6
|
+
|
|
7
|
+
# -- Path setup --------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
# If extensions (or modules to document with autodoc) are in another directory,
|
|
10
|
+
# add these directories to sys.path here. If the directory is relative to the
|
|
11
|
+
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
12
|
+
#
|
|
13
|
+
import os
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
sys.path.insert(0, os.path.abspath("../../"))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# -- Project information -----------------------------------------------------
|
|
20
|
+
|
|
21
|
+
project = "pyobs-v4l"
|
|
22
|
+
copyright = "2024, Tim-Oliver Husser"
|
|
23
|
+
author = "Tim-Oliver Husser"
|
|
24
|
+
|
|
25
|
+
# The short X.Y version
|
|
26
|
+
# version = "0.16"
|
|
27
|
+
# The full version, including alpha/beta/rc tags
|
|
28
|
+
# release = "0.16.0"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# -- General configuration ---------------------------------------------------
|
|
32
|
+
|
|
33
|
+
add_module_names = False
|
|
34
|
+
|
|
35
|
+
# If your documentation needs a minimal Sphinx version, state it here.
|
|
36
|
+
#
|
|
37
|
+
# needs_sphinx = '1.0'
|
|
38
|
+
|
|
39
|
+
# Add any Sphinx extension module names here, as strings. They can be
|
|
40
|
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
|
41
|
+
# ones.
|
|
42
|
+
extensions = [
|
|
43
|
+
"sphinx.ext.autodoc",
|
|
44
|
+
"sphinx.ext.githubpages",
|
|
45
|
+
"sphinx.ext.napoleon",
|
|
46
|
+
"sphinx.ext.viewcode",
|
|
47
|
+
"sphinx.ext.autosectionlabel",
|
|
48
|
+
"sphinx.ext.intersphinx",
|
|
49
|
+
#'sphinx_autodoc_typehints'
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
intersphinx_mapping = {"http://docs.python.org/3": None}
|
|
53
|
+
|
|
54
|
+
# napoleon settings
|
|
55
|
+
napoleon_google_docstring = True
|
|
56
|
+
napoleon_numpy_docstring = False
|
|
57
|
+
napoleon_use_param = False
|
|
58
|
+
napoleon_use_ivar = True
|
|
59
|
+
|
|
60
|
+
# typehints
|
|
61
|
+
# set_type_checking_flag = True
|
|
62
|
+
# autodoc_typehints = "description"
|
|
63
|
+
|
|
64
|
+
# show c'tor parameters in class only
|
|
65
|
+
autoclass_content = "both"
|
|
66
|
+
|
|
67
|
+
# Add any paths that contain templates here, relative to this directory.
|
|
68
|
+
templates_path = ["_templates"]
|
|
69
|
+
|
|
70
|
+
# The suffix(es) of source filenames.
|
|
71
|
+
# You can specify multiple suffix as a list of string:
|
|
72
|
+
#
|
|
73
|
+
source_suffix = ".rst"
|
|
74
|
+
|
|
75
|
+
# The master toctree document.
|
|
76
|
+
master_doc = "index"
|
|
77
|
+
|
|
78
|
+
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
79
|
+
# for a list of supported languages.
|
|
80
|
+
#
|
|
81
|
+
# This is also used if you do content translation via gettext catalogs.
|
|
82
|
+
# Usually you set "language" from the command line for these cases.
|
|
83
|
+
language = "en"
|
|
84
|
+
|
|
85
|
+
# List of patterns, relative to source directory, that match files and
|
|
86
|
+
# directories to ignore when looking for source files.
|
|
87
|
+
# This pattern also affects html_static_path and html_extra_path .
|
|
88
|
+
exclude_patterns = []
|
|
89
|
+
|
|
90
|
+
# The name of the Pygments (syntax highlighting) style to use.
|
|
91
|
+
pygments_style = "sphinx"
|
|
92
|
+
|
|
93
|
+
# Be a little nitpicky
|
|
94
|
+
nitpicky = True
|
|
95
|
+
nitpick_ignore = []
|
|
96
|
+
|
|
97
|
+
# intersphinx
|
|
98
|
+
intersphinx_mapping = {
|
|
99
|
+
"pyobs": ("https://pyobs-core.readthedocs.io/en/latest/", None),
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# -- Options for HTML output -------------------------------------------------
|
|
103
|
+
|
|
104
|
+
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
105
|
+
# a list of builtin themes.
|
|
106
|
+
html_theme = "sphinx_rtd_theme"
|
|
107
|
+
html_theme_options = {
|
|
108
|
+
"collapse_navigation": False,
|
|
109
|
+
"sticky_navigation": True,
|
|
110
|
+
"navigation_depth": 4,
|
|
111
|
+
"display_version": False,
|
|
112
|
+
"logo_only": False,
|
|
113
|
+
"prev_next_buttons_location": "bottom",
|
|
114
|
+
"titles_only": False,
|
|
115
|
+
"style_nav_header_background": "#cccccc",
|
|
116
|
+
}
|
|
117
|
+
html_logo = "_static/pyobs.gif"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
pyobs-v4l
|
|
2
|
+
#########
|
|
3
|
+
|
|
4
|
+
This is a `pyobs <https://www.pyobs.org>`_ (`documentation <https://docs.pyobs.org>`_) module for USB webcams and
|
|
5
|
+
other Video4Linux cameras.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Example configuration
|
|
9
|
+
*********************
|
|
10
|
+
|
|
11
|
+
This is an example configuration::
|
|
12
|
+
|
|
13
|
+
class: pyobs_v4l.v4lCamera
|
|
14
|
+
device: 0
|
|
15
|
+
|
|
16
|
+
# file naming
|
|
17
|
+
filenames: /webcam/pyobs-{DAY-OBS|date:}-{FRAMENUM|string:04d}.fits
|
|
18
|
+
video_path: /webcam/video.mjpg
|
|
19
|
+
|
|
20
|
+
# location
|
|
21
|
+
timezone: utc
|
|
22
|
+
location:
|
|
23
|
+
longitude: 9.944333
|
|
24
|
+
latitude: 51.560583
|
|
25
|
+
elevation: 201.
|
|
26
|
+
|
|
27
|
+
# communication
|
|
28
|
+
comm:
|
|
29
|
+
jid: test@example.com
|
|
30
|
+
password: ***
|
|
31
|
+
|
|
32
|
+
# virtual file system
|
|
33
|
+
vfs:
|
|
34
|
+
class: pyobs.vfs.VirtualFileSystem
|
|
35
|
+
roots:
|
|
36
|
+
webcam:
|
|
37
|
+
class: pyobs.vfs.HttpFile
|
|
38
|
+
upload: http://localhost:37075/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Available classes
|
|
42
|
+
*****************
|
|
43
|
+
|
|
44
|
+
There is one single class for Video4Linux cameras.
|
|
45
|
+
|
|
46
|
+
v4lCamera
|
|
47
|
+
=========
|
|
48
|
+
.. autoclass:: pyobs_v4l.v4lCamera
|
|
49
|
+
:members:
|
|
50
|
+
:show-inheritance:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .v4lcamera import v4lCamera as v4lCamera
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import sys
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import cv2
|
|
7
|
+
import qasync # type: ignore[import-untyped]
|
|
8
|
+
from astropy.io import fits
|
|
9
|
+
from pyobs.utils.gui.camera import DataDisplayWidget, ExposeWidget
|
|
10
|
+
from PySide6 import QtWidgets # type: ignore[import-untyped]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MainWindow(QtWidgets.QMainWindow):
|
|
14
|
+
def __init__(self, device: int) -> None:
|
|
15
|
+
super().__init__()
|
|
16
|
+
self.setWindowTitle(f"V4L Camera — /dev/video{device}")
|
|
17
|
+
|
|
18
|
+
self._camera = cv2.VideoCapture(device)
|
|
19
|
+
self._last_frame: cv2.typing.MatLike | None = None
|
|
20
|
+
self._preview_task: asyncio.Task[None] | None = None
|
|
21
|
+
|
|
22
|
+
central = QtWidgets.QWidget()
|
|
23
|
+
self.setCentralWidget(central)
|
|
24
|
+
layout = QtWidgets.QHBoxLayout(central)
|
|
25
|
+
|
|
26
|
+
controls = QtWidgets.QGroupBox("Camera")
|
|
27
|
+
controls_layout = QtWidgets.QVBoxLayout(controls)
|
|
28
|
+
self.expose = ExposeWidget(can_abort_exposure=False)
|
|
29
|
+
controls_layout.addWidget(self.expose)
|
|
30
|
+
controls_layout.addStretch()
|
|
31
|
+
|
|
32
|
+
self.display = DataDisplayWidget()
|
|
33
|
+
layout.addWidget(controls)
|
|
34
|
+
layout.addWidget(self.display)
|
|
35
|
+
|
|
36
|
+
self.expose.expose_clicked.connect(self._grab_clicked)
|
|
37
|
+
|
|
38
|
+
self._preview_task = asyncio.ensure_future(self._live_preview())
|
|
39
|
+
|
|
40
|
+
async def _live_preview(self) -> None:
|
|
41
|
+
loop = asyncio.get_running_loop()
|
|
42
|
+
while True:
|
|
43
|
+
ret, frame = await loop.run_in_executor(None, self._camera.read)
|
|
44
|
+
if ret:
|
|
45
|
+
self._last_frame = frame
|
|
46
|
+
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
|
47
|
+
self.display.set_data(fits.PrimaryHDU(gray))
|
|
48
|
+
await asyncio.sleep(0.05)
|
|
49
|
+
|
|
50
|
+
@qasync.asyncSlot(int) # type: ignore[misc]
|
|
51
|
+
async def _grab_clicked(self, count: int) -> None:
|
|
52
|
+
if self._last_frame is None:
|
|
53
|
+
return
|
|
54
|
+
self.expose.start_exposure(0.0)
|
|
55
|
+
for _ in range(count):
|
|
56
|
+
loop = asyncio.get_running_loop()
|
|
57
|
+
ret, frame = await loop.run_in_executor(None, self._camera.read)
|
|
58
|
+
if ret:
|
|
59
|
+
self._last_frame = frame
|
|
60
|
+
gray = cv2.cvtColor(self._last_frame, cv2.COLOR_BGR2GRAY)
|
|
61
|
+
self.display.set_data(fits.PrimaryHDU(gray))
|
|
62
|
+
self.expose.set_exposures_left()
|
|
63
|
+
|
|
64
|
+
def closeEvent(self, event: Any) -> None:
|
|
65
|
+
if self._preview_task is not None:
|
|
66
|
+
self._preview_task.cancel()
|
|
67
|
+
self._camera.release()
|
|
68
|
+
super().closeEvent(event)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
async def async_main(app: QtWidgets.QApplication) -> None:
|
|
72
|
+
devices = sorted(p for p in Path("/dev").glob("video*") if p.is_char_device())
|
|
73
|
+
if not devices:
|
|
74
|
+
QtWidgets.QMessageBox.critical(None, "Error", "No V4L devices found.")
|
|
75
|
+
return
|
|
76
|
+
|
|
77
|
+
device_name, ok = QtWidgets.QInputDialog.getItem(
|
|
78
|
+
None, "Select Device", "V4L device:", [str(d) for d in devices], 0, False
|
|
79
|
+
)
|
|
80
|
+
if not ok:
|
|
81
|
+
return
|
|
82
|
+
|
|
83
|
+
device_index = int(device_name.replace("/dev/video", ""))
|
|
84
|
+
|
|
85
|
+
app_close_event = asyncio.Event()
|
|
86
|
+
app.aboutToQuit.connect(app_close_event.set)
|
|
87
|
+
window = MainWindow(device_index)
|
|
88
|
+
window.show()
|
|
89
|
+
await app_close_event.wait()
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def main() -> None:
|
|
93
|
+
app = QtWidgets.QApplication(sys.argv)
|
|
94
|
+
with qasync.QEventLoop(app) as loop:
|
|
95
|
+
loop.run_until_complete(async_main(app))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
main()
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pyobs-v4l"
|
|
3
|
+
version = "2.0.0.dev3"
|
|
4
|
+
description = "pyobs module for V4L cameras"
|
|
5
|
+
authors = [{ name = "Tim-Oliver Husser", email = "thusser@uni-goettingen.de" }]
|
|
6
|
+
requires-python = ">=3.11,<3.14"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"opencv-python>=4.0,<5",
|
|
10
|
+
"pyobs-core>=2.0.0.dev1,<3",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[project.optional-dependencies]
|
|
14
|
+
gui = [
|
|
15
|
+
"pyobs-core[gui]>=2.0.0.dev1,<3",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
v4l-gui = "pyobs_v4l.gui:main"
|
|
20
|
+
|
|
21
|
+
[dependency-groups]
|
|
22
|
+
dev = [
|
|
23
|
+
"black>=25.1.0,<26",
|
|
24
|
+
"ruff>=0.9.0",
|
|
25
|
+
"pyrefly>=1.1.1",
|
|
26
|
+
"pre-commit>=4.2.0,<5",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[build-system]
|
|
30
|
+
requires = ["hatchling"]
|
|
31
|
+
build-backend = "hatchling.build"
|
|
32
|
+
|
|
33
|
+
[tool.black]
|
|
34
|
+
line-length = 120
|
|
35
|
+
target-version = ['py311']
|
|
36
|
+
|
|
37
|
+
[tool.ruff]
|
|
38
|
+
target-version = "py311"
|
|
39
|
+
line-length = 120
|
|
40
|
+
|
|
41
|
+
[tool.ruff.lint]
|
|
42
|
+
select = ["E", "F", "W", "I", "UP", "G"]
|
|
43
|
+
|
|
44
|
+
[tool.pyrefly]
|
|
45
|
+
python-version = "3.11"
|