Skip to content

Commit a319584

Browse files
authored
Merge pull request #2046 from pupil-labs/develop
Pupil v2.6 Release Candidate 1
2 parents e8bcba1 + 4c7dcec commit a319584

18 files changed

+684
-133
lines changed

.travis.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ jobs:
2222
2323
- name: black formatting check
2424
language: python
25+
before_install: pip install -U pip
2526
# Travis automatically runs `pip install -r requirements.txt` if such a file is present.
2627
# Source: https://docs.travis-ci.com/user/languages/python/#dependency-management
27-
# Since we do not need the requirements to be installed, we overwrite
28-
install: ~
29-
before_script:
30-
- pip install -U pip
31-
- pip install black
28+
# Since we only need black to be installed, we overwrite with:
29+
install: pip install black
3230
script:
3331
- >
3432
black . --check --exclude pupil_src/tests || (

docs/dependencies-macos.md

+3-23
Original file line numberDiff line numberDiff line change
@@ -62,32 +62,12 @@ make && make install
6262

6363
### Install Python Libraries
6464

65-
We recommend using a [virtual environment](https://docs.python.org/3/tutorial/venv.html) for running Pupil.
65+
We recommend using a [virtual environment](https://docs.python.org/3/tutorial/venv.html) for running Pupil. To install all Python dependencies, you can use the [`requirements.txt`](https://github.com/pupil-labs/pupil/blob/master/requirements.txt) file from the root of the `pupil` repository.
6666

6767
```sh
6868
# Upgrade pip to latest version. This is necessary for some dependencies.
69-
python -m pip install --upgrade pip
70-
71-
pip install cysignals
72-
pip install cython
73-
pip install msgpack==0.5.6
74-
pip install numexpr
75-
pip install packaging
76-
pip install psutil
77-
pip install pyaudio
78-
pip install pyopengl
79-
pip install pyzmq
80-
pip install scikit-learn
81-
pip install scipy
82-
pip install glfw
83-
pip install git+https://github.com/zeromq/pyre
84-
85-
pip install pupil-apriltags
86-
pip install pupil-detectors
87-
pip install git+https://github.com/pupil-labs/PyAV
88-
pip install git+https://github.com/pupil-labs/pyuvc
89-
pip install git+https://github.com/pupil-labs/pyndsi
90-
pip install git+https://github.com/pupil-labs/pyglui
69+
python -m pip install --upgrade pip wheel
70+
pip install -r requirements.txt
9171
```
9272

9373
**NOTE:** Installing **pyglui** might fail on newer versions of **macOS** due to missing OpenGL headers. In this case, you need to install Xcode which comes with the required header files.

docs/dependencies-ubuntu17.md

+3-23
Original file line numberDiff line numberDiff line change
@@ -152,32 +152,12 @@ sudo ldconfig
152152

153153
### Install Python Libraries
154154

155-
We recommend using a [virtual environment](https://docs.python.org/3/tutorial/venv.html) for running Pupil.
155+
We recommend using a [virtual environment](https://docs.python.org/3/tutorial/venv.html) for running Pupil. To install all Python dependencies, you can use the [`requirements.txt`](https://github.com/pupil-labs/pupil/blob/master/requirements.txt) file from the root of the `pupil` repository.
156156

157157
```sh
158158
# Upgrade pip to latest version. This is necessary for some dependencies.
159-
python -m pip install --upgrade pip
160-
161-
pip install cysignals
162-
pip install cython
163-
pip install msgpack==0.5.6
164-
pip install numexpr
165-
pip install packaging
166-
pip install psutil
167-
pip install pyaudio
168-
pip install pyopengl
169-
pip install pyzmq
170-
pip install scikit-learn
171-
pip install scipy
172-
pip install glfw
173-
pip install git+https://github.com/zeromq/pyre
174-
175-
pip install pupil-apriltags
176-
pip install pupil-detectors
177-
pip install git+https://github.com/pupil-labs/PyAV
178-
pip install git+https://github.com/pupil-labs/pyuvc
179-
pip install git+https://github.com/pupil-labs/pyndsi
180-
pip install git+https://github.com/pupil-labs/pyglui
159+
python -m pip install --upgrade pip wheel
160+
pip install -r requirements.txt
181161
```
182162

183163
**NOTE**: If you get the error `ImportError: No module named 'cv2'` when trying to run Pupil, please refer to the section [OpenCV Troubleshooting](#opencv-troubleshooting) above.

docs/dependencies-ubuntu18.md

+3-23
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,12 @@ sudo udevadm trigger
6363

6464
### Install Python Libraries
6565

66-
We recommend using a [virtual environment](https://docs.python.org/3/tutorial/venv.html) for running Pupil.
66+
We recommend using a [virtual environment](https://docs.python.org/3/tutorial/venv.html) for running Pupil. To install all Python dependencies, you can use the [`requirements.txt`](https://github.com/pupil-labs/pupil/blob/master/requirements.txt) file from the root of the `pupil` repository.
6767

6868
```sh
6969
# Upgrade pip to latest version. This is necessary for some dependencies.
70-
python -m pip install --upgrade pip
71-
72-
pip install cysignals
73-
pip install cython
74-
pip install msgpack==0.5.6
75-
pip install numexpr
76-
pip install packaging
77-
pip install psutil
78-
pip install pyaudio
79-
pip install pyopengl
80-
pip install pyzmq
81-
pip install scikit-learn
82-
pip install scipy
83-
pip install glfw
84-
pip install git+https://github.com/zeromq/pyre
85-
86-
pip install pupil-apriltags
87-
pip install pupil-detectors
88-
pip install git+https://github.com/pupil-labs/PyAV
89-
pip install git+https://github.com/pupil-labs/pyuvc
90-
pip install git+https://github.com/pupil-labs/pyndsi
91-
pip install git+https://github.com/pupil-labs/pyglui
70+
python -m pip install --upgrade pip wheel
71+
pip install -r requirements.txt
9272
```
9373

9474
### OpenCV Troubleshooting

docs/dependencies-windows.md

+4-38
Original file line numberDiff line numberDiff line change
@@ -48,51 +48,17 @@ If you downloaded the linked installer:
4848
- Check the box `Add Python to PATH`. This will add Python to your System PATH Environment Variable.
4949
- Check the box `Install for all users`. **Note:** By default this will install Python to `C:\Program Files\Python36`. Some build scripts may fail to start Python due to spaces in the path name. So, you may want to consider installing Python to `C:\Python36` instead.
5050

51-
5251
## Install Python Libraries
5352

54-
We recommend using a [virtual environment](https://docs.python.org/3/tutorial/venv.html) for running Pupil.
53+
We recommend using a [virtual environment](https://docs.python.org/3/tutorial/venv.html) for running Pupil. To install all Python dependencies, you can use the [`requirements.txt`](https://github.com/pupil-labs/pupil/blob/master/requirements.txt) file from the root of the `pupil` repository.
5554

5655
```sh
5756
# Upgrade pip to latest version. This is necessary for some dependencies.
58-
python -m pip install --upgrade pip
59-
60-
pip install cython
61-
pip install msgpack==0.5.6
62-
pip install numexpr
63-
pip install opencv-python==3.*
64-
pip install packaging
65-
pip install psutil
66-
pip install pyaudio
67-
pip install pyopengl
68-
pip install pyzmq
69-
pip install scikit-learn
70-
pip install scipy
71-
pip install glfw
72-
pip install win_inet_pton
73-
pip install git+https://github.com/zeromq/pyre
74-
75-
pip install pupil-apriltags
76-
pip install pupil-detectors
57+
python -m pip install --upgrade pip wheel
58+
pip install -r requirements.txt
7759
```
7860

79-
## Pupil Labs Python Wheels
80-
81-
In addition to these libraries, you will need to install some Pupil-Labs support libraries. Since building them for Windows is also not automated yet, we provide some prebuilt wheels that you can use. If you want to build the support libraries yourself as well, you will have to look for install instructions on the respective GitHub repositories.
82-
83-
Download the following Python wheels from Pupil Labs github repos:
84-
85-
- [pyglui](https://github.com/pupil-labs/pyglui/releases/latest)
86-
- [pyav](https://github.com/pupil-labs/pyav/releases/latest)
87-
- [pyndsi](https://github.com/pupil-labs/pyndsi/releases/latest)
88-
- [pyuvc](https://github.com/pupil-labs/pyuvc/releases/latest)
89-
90-
`pyuvc` requires that you download Microsoft Visual C++ 2010 Redistributable from [microsoft](https://www.microsoft.com/en-us/download/details.aspx?id=14632). The `pthreadVC2` lib, which is used by libuvc, depends on `msvcr100.dll`.
91-
92-
Open your command prompt and `Run as administrator` in the directory where the wheels are downloaded.
93-
94-
- Install all wheels with `pip install X` (where X is the name of the `.whl` file)
95-
- You can check that libs are installed with `python import X` statements in the command prompt where `X` is the name of the lib.
61+
**NOTE:** `pyuvc` requires that you download Microsoft Visual C++ 2010 Redistributable from [microsoft](https://www.microsoft.com/en-us/download/details.aspx?id=14632). The `pthreadVC2` lib, which is used by libuvc, depends on `msvcr100.dll`.
9662

9763
## Modifying Pupil to Work with Windows
9864

pupil_src/launchables/eye.py

+46-4
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,30 @@ def get_timestamp():
204204
g_pool.get_timestamp = get_timestamp
205205
g_pool.get_now = get_time_monotonic
206206

207+
def load_runtime_pupil_detection_plugins():
208+
from plugin import import_runtime_plugins
209+
from pupil_detector_plugins.detector_base_plugin import PupilDetectorPlugin
210+
211+
plugins_path = os.path.join(g_pool.user_dir, "plugins")
212+
213+
for plugin in import_runtime_plugins(plugins_path):
214+
if not isinstance(plugin, type):
215+
continue
216+
if not issubclass(plugin, PupilDetectorPlugin):
217+
continue
218+
if plugin is PupilDetectorPlugin:
219+
continue
220+
yield plugin
221+
207222
default_2d, default_3d, available_detectors = available_detector_plugins()
208-
plugins = manager_classes + source_classes + available_detectors + [Roi]
223+
runtime_detectors = list(load_runtime_pupil_detection_plugins())
224+
plugins = (
225+
manager_classes
226+
+ source_classes
227+
+ available_detectors
228+
+ runtime_detectors
229+
+ [Roi]
230+
)
209231
g_pool.plugin_by_name = {p.__name__: p for p in plugins}
210232

211233
preferred_names = [
@@ -513,6 +535,14 @@ def set_window_size():
513535
# with incorrect settings that were loaded from session settings.
514536
plugins_to_load.append(overwrite_cap_settings)
515537

538+
# Add runtime plugins to the list of plugins to load with default arguments,
539+
# if not already restored from session settings
540+
plugins_to_load_names = set(name for name, _ in plugins_to_load)
541+
for runtime_detector in runtime_detectors:
542+
runtime_name = runtime_detector.__name__
543+
if runtime_name not in plugins_to_load_names:
544+
plugins_to_load.append((runtime_name, {}))
545+
516546
g_pool.plugins = Plugin_List(g_pool, plugins_to_load)
517547

518548
if not g_pool.capture:
@@ -590,7 +620,8 @@ def window_should_update():
590620
glfw.swap_interval(0)
591621

592622
# Event loop
593-
while not glfw.window_should_close(main_window):
623+
window_should_close = False
624+
while not window_should_close:
594625

595626
if notify_sub.new_data:
596627
t, notification = notify_sub.recv()
@@ -657,6 +688,17 @@ def window_should_update():
657688
)
658689
except KeyError as err:
659690
logger.error(f"Attempt to load unknown plugin: {err}")
691+
elif (
692+
subject.startswith("stop_eye_plugin")
693+
and notification["target"] == g_pool.process
694+
):
695+
try:
696+
plugin_to_stop = g_pool.plugin_by_name[notification["name"]]
697+
except KeyError as err:
698+
logger.error(f"Attempt to load unknown plugin: {err}")
699+
else:
700+
plugin_to_stop.alive = False
701+
g_pool.plugins.clean()
660702

661703
for plugin in g_pool.plugins:
662704
plugin.on_notify(notification)
@@ -724,13 +766,13 @@ def window_should_update():
724766
for result in event.get(EVENT_KEY, ()):
725767
pupil_socket.send(result)
726768

727-
cpu_graph.update()
728-
729769
# GL drawing
730770
if window_should_update():
771+
cpu_graph.update()
731772
if is_window_visible(main_window):
732773
consume_events_and_render_buffer()
733774
glfw.poll_events()
775+
window_should_close = glfw.window_should_close(main_window)
734776

735777
# END while running
736778

pupil_src/launchables/player.py

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def player(
117117
from gaze_producer.gaze_from_offline_calibration import (
118118
GazeFromOfflineCalibration,
119119
)
120+
from pupil_detector_plugins.detector_base_plugin import PupilDetectorPlugin
120121
from system_graphs import System_Graphs
121122
from system_timelines import System_Timelines
122123
from blink_detection import Offline_Blink_Detection
@@ -152,6 +153,9 @@ def interrupt_handler(sig, frame):
152153
signal.signal(signal.SIGINT, interrupt_handler)
153154

154155
runtime_plugins = import_runtime_plugins(os.path.join(user_dir, "plugins"))
156+
runtime_plugins = [
157+
p for p in runtime_plugins if not issubclass(p, PupilDetectorPlugin)
158+
]
155159
system_plugins = [
156160
Log_Display,
157161
Seek_Control,

pupil_src/launchables/world.py

+4
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def detection_enabled_setter(is_on: bool):
161161

162162
from gaze_mapping import registered_gazer_classes
163163
from gaze_mapping.gazer_base import GazerBase
164+
from pupil_detector_plugins.detector_base_plugin import PupilDetectorPlugin
164165
from fixation_detector import Fixation_Detector
165166
from recorder import Recorder
166167
from display_recent_gaze import Display_Recent_Gaze
@@ -241,6 +242,9 @@ def get_timestamp():
241242
runtime_plugins = import_runtime_plugins(
242243
os.path.join(g_pool.user_dir, "plugins")
243244
)
245+
runtime_plugins = [
246+
p for p in runtime_plugins if not issubclass(p, PupilDetectorPlugin)
247+
]
244248
user_plugins = [
245249
Pupil_Groups,
246250
NetworkApiPlugin,

pupil_src/shared_modules/circle_detector.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ def bench():
702702
sts, img = cap.read()
703703
# img = cv2.imread('/Users/mkassner/Desktop/manual_calibration_marker-01.png')
704704
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
705-
print(len(find_concetric_circles(gray, visual_debug=img)))
705+
print(len(find_concentric_circles(gray, visual_debug=img)))
706706
cv2.imshow("img", img)
707707
cv2.waitKey(1)
708708
# return

pupil_src/shared_modules/gaze_mapping/gazer_3d/gazer_headset.py

+8
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ def _predict_single(self, x):
157157
gaze_3d = self._toWorld(gaze_point)
158158
normal_3d = np.dot(self.rotation_matrix, pupil_normal)
159159

160+
# Check if gaze is in front of camera. If it is not, flip direction.
161+
if gaze_3d[-1] < 0:
162+
gaze_3d *= -1.0
163+
160164
g = {
161165
"eye_center_3d": eye_center.tolist(),
162166
"gaze_normal_3d": normal_3d.tolist(),
@@ -284,6 +288,10 @@ def _predict_single(self, x):
284288
if nearest_intersection_point is None:
285289
return None
286290

291+
# Check if gaze is in front of camera. If it is not, flip direction.
292+
if nearest_intersection_point[-1] < 0:
293+
nearest_intersection_point *= -1.0
294+
287295
g = {
288296
"eye_centers_3d": {0: s0_center.tolist(), 1: s1_center.tolist()},
289297
"gaze_normals_3d": {0: s0_normal.tolist(), 1: s1_normal.tolist()},

pupil_src/shared_modules/pupil_detector_plugins/pye3d_plugin.py

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"""
1111
import logging
1212

13+
import pye3d
1314
from pye3d.detector_3d import Detector3D, CameraModel
1415
from pyglui import ui
1516

@@ -19,6 +20,16 @@
1920

2021
logger = logging.getLogger(__name__)
2122

23+
version_installed = getattr(pye3d, "__version__", "0.0.1")
24+
version_supported = "0.0.1"
25+
26+
if version_installed != version_supported:
27+
logger.info(
28+
f"Requires pye3d version {version_supported} "
29+
f"(Installed: {version_installed})"
30+
)
31+
raise ImportError
32+
2233

2334
class Pye3DPlugin(PupilDetectorPlugin):
2435
uniqueness = "by_class"

pupil_src/shared_modules/pupil_detector_plugins/visualizer_pye3d.py pupil_src/shared_modules/pupil_detector_plugins/visualizer_pye3d/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
from pyglui.cygl.utils import RGBA
3838
from visualizer import Visualizer
3939

40+
from .eye import LeGrandEye
41+
4042

4143
class Eye_Visualizer(Visualizer):
4244
def __init__(self, g_pool, focal_length):

0 commit comments

Comments
 (0)