pyobs-aravis 2.0.0.dev2__py3-none-any.whl → 2.0.0.dev4__py3-none-any.whl
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_aravis/gui.py +101 -0
- {pyobs_aravis-2.0.0.dev2.dist-info → pyobs_aravis-2.0.0.dev4.dist-info}/METADATA +4 -1
- pyobs_aravis-2.0.0.dev4.dist-info/RECORD +9 -0
- pyobs_aravis-2.0.0.dev4.dist-info/entry_points.txt +2 -0
- pyobs_aravis-2.0.0.dev2.dist-info/RECORD +0 -7
- {pyobs_aravis-2.0.0.dev2.dist-info → pyobs_aravis-2.0.0.dev4.dist-info}/WHEEL +0 -0
- {pyobs_aravis-2.0.0.dev2.dist-info → pyobs_aravis-2.0.0.dev4.dist-info}/licenses/LICENSE +0 -0
pyobs_aravis/gui.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import sys
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import qasync # type: ignore
|
|
6
|
+
from astropy.io import fits
|
|
7
|
+
from numpy.typing import NDArray
|
|
8
|
+
from pyobs.utils.gui.camera import DataDisplayWidget, ExposeWidget, ExposureTimeWidget, ListPickerDialog
|
|
9
|
+
from PySide6 import QtWidgets # type: ignore[import-untyped]
|
|
10
|
+
|
|
11
|
+
from . import aravis
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class MainWindow(QtWidgets.QMainWindow):
|
|
15
|
+
def __init__(self, device: str) -> None:
|
|
16
|
+
super().__init__()
|
|
17
|
+
self.setWindowTitle(f"Aravis Camera — {device}")
|
|
18
|
+
|
|
19
|
+
self.camera = aravis.Camera(device)
|
|
20
|
+
self.camera.start_acquisition_continuous()
|
|
21
|
+
|
|
22
|
+
self._last_frame: NDArray[Any] | None = None
|
|
23
|
+
self._preview_task: asyncio.Task[None] | None = None
|
|
24
|
+
|
|
25
|
+
self.central_widget = QtWidgets.QWidget()
|
|
26
|
+
self.setCentralWidget(self.central_widget)
|
|
27
|
+
layout = QtWidgets.QHBoxLayout(self.central_widget)
|
|
28
|
+
|
|
29
|
+
controls = QtWidgets.QGroupBox("Camera")
|
|
30
|
+
controls_layout = QtWidgets.QVBoxLayout(controls)
|
|
31
|
+
self.exposure_time = ExposureTimeWidget()
|
|
32
|
+
self.exposure_time.spin_exposure_time.setValue(self.camera.get_exposure_time() / 1e6)
|
|
33
|
+
self.exposure_time.exposure_time_changed.connect(self._exposure_time_changed)
|
|
34
|
+
controls_layout.addWidget(self.exposure_time)
|
|
35
|
+
self.expose = ExposeWidget(can_abort_exposure=False)
|
|
36
|
+
controls_layout.addWidget(self.expose)
|
|
37
|
+
controls_layout.addStretch()
|
|
38
|
+
layout.addWidget(controls)
|
|
39
|
+
|
|
40
|
+
self.display = DataDisplayWidget()
|
|
41
|
+
layout.addWidget(self.display)
|
|
42
|
+
|
|
43
|
+
self.expose.expose_clicked.connect(self._expose_clicked)
|
|
44
|
+
|
|
45
|
+
self._preview_task = asyncio.ensure_future(self._live_preview())
|
|
46
|
+
|
|
47
|
+
def _exposure_time_changed(self, value: float) -> None:
|
|
48
|
+
self.camera.set_exposure_time(value * 1e6)
|
|
49
|
+
|
|
50
|
+
async def _live_preview(self) -> None:
|
|
51
|
+
loop = asyncio.get_running_loop()
|
|
52
|
+
while True:
|
|
53
|
+
self._last_frame = await loop.run_in_executor(None, self.camera.pop_frame) # type: ignore
|
|
54
|
+
self.display.set_data(fits.PrimaryHDU(self._last_frame))
|
|
55
|
+
await asyncio.sleep(0.05)
|
|
56
|
+
|
|
57
|
+
@qasync.asyncSlot(int) # type: ignore
|
|
58
|
+
async def _expose_clicked(self, count: int) -> None:
|
|
59
|
+
self.expose.start_exposure(self.exposure_time.value)
|
|
60
|
+
loop = asyncio.get_running_loop()
|
|
61
|
+
for _ in range(count):
|
|
62
|
+
self._last_frame = await loop.run_in_executor(None, self.camera.pop_frame) # type: ignore
|
|
63
|
+
if self._last_frame is not None:
|
|
64
|
+
self.display.set_data(fits.PrimaryHDU(self._last_frame))
|
|
65
|
+
self.expose.set_exposures_left()
|
|
66
|
+
|
|
67
|
+
def closeEvent(self, event: Any) -> None:
|
|
68
|
+
if self._preview_task is not None:
|
|
69
|
+
self._preview_task.cancel()
|
|
70
|
+
self.camera.stop_acquisition()
|
|
71
|
+
self.camera.shutdown()
|
|
72
|
+
super().closeEvent(event)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
async def async_main(app: QtWidgets.QApplication) -> None:
|
|
76
|
+
devices: list[str] = aravis.get_device_ids()
|
|
77
|
+
if not devices:
|
|
78
|
+
QtWidgets.QMessageBox.critical(None, "Error", "No Aravis devices found.")
|
|
79
|
+
return
|
|
80
|
+
|
|
81
|
+
device_picker = ListPickerDialog(devices)
|
|
82
|
+
if device_picker.exec() != QtWidgets.QDialog.DialogCode.Accepted:
|
|
83
|
+
print("No device selected. Exiting...")
|
|
84
|
+
return
|
|
85
|
+
device_name = devices[device_picker.comboBox().currentIndex()]
|
|
86
|
+
|
|
87
|
+
app_close_event = asyncio.Event()
|
|
88
|
+
app.aboutToQuit.connect(app_close_event.set)
|
|
89
|
+
window = MainWindow(device_name)
|
|
90
|
+
window.show()
|
|
91
|
+
await app_close_event.wait()
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def main() -> None:
|
|
95
|
+
app = QtWidgets.QApplication(sys.argv)
|
|
96
|
+
with qasync.QEventLoop(app) as loop:
|
|
97
|
+
loop.run_until_complete(async_main(app))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if __name__ == "__main__":
|
|
101
|
+
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyobs-aravis
|
|
3
|
-
Version: 2.0.0.
|
|
3
|
+
Version: 2.0.0.dev4
|
|
4
4
|
Summary: pyobs module for Aravis cameras
|
|
5
5
|
Author-email: Tim-Oliver Husser <thusser@uni-goettingen.de>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -8,3 +8,6 @@ License-File: LICENSE
|
|
|
8
8
|
Requires-Python: <3.14,>=3.11
|
|
9
9
|
Requires-Dist: numpy<3,>=2.2.5
|
|
10
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'
|
|
13
|
+
Requires-Dist: qasync>=0.28.0; extra == 'gui'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pyobs_aravis/__init__.py,sha256=HVAmIguNX9cCQD9zRFmgbF2RD5TKUICfuFSKam7t9xs,83
|
|
2
|
+
pyobs_aravis/aravis.py,sha256=IeTy4WPWv7pjeAlWILg5eOGN34hFsdENAGPPclfl4I0,10724
|
|
3
|
+
pyobs_aravis/araviscamera.py,sha256=04p0BOx-nZhfPOOKr6CQO4-VKws2GJyhLdEFsRM1DMA,4287
|
|
4
|
+
pyobs_aravis/gui.py,sha256=XW_0wkAcQ732cCjjq790UmgKYXqwVlFm4tZ37A-Nuwg,3668
|
|
5
|
+
pyobs_aravis-2.0.0.dev4.dist-info/METADATA,sha256=6FLvsIRH76x7mRbpNrIfiTFwgC1R4a89eNBbBysrnzk,438
|
|
6
|
+
pyobs_aravis-2.0.0.dev4.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
7
|
+
pyobs_aravis-2.0.0.dev4.dist-info/entry_points.txt,sha256=HpPcrTEdCO90ZLViwx13nV_22WiHpQskyQFXrS8APdo,53
|
|
8
|
+
pyobs_aravis-2.0.0.dev4.dist-info/licenses/LICENSE,sha256=gC8djBliCENDmuRvzCoejpWbsn8eqKx61Hc8bmDZ2LI,1099
|
|
9
|
+
pyobs_aravis-2.0.0.dev4.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
pyobs_aravis/__init__.py,sha256=HVAmIguNX9cCQD9zRFmgbF2RD5TKUICfuFSKam7t9xs,83
|
|
2
|
-
pyobs_aravis/aravis.py,sha256=IeTy4WPWv7pjeAlWILg5eOGN34hFsdENAGPPclfl4I0,10724
|
|
3
|
-
pyobs_aravis/araviscamera.py,sha256=04p0BOx-nZhfPOOKr6CQO4-VKws2GJyhLdEFsRM1DMA,4287
|
|
4
|
-
pyobs_aravis-2.0.0.dev2.dist-info/METADATA,sha256=pe3fikK36hsj0C_B6jgzZd19svluYEjLs1cNDa0ynqE,310
|
|
5
|
-
pyobs_aravis-2.0.0.dev2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
6
|
-
pyobs_aravis-2.0.0.dev2.dist-info/licenses/LICENSE,sha256=gC8djBliCENDmuRvzCoejpWbsn8eqKx61Hc8bmDZ2LI,1099
|
|
7
|
-
pyobs_aravis-2.0.0.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|