Skip to content

Commit

Permalink
Merge pull request #2072 from pupil-labs/develop
Browse files Browse the repository at this point in the history
Pupil v3.0 Release Candidate 1
  • Loading branch information
papr authored Dec 10, 2020
2 parents af660c3 + b92e24f commit a18e63f
Show file tree
Hide file tree
Showing 27 changed files with 694 additions and 972 deletions.
8 changes: 6 additions & 2 deletions deployment/deploy_capture/bundle.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sys

import numpy
import pkg_resources
from PyInstaller.utils.hooks import collect_submodules
from PyInstaller.utils.hooks import collect_submodules, collect_data_files

hidden_imports = []
hidden_imports += collect_submodules("av")
Expand Down Expand Up @@ -40,6 +40,8 @@ if not glfw_path.exists():
glfw_path = pathlib.Path(pkg_resources.resource_filename("glfw", glfw_name))
glfw_binaries = [(glfw_path.name, str(glfw_path), "BINARY")]

data_files_pye3d = collect_data_files("pye3d")

if platform.system() == "Darwin":
sys.path.append(".")
from version import pupil_version
Expand All @@ -52,6 +54,7 @@ if platform.system() == "Darwin":
hookspath=None,
runtime_hooks=None,
excludes=["matplotlib"],
datas=data_files_pye3d,
)
pyz = PYZ(a.pure)
exe = EXE(
Expand Down Expand Up @@ -104,6 +107,7 @@ elif platform.system() == "Linux":
hookspath=None,
runtime_hooks=None,
excludes=["matplotlib"],
datas=data_files_pye3d,
)

pyz = PYZ(a.pure)
Expand Down Expand Up @@ -172,7 +176,7 @@ elif platform.system() == "Windows":
["../../pupil_src/main.py"],
pathex=["../../pupil_src/shared_modules/", str(external_libs_path)],
binaries=None,
datas=None,
datas=data_files_pye3d,
hiddenimports=hidden_imports,
hookspath=None,
runtime_hooks=None,
Expand Down
7 changes: 6 additions & 1 deletion deployment/deploy_player/bundle.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sys

import numpy
import pkg_resources
from PyInstaller.utils.hooks import collect_submodules
from PyInstaller.utils.hooks import collect_submodules, collect_data_files

hidden_imports = []
hidden_imports += collect_submodules("av")
Expand Down Expand Up @@ -40,6 +40,8 @@ if not glfw_path.exists():
glfw_path = pathlib.Path(pkg_resources.resource_filename("glfw", glfw_name))
glfw_binaries = [(glfw_path.name, str(glfw_path), "BINARY")]

data_files_pye3d = collect_data_files("pye3d")

if platform.system() == "Darwin":
sys.path.append(".")
from version import pupil_version
Expand All @@ -53,6 +55,7 @@ if platform.system() == "Darwin":
hookspath=None,
runtime_hooks=None,
excludes=["matplotlib"],
datas=data_files_pye3d,
)

pyz = PYZ(a.pure)
Expand Down Expand Up @@ -106,6 +109,7 @@ elif platform.system() == "Linux":
hookspath=None,
runtime_hooks=None,
excludes=["matplotlib"],
datas=data_files_pye3d,
)

pyz = PYZ(a.pure)
Expand Down Expand Up @@ -177,6 +181,7 @@ elif platform.system() == "Windows":
hookspath=None,
runtime_hooks=None,
excludes=["matplotlib"],
datas=data_files_pye3d,
)

pyz = PYZ(a.pure)
Expand Down
8 changes: 6 additions & 2 deletions deployment/deploy_service/bundle.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sys

import numpy
import pkg_resources
from PyInstaller.utils.hooks import collect_submodules
from PyInstaller.utils.hooks import collect_submodules, collect_data_files

hidden_imports = []
hidden_imports += collect_submodules("av")
Expand All @@ -30,6 +30,8 @@ if not glfw_path.exists():
glfw_path = pathlib.Path(pkg_resources.resource_filename("glfw", glfw_name))
glfw_binaries = [(glfw_path.name, str(glfw_path), "BINARY")]

data_files_pye3d = collect_data_files("pye3d")

