Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8a46e78
Bump the patch-and-minor group with 3 updates
dependabot[bot] Oct 6, 2026
563699c
Merge pull request #34 from pyobs/dependabot/uv/develop/patch-and-min…
github-actions[bot] Oct 6, 2026
ef5cef8
Bump the patch-and-minor group with 3 updates
dependabot[bot] Oct 14, 2026
18c1117
Merge pull request #35 from pyobs/dependabot/uv/develop/patch-and-min…
github-actions[bot] Oct 14, 2026
2b04295
Bump the patch-and-minor group with 4 updates
dependabot[bot] Oct 20, 2026
f6c2e9d
Merge pull request #38 from pyobs/dependabot/uv/develop/patch-and-min…
github-actions[bot] Oct 20, 2026
d54a089
Bump ruff from 0.17.1 to 0.17.2 in the patch-and-minor group
dependabot[bot] Oct 27, 2026
79df501
Merge pull request #44 from pyobs/dependabot/uv/develop/patch-and-min…
github-actions[bot] Oct 27, 2026
7716304
Bump the patch-and-minor group with 4 updates
dependabot[bot] Nov 3, 2026
43fce50
Merge pull request #46 from pyobs/dependabot/uv/develop/patch-and-min…
github-actions[bot] Nov 3, 2026
8ad4f2c
ci: run checks on pull requests
thusser Nov 10, 2026
4f7079b
Merge pull request #48 from pyobs/ci/run-on-pull-requests
thusser Nov 10, 2026
c468482
Merge main into develop
thusser Nov 10, 2026
bd96e05
Merge pull request #49 from pyobs/sync/main-into-develop
thusser Nov 10, 2026
f815ffb
Bump the patch-and-minor group with 3 updates
dependabot[bot] Nov 10, 2026
a0087c8
Bump pytest-asyncio from 1.4.1 to 1.4.1.post1
dependabot[bot] Nov 10, 2026
7487576
Merge pull request #50 from pyobs/dependabot/uv/develop/patch-and-min…
github-actions[bot] Nov 10, 2026
337b1d3
Merge pull request #51 from pyobs/dependabot/uv/develop/pytest-asynci…
github-actions[bot] Nov 10, 2026
6a84cae
Use the shared frame header in the camera and GUI
thusser Nov 17, 2026
5fa622a
Require pyobs-core 2.28.0 for make_frame_header
thusser Nov 17, 2026
012f490
v2.2.0
thusser Nov 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/pyrefly.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: pyrefly
on: push
on:
push:
branches: [develop, main]
pull_request:

jobs:
pyrefly:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: PyTest
on: push
on:
push:
branches: [develop, main]
pull_request:

jobs:
test:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: ruff
on: push
on:
push:
branches: [develop, main]
pull_request:

jobs:
ruff:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Entries for releases before this file existed were generated from commit subjects.

## [Unreleased]

- `v4lCamera` writes the device (`/dev/videoN`) as `INSTRUME`. The GUI writes a FITS header into the frames it saves (it
was empty): the instrument and data statistics. Both use `make_frame_header` from pyobs-core. Needs pyobs-core 2.28.0
(the pin in `pyproject.toml` is still 2.13.1).

## [2.1.0] - 2026-09-29

- Move v4lCamera to the BaseVideo frames() contract
Expand Down
19 changes: 17 additions & 2 deletions pyobs_v4l/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,25 @@
import cv2
import qasync # type: ignore[import-untyped]
from astropy.io import fits
from numpy.typing import NDArray
from pyobs.utils.frameheader import FrameSettings, make_frame_header
from pyobs.utils.gui.camera import DataDisplayWidget, ExposeWidget
from PySide6 import QtWidgets # type: ignore[import-untyped]


def make_header(device: int, data: NDArray[Any]) -> fits.Header:
"""Builds the FITS header for a frame. All the camera tells is its device, so that and the data statistics.

Args:
device: Index of the V4L device, used as instrument name.
data: The frame.

Returns:
The header.
"""
return make_frame_header(FrameSettings(instrument=f"/dev/video{device}", data=data))


