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