if platform.system() == "Darwin":
sys.path.append(".")
from version import pupil_version
Expand All @@ -43,6 +45,7 @@ if platform.system() == "Darwin":
hookspath=None,
runtime_hooks=None,
excludes=["matplotlib"],
datas=data_files_pye3d,
)
pyz = PYZ(a.pure)
exe = EXE(
Expand Down Expand Up @@ -89,6 +92,7 @@ elif platform.system() == "Linux":
hookspath=None,
runtime_hooks=None,
excludes=["matplotlib"],
datas=data_files_pye3d,
)

pyz = PYZ(a.pure)
Expand Down Expand Up @@ -151,7 +155,7 @@ elif platform.system() == "Windows":
["../../pupil_src/main.py"],
pathex=["../../pupil_src/shared_modules/", str(external_libs_path)],
binaries=None,
datas=None,
datas=data_files_pye3d,
hiddenimports=hidden_imports,
hookspath=None,
runtime_hooks=None,
Expand Down
2 changes: 0 additions & 2 deletions docs/dependencies-macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ brew install portaudio
# tbb is included by default with https://github.com/Homebrew/homebrew-core/pull/20101
brew install opencv
brew install glew
# dependencies for 2d_3d c++ detector
brew install ceres-solver
```

## libuvc
Expand Down
30 changes: 1 addition & 29 deletions docs/dependencies-ubuntu17.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,35 +119,7 @@ sudo udevadm trigger

## 3D Eye Model Dependencies
```sh
sudo apt install -y libgoogle-glog-dev libatlas-base-dev libeigen3-dev
```

## Ceres

You will need to build Ceres from source:
```sh
sudo add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687
sudo apt-get update
sudo apt-get install libsuitesparse-dev
```

If `add-apt-repository` is not found, install the following package first:
```sh
sudo apt-get install software-properties-common
```

The build and install the Ceres solver:
```sh
git clone https://ceres-solver.googlesource.com/ceres-solver
cd ceres-solver
git checkout 1.14.0
mkdir build && cd build
cmake .. -DBUILD_SHARED_LIBS=ON
make -j3
make test
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/ceres.conf'
sudo ldconfig
sudo apt install -y libeigen3-dev
```

### Install Python Libraries
Expand Down
8 changes: 2 additions & 6 deletions docs/dependencies-ubuntu18.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ sudo apt install -y pkg-config git cmake build-essential nasm wget python3-setup
# ffmpeg >= 3.2
sudo apt install -y libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev libavresample-dev ffmpeg x264 x265 libportaudio2 portaudio19-dev

# OpenCV >= 3
sudo apt install -y python3-opencv libopencv-dev

# 3D Eye model dependencies
sudo apt install -y libgoogle-glog-dev libatlas-base-dev libeigen3-dev
sudo apt install -y libceres-dev
# OpenCV >= 3 + Eigen
sudo apt install -y python3-opencv libopencv-dev libeigen3-dev
```