class MainWindow(QtWidgets.QMainWindow):
def __init__(self, device: int) -> None:
super().__init__()
Expand Down Expand Up @@ -58,7 +73,7 @@ async def _live_preview(self) -> None:
if ret:
self._last_frame = frame
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
self.display.set_data(fits.PrimaryHDU(gray))
self.display.set_data(fits.PrimaryHDU(gray, header=make_header(self._device, gray)))
await asyncio.sleep(0.05)

@qasync.asyncSlot(int) # type: ignore[misc]
Expand All @@ -72,7 +87,7 @@ async def _grab_clicked(self, count: int) -> None:
if ret:
self._last_frame = frame
gray = cv2.cvtColor(self._last_frame, cv2.COLOR_BGR2GRAY)
self.display.set_data(fits.PrimaryHDU(gray))
self.display.set_data(fits.PrimaryHDU(gray, header=make_header(self._device, gray)))
self.expose.set_exposures_left()

def closeEvent(self, event: Any) -> None:
Expand Down
8 changes: 8 additions & 0 deletions pyobs_v4l/v4lcamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
from typing import Any

import cv2
from pyobs.images import Image
from pyobs.modules.camera import BaseVideo, Frame
from pyobs.utils.enums import ImageType
from pyobs.utils.frameheader import FrameSettings, make_frame_header

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -90,6 +93,11 @@ def _wrapper() -> None:
except TimeoutError:
return False

async def _finish_image(self, image: Image, broadcast: bool, image_type: ImageType) -> tuple[Image, str]:
"""Add the device name as instrument, then finish up as usual."""
image.header.update(make_frame_header(FrameSettings(instrument=f"/dev/video{self._device}")))
return await super()._finish_image(image, broadcast, image_type)

async def _open_camera(self) -> Any:
"""Open the V4L2 camera device, without blocking the event loop.

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[project]
name = "pyobs-v4l"
version = "2.1.2"
version = "2.2.0"
description = "pyobs module for V4L cameras"
authors = [{ name = "Tim-Oliver Husser", email = "thusser@uni-goettingen.de" }]
requires-python = ">=3.11"
license = "MIT"
readme = "README.md"
dependencies = [
"opencv-python>=4.0,<6",
"pyobs-core>=2.13.1,<3",
"pyobs-core>=2.28.0,<3",
]

[project.urls]
Expand All @@ -19,7 +19,7 @@ Issues = "https://github.com/pyobs/pyobs-v4l/issues"

[project.optional-dependencies]
gui = [
"pyobs-core[gui]>=2.13.1,<3",
"pyobs-core[gui]>=2.28.0,<3",
]

[project.scripts]
Expand Down
30 changes: 30 additions & 0 deletions tests/test_frameheader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Tests for the FITS header cards of the module and the GUI."""

from __future__ import annotations

from unittest.mock import AsyncMock

import numpy as np
import pytest
from pyobs.images import Image
from pyobs.modules.camera import BaseVideo
from pyobs.utils.enums import ImageType

from pyobs_v4l import v4lCamera


@pytest.mark.asyncio
async def test_module_header_has_the_device_as_instrument(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(BaseVideo, "_finish_image", AsyncMock(side_effect=lambda image, *a: (image, "x")))
camera = v4lCamera(device=2)

image, _ = await camera._finish_image(Image(np.zeros((2, 2), dtype=np.uint8)), False, ImageType.OBJECT)

assert image.header["INSTRUME"] == "/dev/video2"


def test_gui_header_has_the_device_and_statistics() -> None:
gui = pytest.importorskip("pyobs_v4l.gui")
h = gui.make_header(0, np.array([[1, 2], [3, 6]], dtype=np.uint8))
assert h["INSTRUME"] == "/dev/video0"
assert (h["DATAMIN"], h["DATAMAX"], h["DATAMEAN"]) == (1.0, 6.0, 3.0)
Loading
Loading