etho-python 1.2.1__tar.gz → 1.2.3__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.
- {etho_python-1.2.1 → etho_python-1.2.3}/PKG-INFO +1 -1
- etho_python-1.2.3/docs/api/etho.services.camera.spinnaker_old.rst +5 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api_etho.rst +1 -1
- {etho_python-1.2.1 → etho_python-1.2.3}/pyproject.toml +1 -1
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/DAQZeroService.py +5 -11
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/camera/__init__.py +2 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/camera/spinnaker.py +20 -28
- etho_python-1.2.3/src/etho/services/camera/spinnaker_old.py +312 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/daq/IOTask.py +16 -16
- etho_python-1.2.3/tests/test_daq_playlist.py +42 -0
- etho_python-1.2.1/docs/api/etho.utils.shuffled_cycle.rst +0 -5
- etho_python-1.2.1/src/etho/services/daq/ai.py +0 -174
- etho_python-1.2.1/src/etho/utils/shuffled_cycle.py +0 -45
- etho_python-1.2.1/tests/test_shuffled_cycle.py +0 -12
- {etho_python-1.2.1 → etho_python-1.2.3}/.github/workflows/draft-pdf.yml +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/.github/workflows/python-package.yml +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/.github/workflows/static.yml +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/.gitignore +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/CITATION.cff +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/CONTRIBUTING.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/LICENSE +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/README.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/Makefile +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/README.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/_static/etho_dark.svg +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/_static/etho_light.svg +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/_templates/api_head.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/_templates/autosummary/module.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.app.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.cli.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.client.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.BLTZeroService.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.DAQZeroService.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.GCMZeroService.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.GOVZeroService.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.NICounterZeroService.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.TemplateZeroService.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.ZeroService.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.camera.base.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.camera.basler.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.camera.dummy.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.camera.hamamatsu.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.camera.spinnaker.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.camera.ximea.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.dlp.dlp_make_warpfiles.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.utils.concurrent_task.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.services.utils.log_exceptions.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.utils.calibration.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.utils.config.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.utils.runner.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.utils.sound.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.utils.tui.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/api/etho.utils.zeroclient.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/callbacks.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/cli.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/conf.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/configuration/calibration_led.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/configuration/calibration_speaker.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/configuration/configuration.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/configuration/global.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/configuration/playlist.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/configuration/protocol.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/extensions.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/hardware/camera.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/hardware/govee.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/hardware/hardware.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/hardware/nidaq.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/hardware/projector.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/hardware/scanimage.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/index.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/install.rst +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/logging.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/make.bat +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/make_api_doctree.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/docs/tutorial.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/paper/bib.bib +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/paper/fig_flow.pdf +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/paper/paper.md +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/__init__.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/app.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/assets/etho_icon1_pipeline_dark.svg +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/assets/etho_icon1_pipeline_light.svg +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/cli.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/client.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/res_app.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/resumable.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/BLTZeroService.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/DLPZeroService.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/GCMZeroService.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/GOVZeroService.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/NICounterZeroService.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/ScanImageTriggerZeroService.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/TemplateZeroService.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/ZeroService.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/__init__.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/callbacks/__init__.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/callbacks/_base.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/callbacks/_image.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/callbacks/_trace.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/camera/base.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/camera/basler.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/camera/dummy.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/camera/hamamatsu.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/camera/ximea.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/dlp/dlp_make_warpfiles.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/dlp/dlp_runners.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/resumable.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/utils/__init__.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/utils/concurrent_task.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/services/utils/log_exceptions.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/utils/__init__.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/utils/calibration.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/utils/config.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/utils/runner.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/utils/sound.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/utils/tui.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/src/etho/utils/zeroclient.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_cli_gui_smoke.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_config.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_config.yaml +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_gov_service.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_import.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_resumable.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_service_client_wiring.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_services.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_sound.py +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_sound_playlist_mono.txt +0 -0
- {etho_python-1.2.1 → etho_python-1.2.3}/tests/test_sound_playlist_stereo.txt +0 -0
|
@@ -20,7 +20,6 @@ Developer API
|
|
|
20
20
|
etho.utils.calibration
|
|
21
21
|
etho.utils.config
|
|
22
22
|
etho.utils.runner
|
|
23
|
-
etho.utils.shuffled_cycle
|
|
24
23
|
etho.utils.sound
|
|
25
24
|
etho.utils.tui
|
|
26
25
|
etho.utils.zeroclient
|
|
@@ -36,6 +35,7 @@ Developer API
|
|
|
36
35
|
etho.services.camera.dummy
|
|
37
36
|
etho.services.camera.hamamatsu
|
|
38
37
|
etho.services.camera.spinnaker
|
|
38
|
+
etho.services.camera.spinnaker_old
|
|
39
39
|
etho.services.camera.ximea
|
|
40
40
|
etho.services.utils.concurrent_task
|
|
41
41
|
etho.services.utils.log_exceptions
|
|
@@ -2,9 +2,7 @@ from .ZeroService import BaseZeroService
|
|
|
2
2
|
import time
|
|
3
3
|
import threading
|
|
4
4
|
import sys
|
|
5
|
-
import
|
|
6
|
-
from itertools import cycle
|
|
7
|
-
from typing import Iterable, Sequence, Optional, Dict, Any
|
|
5
|
+
from typing import Sequence, Optional, Dict, Any
|
|
8
6
|
from . import register_service
|
|
9
7
|
from .. import config as global_config
|
|
10
8
|
from ..utils.config import undefaultify
|
|
@@ -67,8 +65,6 @@ class DAQ(BaseZeroService):
|
|
|
67
65
|
if prot["maxduration"] == -1:
|
|
68
66
|
logging.info(f"Setting maxduration from playlist to {totallen}.")
|
|
69
67
|
prot["maxduration"] = totallen
|
|
70
|
-
playlist_items = cycle(playlist_items)
|
|
71
|
-
|
|
72
68
|
if prot[service_key]["digital_chans_out"] is not None:
|
|
73
69
|
nb_digital_chans_out = len(prot[service_key]["digital_chans_out"])
|
|
74
70
|
digital_data = [snd[:, -nb_digital_chans_out:].astype(np.uint8) for snd in sounds]
|
|
@@ -112,7 +108,7 @@ class DAQ(BaseZeroService):
|
|
|
112
108
|
def setup(
|
|
113
109
|
self,
|
|
114
110
|
savefilename: str = None,
|
|
115
|
-
play_order:
|
|
111
|
+
play_order: Sequence = None,
|
|
116
112
|
playlist_info=None,
|
|
117
113
|
duration: float = -1,
|
|
118
114
|
fs: int = 10000,
|
|
@@ -134,7 +130,7 @@ class DAQ(BaseZeroService):
|
|
|
134
130
|
|
|
135
131
|
Args:
|
|
136
132
|
savefilename (str, optional): [description]. Defaults to None.
|
|
137
|
-
play_order (
|
|
133
|
+
play_order (Sequence, optional): [description]. Defaults to None.
|
|
138
134
|
playlist_info ([type], optional): [description]. Defaults to None.
|
|
139
135
|
duration (float, optional): [description]. Defaults to -1.
|
|
140
136
|
fs (int, optional): [description]. Defaults to 10000.
|
|
@@ -185,8 +181,7 @@ class DAQ(BaseZeroService):
|
|
|
185
181
|
)
|
|
186
182
|
if analog_data_out[0].shape[-1] is not len(self.analog_chans_out):
|
|
187
183
|
raise ValueError(f"Number of analog output channels ({len(self.analog_chans_out)}) does not match the number of channels in the sound files ({analog_data_out[0].shape[-1]}).")
|
|
188
|
-
|
|
189
|
-
self.taskAO.data_gen = data_playlist(analog_data_out, play_order_new, playlist_info, self.log, name="AO")
|
|
184
|
+
self.taskAO.data_gen = data_playlist(analog_data_out, play_order, playlist_info, self.log, name="AO")
|
|
190
185
|
if clock_source is None:
|
|
191
186
|
self.taskAO.CfgDigEdgeStartTrig("ai/StartTrigger", DAQmx_Val_Rising)
|
|
192
187
|
else:
|
|
@@ -200,8 +195,7 @@ class DAQ(BaseZeroService):
|
|
|
200
195
|
clock_source=clock_source,
|
|
201
196
|
logger=self.log,
|
|
202
197
|
)
|
|
203
|
-
|
|
204
|
-
self.taskDO.data_gen = data_playlist(digital_data_out, play_order_new, name="DO")
|
|
198
|
+
self.taskDO.data_gen = data_playlist(digital_data_out, play_order, name="DO")
|
|
205
199
|
if clock_source is None:
|
|
206
200
|
self.taskDO.CfgDigEdgeStartTrig("ai/StartTrigger", DAQmx_Val_Rising)
|
|
207
201
|
else:
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from .spinnaker import Spinnaker
|
|
2
|
+
from .spinnaker_old import Spinnaker_OLD
|
|
2
3
|
from .ximea import Ximea
|
|
3
4
|
from .basler import Basler
|
|
4
5
|
from .hamamatsu import Hamamatsu
|
|
5
6
|
from .dummy import Dummy
|
|
6
7
|
|
|
7
8
|
make = {
|
|
9
|
+
"Spinnaker_OLD": Spinnaker_OLD,
|
|
8
10
|
"Spinnaker": Spinnaker,
|
|
9
11
|
"Ximea": Ximea,
|
|
10
12
|
"Basler": Basler,
|
|
@@ -2,19 +2,18 @@ import time
|
|
|
2
2
|
import numpy as np
|
|
3
3
|
from typing import Tuple, Union
|
|
4
4
|
from .base import BaseCam
|
|
5
|
-
import cv2
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
try:
|
|
9
8
|
import PySpin
|
|
9
|
+
|
|
10
10
|
pyspin_error = None
|
|
11
11
|
except ImportError as pyspin_error:
|
|
12
12
|
pass
|
|
13
13
|
|
|
14
|
-
class Spinnaker(BaseCam):
|
|
15
|
-
|
|
16
|
-
NAME = 'SPN'
|
|
17
14
|
|
|
15
|
+
class Spinnaker(BaseCam):
|
|
16
|
+
NAME = "SPN"
|
|
18
17
|
|
|
19
18
|
def __init__(self, serialnumber):
|
|
20
19
|
if pyspin_error is not None:
|
|
@@ -22,7 +21,7 @@ class Spinnaker(BaseCam):
|
|
|
22
21
|
self.serialnumber = serialnumber
|
|
23
22
|
|
|
24
23
|
def init(self):
|
|
25
|
-
self.cam_system = PySpin.
|
|
24
|
+
self.cam_system = PySpin.System.GetInstance()
|
|
26
25
|
self.cam_list = self.cam_system.GetCameras()
|
|
27
26
|
self.c = self.cam_list.GetBySerial(self.serialnumber)
|
|
28
27
|
self.c.Init()
|
|
@@ -75,7 +74,7 @@ class Spinnaker(BaseCam):
|
|
|
75
74
|
try:
|
|
76
75
|
x0, y0, x, y = x0_y0_x_y
|
|
77
76
|
except ValueError:
|
|
78
|
-
raise ValueError(
|
|
77
|
+
raise ValueError("Need 4-tuple with x0_y0_x_y")
|
|
79
78
|
else:
|
|
80
79
|
self._min_max_inc(self.c.Width, int(x))
|
|
81
80
|
self._min_max_inc(self.c.Height, int(y))
|
|
@@ -114,7 +113,7 @@ class Spinnaker(BaseCam):
|
|
|
114
113
|
|
|
115
114
|
@exposure.setter
|
|
116
115
|
def exposure(self, value: Union[float, str]):
|
|
117
|
-
if value ==
|
|
116
|
+
if value == "AUTO":
|
|
118
117
|
self.c.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous)
|
|
119
118
|
else:
|
|
120
119
|
self.c.ExposureAuto.SetValue(PySpin.ExposureAuto_Off)
|
|
@@ -127,18 +126,18 @@ class Spinnaker(BaseCam):
|
|
|
127
126
|
|
|
128
127
|
@gain.setter
|
|
129
128
|
def gain(self, value: Union[float, str]):
|
|
130
|
-
if value ==
|
|
129
|
+
if value == "AUTO":
|
|
131
130
|
self.c.GainAuto.SetValue(PySpin.GainAuto_Continuous)
|
|
132
131
|
else:
|
|
133
132
|
self.c.GainAuto.SetValue(PySpin.GainAuto_Off)
|
|
134
133
|
self.c.Gain.SetValue(float(value))
|
|
135
134
|
|
|
136
135
|
def optimize_auto_exposure(self):
|
|
137
|
-
self.setattr(
|
|
138
|
-
self.setattr(
|
|
139
|
-
self.setattr(
|
|
140
|
-
self.setattr(
|
|
141
|
-
self.setattr(
|
|
136
|
+
self.setattr("AutoExposureControlLoopDamping", 0.1)
|
|
137
|
+
self.setattr("AutoExposureLightingMode_Val", 2) # Frontlight
|
|
138
|
+
self.setattr("AutoExposureExposureTimeLowerLimit", 6)
|
|
139
|
+
self.setattr("AutoExposureExposureTimeUpperLimit", 30000)
|
|
140
|
+
self.setattr("AutoExposureEVCompensation", 3)
|
|
142
141
|
|
|
143
142
|
@property
|
|
144
143
|
def external_trigger(self):
|
|
@@ -155,12 +154,7 @@ class Spinnaker(BaseCam):
|
|
|
155
154
|
|
|
156
155
|
def _generate_attrs(self):
|
|
157
156
|
|
|
158
|
-
self._rw_modes = {
|
|
159
|
-
PySpin.RO: "read only",
|
|
160
|
-
PySpin.RW: "read/write",
|
|
161
|
-
PySpin.WO: "write only",
|
|
162
|
-
PySpin.NA: "not available"
|
|
163
|
-
}
|
|
157
|
+
self._rw_modes = {PySpin.RO: "read only", PySpin.RW: "read/write", PySpin.WO: "write only", PySpin.NA: "not available"}
|
|
164
158
|
|
|
165
159
|
self._attr_types = {
|
|
166
160
|
PySpin.intfIFloat: PySpin.CFloatPtr,
|
|
@@ -171,12 +165,12 @@ class Spinnaker(BaseCam):
|
|
|
171
165
|
}
|
|
172
166
|
|
|
173
167
|
self._attr_type_names = {
|
|
174
|
-
PySpin.intfIFloat:
|
|
175
|
-
PySpin.intfIBoolean:
|
|
176
|
-
PySpin.intfIInteger:
|
|
177
|
-
PySpin.intfIEnumeration:
|
|
178
|
-
PySpin.intfIString:
|
|
179
|
-
PySpin.intfICommand:
|
|
168
|
+
PySpin.intfIFloat: "float",
|
|
169
|
+
PySpin.intfIBoolean: "bool",
|
|
170
|
+
PySpin.intfIInteger: "int",
|
|
171
|
+
PySpin.intfIEnumeration: "enum",
|
|
172
|
+
PySpin.intfIString: "string",
|
|
173
|
+
PySpin.intfICommand: "command",
|
|
180
174
|
}
|
|
181
175
|
|
|
182
176
|
self.camera_attributes = {}
|
|
@@ -195,7 +189,6 @@ class Spinnaker(BaseCam):
|
|
|
195
189
|
|
|
196
190
|
def getattr(self, attr):
|
|
197
191
|
if attr in self.camera_attributes:
|
|
198
|
-
|
|
199
192
|
prop = self.camera_attributes[attr]
|
|
200
193
|
if not PySpin.IsReadable(prop):
|
|
201
194
|
raise AttributeError("Camera property '%s' is not readable" % attr)
|
|
@@ -213,12 +206,11 @@ class Spinnaker(BaseCam):
|
|
|
213
206
|
|
|
214
207
|
def setattr(self, attr, val):
|
|
215
208
|
if attr in self.camera_attributes:
|
|
216
|
-
|
|
217
209
|
prop = self.camera_attributes[attr]
|
|
218
210
|
if not PySpin.IsWritable(prop):
|
|
219
211
|
raise AttributeError("Property '%s' is not currently writable!" % attr)
|
|
220
212
|
|
|
221
|
-
if hasattr(prop,
|
|
213
|
+
if hasattr(prop, "SetValue"):
|
|
222
214
|
prop.SetValue(val)
|
|
223
215
|
else:
|
|
224
216
|
prop.FromString(val)
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import numpy as np
|
|
3
|
+
from typing import Tuple, Union
|
|
4
|
+
from .base import BaseCam
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
import PySpin
|
|
9
|
+
|
|
10
|
+
pyspin_error = None
|
|
11
|
+
except ImportError as pyspin_error:
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Spinnaker_OLD(BaseCam):
|
|
16
|
+
"""Supports older FLIR cameras (Flea3, Grasshopper) with only partial support for the Spinnaker SDK."""
|
|
17
|
+
|
|
18
|
+
NAME = "SPO"
|
|
19
|
+
|
|
20
|
+
def __init__(self, serialnumber):
|
|
21
|
+
if pyspin_error is not None:
|
|
22
|
+
raise pyspin_error
|
|
23
|
+
self.serialnumber = serialnumber
|
|
24
|
+
|
|
25
|
+
def init(self):
|
|
26
|
+
self.cam_system = PySpin.System.GetInstance()
|
|
27
|
+
self.cam_list = self.cam_system.GetCameras()
|
|
28
|
+
self.c = self.cam_list.GetBySerial(self.serialnumber)
|
|
29
|
+
self.c.Init()
|
|
30
|
+
self.c.PixelFormat.SetValue(PySpin.PixelFormat_Mono8)
|
|
31
|
+
self._generate_attrs()
|
|
32
|
+
|
|
33
|
+
# enable embedding of frame TIME STAMP
|
|
34
|
+
self.c.ChunkModeActive.SetValue(True)
|
|
35
|
+
self.c.ChunkSelector.SetValue(PySpin.ChunkSelector_Timestamp)
|
|
36
|
+
self.c.ChunkEnable.SetValue(True)
|
|
37
|
+
self.timestamp_offset = 0 # self._estimate_timestamp_offset()
|
|
38
|
+
|
|
39
|
+
# set pixel format
|
|
40
|
+
self.c.PixelFormat.SetValue(PySpin.PixelFormat_Mono8)
|
|
41
|
+
|
|
42
|
+
# set continuous acquisition
|
|
43
|
+
self.c.AcquisitionMode.SetValue(PySpin.AcquisitionMode_Continuous)
|
|
44
|
+
|
|
45
|
+
self.timeout = PySpin.EVENT_TIMEOUT_INFINITE
|
|
46
|
+
self.processor = PySpin.ImageProcessor()
|
|
47
|
+
self.processor.SetColorProcessing(PySpin.SPINNAKER_COLOR_PROCESSING_ALGORITHM_HQ_LINEAR)
|
|
48
|
+
|
|
49
|
+
def get(self, timeout=None):
|
|
50
|
+
|
|
51
|
+
# get image
|
|
52
|
+
im = self.c.GetNextImage(self.timeout)
|
|
53
|
+
system_stimestamp = time.time()
|
|
54
|
+
|
|
55
|
+
if im.IsIncomplete():
|
|
56
|
+
im.Release()
|
|
57
|
+
raise ValueError(f"Image incomplete with image status {im.GetImageStatus()}")
|
|
58
|
+
else:
|
|
59
|
+
im_converted = self.processor.Convert(im, PySpin.PixelFormat_BGR8)
|
|
60
|
+
image_timestamp = im.GetTimeStamp()
|
|
61
|
+
im.Release()
|
|
62
|
+
|
|
63
|
+
BGR = im_converted.GetNDArray()
|
|
64
|
+
image_timestamp = image_timestamp / 1e9 + self.timestamp_offset
|
|
65
|
+
return BGR, image_timestamp, system_stimestamp
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def roi(self) -> Tuple[int, int, int, int]:
|
|
69
|
+
return self.c.OffsetX.GetValue(), self.c.OffsetY.GetValue(), self.c.Width.GetValue(), self.c.Height.GetValue()
|
|
70
|
+
|
|
71
|
+
@roi.setter
|
|
72
|
+
def roi(self, x0_y0_x_y: Tuple[int, int, int, int]):
|
|
73
|
+
try:
|
|
74
|
+
x0, y0, x, y = x0_y0_x_y
|
|
75
|
+
except ValueError:
|
|
76
|
+
raise ValueError("Need 4-tuple with x0_y0_x_y")
|
|
77
|
+
else:
|
|
78
|
+
self._min_max_inc(self.c.Width, int(x))
|
|
79
|
+
self._min_max_inc(self.c.Height, int(y))
|
|
80
|
+
self._min_max_inc(self.c.OffsetX, int(x0))
|
|
81
|
+
self._min_max_inc(self.c.OffsetY, int(y0))
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def framerate(self):
|
|
85
|
+
return self.c.AcquisitionFrameRate.GetValue()
|
|
86
|
+
|
|
87
|
+
@framerate.setter
|
|
88
|
+
def framerate(self, value: float):
|
|
89
|
+
nodemap = self.c.GetNodeMap()
|
|
90
|
+
self.c.TriggerMode.SetValue(PySpin.TriggerMode_Off)
|
|
91
|
+
node = PySpin.CEnumerationPtr(nodemap.GetNode("AcquisitionFrameRateAuto"))
|
|
92
|
+
val = PySpin.CEnumEntryPtr(node.GetEntryByName("Off")).GetValue() # Once, Continuous
|
|
93
|
+
node.SetIntValue(val)
|
|
94
|
+
self.c.AcquisitionFrameRate.SetValue(float(value))
|
|
95
|
+
|
|
96
|
+
@property
|
|
97
|
+
def gamma(self):
|
|
98
|
+
return self.c.Gamma.GetValue()
|
|
99
|
+
|
|
100
|
+
@gamma.setter
|
|
101
|
+
def gamma(self, value: float):
|
|
102
|
+
# self.c.GammaEnabled.SetValue(bool(True))
|
|
103
|
+
self.c.Gamma.SetValue(value)
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def brightness(self) -> float:
|
|
107
|
+
return self.c.BlackLevel.GetValue()
|
|
108
|
+
|
|
109
|
+
@brightness.setter
|
|
110
|
+
def brightness(self, value: float):
|
|
111
|
+
# self.c.BlackLevelSelector.SetValue(PySpin.BlackLevelSelector_All)
|
|
112
|
+
self.c.BlackLevel.SetValue(float(value))
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
def exposure(self):
|
|
116
|
+
return self.c.ExposureTime.GetValue()
|
|
117
|
+
|
|
118
|
+
@exposure.setter
|
|
119
|
+
def exposure(self, value: Union[float, str]):
|
|
120
|
+
if value == "AUTO":
|
|
121
|
+
self.c.ExposureAuto.SetValue(PySpin.ExposureAuto_Continuous)
|
|
122
|
+
else:
|
|
123
|
+
self.c.ExposureAuto.SetValue(PySpin.ExposureAuto_Off)
|
|
124
|
+
self.c.ExposureMode.SetValue(PySpin.ExposureMode_Timed)
|
|
125
|
+
self.c.ExposureTime.SetValue(float(value))
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def gain(self):
|
|
129
|
+
self.c.Gain.GetValue()
|
|
130
|
+
|
|
131
|
+
@gain.setter
|
|
132
|
+
def gain(self, value: Union[float, str]):
|
|
133
|
+
if value == "AUTO":
|
|
134
|
+
self.c.GainAuto.SetValue(PySpin.GainAuto_Continuous)
|
|
135
|
+
else:
|
|
136
|
+
self.c.GainAuto.SetValue(PySpin.GainAuto_Off)
|
|
137
|
+
self.c.Gain.SetValue(float(value))
|
|
138
|
+
|
|
139
|
+
def optimize_auto_exposure(self):
|
|
140
|
+
self.setattr("AutoExposureControlLoopDamping", 0.1)
|
|
141
|
+
self.setattr("AutoExposureLightingMode_Val", 2) # Frontlight
|
|
142
|
+
self.setattr("AutoExposureExposureTimeLowerLimit", 6)
|
|
143
|
+
self.setattr("AutoExposureExposureTimeUpperLimit", 30000)
|
|
144
|
+
self.setattr("AutoExposureEVCompensation", 3)
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def external_trigger(self):
|
|
148
|
+
return self.c.TriggerMode.GetValue()
|
|
149
|
+
|
|
150
|
+
@external_trigger.setter
|
|
151
|
+
def external_trigger(self, value: bool = False):
|
|
152
|
+
self.c.TriggerMode.SetValue(PySpin.TriggerMode_Off)
|
|
153
|
+
|
|
154
|
+
if value:
|
|
155
|
+
self.c.TriggerSource.SetValue(PySpin.TriggerSource_Line3)
|
|
156
|
+
self.c.TriggerMode.SetValue(PySpin.TriggerMode_On)
|
|
157
|
+
|
|
158
|
+
def _generate_attrs(self):
|
|
159
|
+
|
|
160
|
+
self._rw_modes = {PySpin.RO: "read only", PySpin.RW: "read/write", PySpin.WO: "write only", PySpin.NA: "not available"}
|
|
161
|
+
|
|
162
|
+
self._attr_types = {
|
|
163
|
+
PySpin.intfIFloat: PySpin.CFloatPtr,
|
|
164
|
+
PySpin.intfIBoolean: PySpin.CBooleanPtr,
|
|
165
|
+
PySpin.intfIInteger: PySpin.CIntegerPtr,
|
|
166
|
+
PySpin.intfIEnumeration: PySpin.CEnumerationPtr,
|
|
167
|
+
PySpin.intfIString: PySpin.CStringPtr,
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
self._attr_type_names = {
|
|
171
|
+
PySpin.intfIFloat: "float",
|
|
172
|
+
PySpin.intfIBoolean: "bool",
|
|
173
|
+
PySpin.intfIInteger: "int",
|
|
174
|
+
PySpin.intfIEnumeration: "enum",
|
|
175
|
+
PySpin.intfIString: "string",
|
|
176
|
+
PySpin.intfICommand: "command",
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
self.camera_attributes = {}
|
|
180
|
+
self.camera_methods = {}
|
|
181
|
+
self.camera_node_types = {}
|
|
182
|
+
|
|
183
|
+
for node in self.c.GetNodeMap().GetNodes():
|
|
184
|
+
pit = node.GetPrincipalInterfaceType()
|
|
185
|
+
name = node.GetName()
|
|
186
|
+
self.camera_node_types[name] = self._attr_type_names.get(pit, pit)
|
|
187
|
+
if pit == PySpin.intfICommand:
|
|
188
|
+
self.camera_methods[name] = PySpin.CCommandPtr(node)
|
|
189
|
+
if pit in self._attr_types:
|
|
190
|
+
self.camera_attributes[name] = self._attr_types[pit](node)
|
|
191
|
+
self.initialized = True
|
|
192
|
+
|
|
193
|
+
def getattr(self, attr):
|
|
194
|
+
if attr in self.camera_attributes:
|
|
195
|
+
prop = self.camera_attributes[attr]
|
|
196
|
+
if not PySpin.IsReadable(prop):
|
|
197
|
+
raise AttributeError("Camera property '%s' is not readable" % attr)
|
|
198
|
+
|
|
199
|
+
if hasattr(prop, "GetValue"):
|
|
200
|
+
return prop.GetValue()
|
|
201
|
+
elif hasattr(prop, "ToString"):
|
|
202
|
+
return prop.ToString()
|
|
203
|
+
else:
|
|
204
|
+
raise AttributeError("Camera property '%s' is not readable" % attr)
|
|
205
|
+
elif attr in self.camera_methods:
|
|
206
|
+
return self.camera_methods[attr].Execute
|
|
207
|
+
else:
|
|
208
|
+
raise AttributeError(attr)
|
|
209
|
+
|
|
210
|
+
def setattr(self, attr, val):
|
|
211
|
+
if attr in self.camera_attributes:
|
|
212
|
+
prop = self.camera_attributes[attr]
|
|
213
|
+
if not PySpin.IsWritable(prop):
|
|
214
|
+
raise AttributeError("Property '%s' is not currently writable!" % attr)
|
|
215
|
+
|
|
216
|
+
if hasattr(prop, "SetValue"):
|
|
217
|
+
prop.SetValue(val)
|
|
218
|
+
else:
|
|
219
|
+
prop.FromString(val)
|
|
220
|
+
|
|
221
|
+
elif attr in self.camera_methods:
|
|
222
|
+
raise AttributeError("Camera method '%s' is a function -- you can't assign it a value!" % attr)
|
|
223
|
+
else:
|
|
224
|
+
if attr not in self.__dict__ and self.lock and self.initialized:
|
|
225
|
+
raise AttributeError("Unknown property '%s'." % attr)
|
|
226
|
+
else:
|
|
227
|
+
raise AttributeError(attr)
|
|
228
|
+
|
|
229
|
+
def _min_max_inc(self, prop, value=None, set_value=True):
|
|
230
|
+
min_val, max_val, inc = prop.GetMin(), prop.GetMax(), prop.GetInc()
|
|
231
|
+
|
|
232
|
+
prop_type = type(prop.GetValue())
|
|
233
|
+
if value is not None:
|
|
234
|
+
value = np.clip(value, min_val, max_val)
|
|
235
|
+
value = np.round(value / inc) * inc
|
|
236
|
+
if set_value:
|
|
237
|
+
value = prop_type(value)
|
|
238
|
+
prop.SetValue(value)
|
|
239
|
+
value = prop.GetValue()
|
|
240
|
+
return value
|
|
241
|
+
|
|
242
|
+
def _estimate_timestamp_offset(self, timestamp_offset_iterations=10):
|
|
243
|
+
"""Gets offset between system time and timestamps."""
|
|
244
|
+
# This method is required because the timestamp stored in the camera is relative to when it was powered on, so an
|
|
245
|
+
# offset needs to be applied to get it into epoch time; from tests I’ve done, this appears to be accurate to ~1e-3
|
|
246
|
+
# seconds.
|
|
247
|
+
timestamp_offsets = []
|
|
248
|
+
for i in range(timestamp_offset_iterations):
|
|
249
|
+
# Latch timestamp. This basically “freezes” the current camera timer into a variable that can be read with
|
|
250
|
+
self.c.TimestampLatch.Execute()
|
|
251
|
+
system_time = time.time()
|
|
252
|
+
# Compute timestamp offset in seconds; note that timestamp latch value is in nanoseconds
|
|
253
|
+
timestamp_offset = system_time - self.c.TimestampLatchValue.GetValue() / 1e9
|
|
254
|
+
timestamp_offsets.append(timestamp_offset)
|
|
255
|
+
# Return the median value
|
|
256
|
+
return np.median(timestamp_offsets)
|
|
257
|
+
|
|
258
|
+
def enable_gpio_strobe(self):
|
|
259
|
+
pass # self._set_gpio_strobe(enable=True)
|
|
260
|
+
|
|
261
|
+
def disable_gpio_strobe(self):
|
|
262
|
+
pass # self._set_gpio_strobe(enable=False)
|
|
263
|
+
|
|
264
|
+
def set_node_and_entry(self, node_name: str, entry_name: str):
|
|
265
|
+
nodemap = self.c.GetNodeMap()
|
|
266
|
+
|
|
267
|
+
node = PySpin.CEnumerationPtr(nodemap.GetNode(node_name))
|
|
268
|
+
if not PySpin.IsAvailable(node) or not PySpin.IsWritable(node):
|
|
269
|
+
raise ValueError(f"Cannot retrieve node {node_name}.")
|
|
270
|
+
|
|
271
|
+
entry = node.GetEntryByName(entry_name)
|
|
272
|
+
if not PySpin.IsAvailable(entry) or not PySpin.IsReadable(entry):
|
|
273
|
+
raise ValueError(f"Cannot retrieve entry {entry_name} from node {node_name}.")
|
|
274
|
+
|
|
275
|
+
node.SetIntValue(entry.GetValue())
|
|
276
|
+
|
|
277
|
+
# def _set_gpio_strobe(self, line: str = "Line2", enable: bool = True):
|
|
278
|
+
# # from PySpin/Examples/Python3/CounterAndTimer.py
|
|
279
|
+
# # from https://github.com/CapAI/misc/blob/a22cd50e90018c03cde3c1339aa622185502bb05/spinnaker/pyspin/Examples/Python3/CounterAndTimer.py#L193
|
|
280
|
+
# if enable:
|
|
281
|
+
# line_mode = "Output"
|
|
282
|
+
# else:
|
|
283
|
+
# line_mode = "Input"
|
|
284
|
+
|
|
285
|
+
# # Select line to control
|
|
286
|
+
# self.set_node_and_entry("LineSelector", line)
|
|
287
|
+
# self.set_node_and_entry("LineMode", line_mode)
|
|
288
|
+
# self.set_node_and_entry("LineSource", "ExposureActive")
|
|
289
|
+
|
|
290
|
+
def reset(self, sleep: float = 10.0):
|
|
291
|
+
device_reset = PySpin.CCommandPtr(self.c.GetNodeMap().GetNode("DeviceReset"))
|
|
292
|
+
device_reset.Execute()
|
|
293
|
+
self.close()
|
|
294
|
+
time.sleep(sleep)
|
|
295
|
+
|
|
296
|
+
def start(self):
|
|
297
|
+
self.c.BeginAcquisition()
|
|
298
|
+
|
|
299
|
+
def stop(self):
|
|
300
|
+
try:
|
|
301
|
+
self.c.EndAcquisition() # not sure this works if BeginAcquistion has not been called
|
|
302
|
+
except:
|
|
303
|
+
pass
|
|
304
|
+
|
|
305
|
+
def close(self):
|
|
306
|
+
self.stop() # should check if cam started
|
|
307
|
+
self.c.DeInit()
|
|
308
|
+
del self.c
|
|
309
|
+
self.cam_list.Clear()
|
|
310
|
+
del self.cam_list
|
|
311
|
+
# self.cam_system.ReleaseInstance()
|
|
312
|
+
# del self.cam_system
|
|
@@ -292,22 +292,22 @@ def coroutine(func):
|
|
|
292
292
|
|
|
293
293
|
|
|
294
294
|
@coroutine
|
|
295
|
-
def data_playlist(sounds, play_order, playlist_info=None, logger=None, name="standard"):
|
|
296
|
-
"""sounds - list of nparrays"""
|
|
297
|
-
first_run = True
|
|
298
|
-
|
|
299
|
-
playlist_cnt = 0
|
|
300
|
-
|
|
301
|
-
try:
|
|
302
|
-
while play_order:
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
playlist_cnt += 1
|
|
295
|
+
def data_playlist(sounds, play_order, playlist_info=None, logger=None, name="standard"):
|
|
296
|
+
"""sounds - list of nparrays"""
|
|
297
|
+
first_run = True
|
|
298
|
+
playlist_index = 0
|
|
299
|
+
playlist_cnt = 0
|
|
300
|
+
|
|
301
|
+
try:
|
|
302
|
+
while play_order:
|
|
303
|
+
# duplicate first stim - otherwise we miss the first in the playlist
|
|
304
|
+
if first_run:
|
|
305
|
+
pp = 0
|
|
306
|
+
first_run = False
|
|
307
|
+
else:
|
|
308
|
+
pp = play_order[playlist_index % len(play_order)]
|
|
309
|
+
playlist_index += 1
|
|
310
|
+
playlist_cnt += 1
|
|
311
311
|
if playlist_info is not None:
|
|
312
312
|
msg = _format_playlist(playlist_info.loc[pp], playlist_cnt)
|
|
313
313
|
if logger:
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import pickle
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from etho.services.DAQZeroService import DAQ
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FakeService:
|
|
9
|
+
def setup(self, *args, **kwargs):
|
|
10
|
+
self.play_order = args[1]
|
|
11
|
+
|
|
12
|
+
def init_local_logger(self, *_):
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_setup_client_passes_pickleable_playlist(monkeypatch):
|
|
17
|
+
service = FakeService()
|
|
18
|
+
monkeypatch.setattr(DAQ, "make", lambda *args, **kwargs: service)
|
|
19
|
+
monkeypatch.setattr("etho.services.DAQZeroService.parse_table", lambda _: None)
|
|
20
|
+
monkeypatch.setattr("etho.services.DAQZeroService.load_sounds", lambda *args, **kwargs: [np.zeros((1, 1)), np.zeros((1, 1))])
|
|
21
|
+
monkeypatch.setattr("etho.services.DAQZeroService.build_playlist", lambda *args, **kwargs: ([1, 0], 2))
|
|
22
|
+
|
|
23
|
+
daq = {
|
|
24
|
+
"samplingrate": 1,
|
|
25
|
+
"shuffle": False,
|
|
26
|
+
"device": None,
|
|
27
|
+
"port": None,
|
|
28
|
+
"clock_source": None,
|
|
29
|
+
"nb_inputsamples_per_cycle": 1,
|
|
30
|
+
"analog_chans_in": [],
|
|
31
|
+
"analog_chans_out": None,
|
|
32
|
+
"digital_chans_out": None,
|
|
33
|
+
"analog_chans_in_info": None,
|
|
34
|
+
"analog_chans_out_info": None,
|
|
35
|
+
"digital_chans_out_info": None,
|
|
36
|
+
}
|
|
37
|
+
defaults = {"host": "localhost", "serializer": "default", "python_exe": "python", "savefolder": "/tmp"}
|
|
38
|
+
|
|
39
|
+
DAQ.setup_client("DAQ", 0, {"DAQ": daq, "maxduration": 1}, defaults, "playlist.txt", "run", False, False)
|
|
40
|
+
|
|
41
|
+
assert service.play_order == [1, 0]
|
|
42
|
+
pickle.dumps(service.play_order)
|