## Turbojpeg
Expand Down
38 changes: 27 additions & 11 deletions pupil_src/launchables/eye.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def eye(
hide_ui=False,
debug=False,
pub_socket_hwm=None,
parent_application="capture",
):
"""reads eye video and detects the pupil.
Expand Down Expand Up @@ -190,7 +191,7 @@ def interrupt_handler(sig, frame):
g_pool.debug = debug
g_pool.user_dir = user_dir
g_pool.version = version
g_pool.app = "capture"
g_pool.app = parent_application
g_pool.eye_id = eye_id
g_pool.process = f"eye{eye_id}"
g_pool.timebase = timebase
Expand Down Expand Up @@ -223,7 +224,7 @@ def load_runtime_pupil_detection_plugins():
continue
yield plugin

default_2d, default_3d, available_detectors = available_detector_plugins()
available_detectors = available_detector_plugins()
runtime_detectors = list(load_runtime_pupil_detection_plugins())
plugins = (
manager_classes
Expand Down Expand Up @@ -253,13 +254,10 @@ def load_runtime_pupil_detection_plugins():
# TODO: extend with plugins
(default_capture_name, default_capture_settings),
("UVC_Manager", {}),
# Detectors needs to be loaded first to set `g_pool.pupil_detector`
(default_2d.__name__, {}),
(default_3d.__name__, {}),
*[(p.__name__, {}) for p in available_detectors],
("NDSI_Manager", {}),
("HMD_Streaming_Manager", {}),
("File_Manager", {}),
("PupilDetectorManager", {}),
("Roi", {}),
]

Expand Down Expand Up @@ -814,10 +812,10 @@ def window_should_update():
plugin.alive = False
g_pool.plugins.clean()

glfw.destroy_window(main_window)
g_pool.gui.terminate()
glfw.terminate()
logger.info("Process shutting down.")
glfw.destroy_window(main_window)
g_pool.gui.terminate()
glfw.terminate()
logger.info("Process shutting down.")


def eye_profiled(
Expand All @@ -833,14 +831,31 @@ def eye_profiled(
hide_ui=False,
debug=False,
pub_socket_hwm=None,
parent_application="capture",
):
import cProfile
import subprocess
import os
from .eye import eye

cProfile.runctx(
"eye(timebase, is_alive_flag,ipc_pub_url,ipc_sub_url,ipc_push_url, user_dir, version, eye_id, overwrite_cap_settings, hide_ui, debug)",
(
"eye("
"timebase, "
"is_alive_flag, "
"ipc_pub_url, "
"ipc_sub_url, "
"ipc_push_url, "
"user_dir, "
"version, "
"eye_id, "
"overwrite_cap_settings, "
"hide_ui, "
"debug, "
"pub_socket_hwm, "
"parent_application, "
")"
),
{
"timebase": timebase,
"is_alive_flag": is_alive_flag,
Expand All @@ -854,6 +869,7 @@ def eye_profiled(
"hide_ui": hide_ui,
"debug": debug,
"pub_socket_hwm": pub_socket_hwm,
"parent_application": parent_application,
},
locals(),
"eye{}.pstats".format(eye_id),
Expand Down
3 changes: 3 additions & 0 deletions pupil_src/launchables/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def world(
Reacts to notifications:
``eye_process.started``
``start_plugin``
``should_stop``
Emits notifications:
``eye_process.should_start``
Expand Down Expand Up @@ -516,6 +517,8 @@ def handle_notifications(noti):
)
elif subject == "world_process.adapt_window_size":
set_window_size()
elif subject == "world_process.should_stop":
glfw.set_window_should_close(main_window, True)

width, height = session_settings.get(
"window_size", (1280 + icon_bar_width, 720)
Expand Down
9 changes: 9 additions & 0 deletions pupil_src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def log_loop(ipc_sub_url, log_level_debug):
parsed_args.hide_ui,
parsed_args.debug,
n.get("pub_socket_hwm"),
parsed_args.app, # parent_application
),
).start()
elif "notify.player_process.should_start" in topic:
Expand Down Expand Up @@ -392,6 +393,14 @@ def log_loop(ipc_sub_url, log_level_debug):
"doc": launcher.__doc__,
}
)
elif "notify.launcher_process.should_stop" in topic:
if parsed_args.app == "capture":
cmd_push.notify({"subject": "world_process.should_stop"})
elif parsed_args.app == "service":
cmd_push.notify({"subject": "service_process.should_stop"})
elif parsed_args.app == "player":
cmd_push.notify({"subject": "player_process.should_stop"})

else:
if not active_children():
break
Expand Down
3 changes: 0 additions & 3 deletions pupil_src/shared_modules/blink_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ def recent_events(self, events={}):
blink_type = "offset"

confidence = min(abs(filter_response), 1.0) # clamp conf. value at 1.
logger.debug(
"Blink {} detected with confidence {:0.3f}".format(blink_type, confidence)
)
# Add info to events
blink_entry = {
"topic": "blinks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ def close(self):
@contextlib.contextmanager
def drawing_context(self):
if self.__gl_handle is None:
yield None
return

if glfw.window_should_close(self.__gl_handle):
self.close()
yield None
return

with self._switch_to_current_context():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,11 @@ def draw_window(self):
return

with self.__window.drawing_context() as gl_context:
self.__draw_circle_marker(
position=marker_position, is_valid=is_valid, alpha=marker_alpha
)
self.__draw_status_text(clicks_needed=clicks_needed)
if gl_context:
self.__draw_circle_marker(
position=marker_position, is_valid=is_valid, alpha=marker_alpha
)
self.__draw_status_text(clicks_needed=clicks_needed)

else:
raise UnhandledMarkerWindowStateError(self.__state)
Expand Down
Loading

0 comments on commit a18e63f

Please sign in to comment.