Skip to content

Commit

Permalink
Merge pull request #2012 from pupil-labs/develop
Browse files Browse the repository at this point in the history
Pupil v2.4 Release Candidate 1
  • Loading branch information
papr authored Sep 15, 2020
2 parents f7353e6 + 6705d98 commit f4aff3e
Show file tree
Hide file tree
Showing 80 changed files with 1,435 additions and 336 deletions.
40 changes: 30 additions & 10 deletions pupil_src/launchables/eye.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def eye(
# helpers/utils
from uvc import get_time_monotonic
from file_methods import Persistent_Dict
from version_utils import VersionFormat
from version_utils import parse_version
from methods import normalize, denormalize, timer
from av_writer import JPEG_Writer, MPEG_Writer, NonMonotonicTimestampError
from ndsi import H264Writer
Expand Down Expand Up @@ -236,9 +236,10 @@ def consume_events_and_render_buffer():
glfw.glfwMakeContextCurrent(main_window)
clear_gl_screen()

glViewport(0, 0, *g_pool.camera_render_size)
for p in g_pool.plugins:
p.gl_display()
if all(c > 0 for c in g_pool.camera_render_size):
glViewport(0, 0, *g_pool.camera_render_size)
for p in g_pool.plugins:
p.gl_display()

glViewport(0, 0, *window_size)
# render graphs
Expand Down Expand Up @@ -289,6 +290,11 @@ def on_resize(window, w, h):
nonlocal window_size
nonlocal content_scale

is_minimized = bool(glfw.glfwGetWindowAttrib(window, glfw.GLFW_ICONIFIED))

if is_minimized:
return

# Always clear buffers on resize to make sure that there are no overlapping
# artifacts from previous frames.
gl_utils.glClear(gl_utils.GL_COLOR_BUFFER_BIT)
Expand Down Expand Up @@ -362,7 +368,7 @@ def on_drop(window, count, paths):
session_settings = Persistent_Dict(
os.path.join(g_pool.user_dir, "user_settings_eye{}".format(eye_id))
)
if VersionFormat(session_settings.get("version", "0.0")) != g_pool.version:
if parse_version(session_settings.get("version", "0.0")) != g_pool.version:
logger.info(
"Session setting are from a different version of this app. I will not use those."
)
Expand Down Expand Up @@ -407,8 +413,15 @@ def toggle_general_settings(collapsed):
width, height = session_settings.get("window_size", default_window_size)

main_window = glfw.glfwCreateWindow(width, height, title, None, None)
window_pos = session_settings.get("window_position", window_position_default)

window_position_manager = gl_utils.WindowPositionManager()
window_pos = window_position_manager.new_window_position(
window=main_window,
default_position=window_position_default,
previous_position=session_settings.get("window_position", None),
)
glfw.glfwSetWindowPos(main_window, window_pos[0], window_pos[1])

glfw.glfwMakeContextCurrent(main_window)
cygl.utils.init()

Expand Down Expand Up @@ -503,6 +516,7 @@ def set_window_size():
toggle_general_settings(True)

g_pool.writer = None
g_pool.rec_path = None

# Register callbacks main_window
glfw.glfwSetFramebufferSizeCallback(main_window, on_resize)
Expand Down Expand Up @@ -567,12 +581,12 @@ def window_should_update():
break
elif subject == "recording.started":
if notification["record_eye"] and g_pool.capture.online:
record_path = notification["rec_path"]
g_pool.rec_path = notification["rec_path"]
raw_mode = notification["compression"]
start_time_synced = notification["start_time_synced"]
logger.info("Will save eye video to: {}".format(record_path))
logger.info(f"Will save eye video to: {g_pool.rec_path}")
video_path = os.path.join(
record_path, "eye{}.mp4".format(eye_id)
g_pool.rec_path, "eye{}.mp4".format(eye_id)
)
if raw_mode and frame and g_pool.capture.jpeg_support:
g_pool.writer = JPEG_Writer(video_path, start_time_synced)
Expand All @@ -592,7 +606,13 @@ def window_should_update():
g_pool.writer.release()
except RuntimeError:
logger.error("No eye video recorded")
g_pool.writer = None
else:
# TODO: wrap recording logic into plugin
g_pool.capture.intrinsics.save(
g_pool.rec_path, custom_name=f"eye{eye_id}"
)
finally:
g_pool.writer = None
elif subject.startswith("meta.should_doc"):
ipc_socket.notify(
{
Expand Down
28 changes: 21 additions & 7 deletions pupil_src/launchables/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def player(
from video_capture import File_Source

# helpers/utils
from version_utils import VersionFormat
from version_utils import parse_version
from methods import normalize, denormalize, delta_t, get_system_info
import player_methods as pm
from pupil_recording import PupilRecording
Expand Down Expand Up @@ -131,7 +131,7 @@ def player(
InvalidRecordingException,
)

assert VersionFormat(pyglui_version) >= VersionFormat(
assert parse_version(pyglui_version) >= parse_version(
"1.28"
), "pyglui out of date, please upgrade to newest version"

Expand Down Expand Up @@ -346,7 +346,7 @@ def get_dt():
session_settings = Persistent_Dict(
os.path.join(user_dir, "user_settings_player")
)
if VersionFormat(session_settings.get("version", "0.0")) != app_version:
if parse_version(session_settings.get("version", "0.0")) != app_version:
logger.info(
"Session setting are a different version of this app. I will not use those."
)
Expand All @@ -356,13 +356,20 @@ def get_dt():
width += icon_bar_width
width, height = session_settings.get("window_size", (width, height))

window_pos = session_settings.get("window_position", window_position_default)
window_name = f"Pupil Player: {meta_info.recording_name} - {rec_dir}"

glfw.glfwInit()
glfw.glfwWindowHint(glfw.GLFW_SCALE_TO_MONITOR, glfw.GLFW_TRUE)
main_window = glfw.glfwCreateWindow(width, height, window_name, None, None)

window_position_manager = gl_utils.WindowPositionManager()
window_pos = window_position_manager.new_window_position(
window=main_window,
default_position=window_position_default,
previous_position=session_settings.get("window_position", None),
)
glfw.glfwSetWindowPos(main_window, window_pos[0], window_pos[1])

glfw.glfwMakeContextCurrent(main_window)
cygl.utils.init()
g_pool.main_window = main_window
Expand Down Expand Up @@ -793,7 +800,7 @@ def player_drop(
import glfw
import gl_utils
from OpenGL.GL import glClearColor
from version_utils import VersionFormat
from version_utils import parse_version
from file_methods import Persistent_Dict
from pyglui.pyfontstash import fontstash
from pyglui.ui import get_roboto_font_path
Expand Down Expand Up @@ -830,13 +837,12 @@ def on_drop(window, count, paths):
session_settings = Persistent_Dict(
os.path.join(user_dir, "user_settings_player")
)
if VersionFormat(session_settings.get("version", "0.0")) != app_version:
if parse_version(session_settings.get("version", "0.0")) != app_version:
logger.info(
"Session setting are from a different version of this app. I will not use those."
)
session_settings.clear()
w, h = session_settings.get("window_size", (1280, 720))
window_pos = session_settings.get("window_position", window_position_default)

glfw.glfwInit()
glfw.glfwWindowHint(glfw.GLFW_SCALE_TO_MONITOR, glfw.GLFW_TRUE)
Expand All @@ -845,7 +851,15 @@ def on_drop(window, count, paths):
glfw.glfwWindowHint(glfw.GLFW_RESIZABLE, 1)

glfw.glfwMakeContextCurrent(window)

window_position_manager = gl_utils.WindowPositionManager()
window_pos = window_position_manager.new_window_position(
window=window,
default_position=window_position_default,
previous_position=session_settings.get("window_position", None),
)
glfw.glfwSetWindowPos(window, window_pos[0], window_pos[1])

glfw.glfwSetDropCallback(window, on_drop)

glfont = fontstash.Context()
Expand Down
4 changes: 2 additions & 2 deletions pupil_src/launchables/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def stop_eye_process(eye_id):
# helpers/utils
from file_methods import Persistent_Dict
from methods import delta_t, get_system_info
from version_utils import VersionFormat
from version_utils import parse_version
import audio
from uvc import get_time_monotonic

Expand Down Expand Up @@ -183,7 +183,7 @@ def get_dt():
session_settings = Persistent_Dict(
os.path.join(g_pool.user_dir, "user_settings_service")
)
if session_settings.get("version", VersionFormat("0.0")) < g_pool.version:
if parse_version(session_settings.get("version", "0.0")) < g_pool.version:
logger.info(
"Session setting are from older version of this app. I will not use those."
)
Expand Down
15 changes: 11 additions & 4 deletions pupil_src/launchables/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def detection_enabled_setter(is_on: bool):

# display
import glfw
from version_utils import VersionFormat
from version_utils import parse_version
from pyglui import ui, cygl, __version__ as pyglui_version

assert VersionFormat(pyglui_version) >= VersionFormat(
assert parse_version(pyglui_version) >= parse_version(
"1.27"
), "pyglui out of date, please upgrade to newest version"
from pyglui.cygl.utils import Named_Texture
Expand Down Expand Up @@ -441,7 +441,7 @@ def get_dt():
session_settings = Persistent_Dict(
os.path.join(g_pool.user_dir, "user_settings_world")
)
if VersionFormat(session_settings.get("version", "0.0")) != g_pool.version:
if parse_version(session_settings.get("version", "0.0")) != g_pool.version:
logger.info(
"Session setting are from a different version of this app. I will not use those."
)
Expand Down Expand Up @@ -514,8 +514,15 @@ def handle_notifications(noti):
if hide_ui:
glfw.glfwWindowHint(glfw.GLFW_VISIBLE, 0) # hide window
main_window = glfw.glfwCreateWindow(width, height, "Pupil Capture - World")
window_pos = session_settings.get("window_position", window_position_default)

window_position_manager = gl_utils.WindowPositionManager()
window_pos = window_position_manager.new_window_position(
window=main_window,
default_position=window_position_default,
previous_position=session_settings.get("window_position", None),
)
glfw.glfwSetWindowPos(main_window, window_pos[0], window_pos[1])

glfw.glfwMakeContextCurrent(main_window)
cygl.utils.init()
g_pool.main_window = main_window
Expand Down
3 changes: 2 additions & 1 deletion pupil_src/shared_modules/accuracy_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def __handle_calibration_result_notification(self, note_dict: dict) -> bool:
return False

self.recent_input.update(
gazer_class_name=note.gazer_class_name, gazer_params=note.params,
gazer_class_name=note.gazer_class_name,
gazer_params=note.params,
)

self.recalculate()
Expand Down
2 changes: 1 addition & 1 deletion pupil_src/shared_modules/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create_annotation(label, timestamp, duration=0.0, **custom_fields):
"""
Returns a dictionary in the format needed to send annotations
to an annotation plugin via the ICP.
See python/remote_annotations.py in pupil-helpers for an example.
:param custom_fields:
Expand Down
3 changes: 1 addition & 2 deletions pupil_src/shared_modules/audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def get_audio_mode():


def set_audio_mode(new_mode):
"""a save way to set the audio mode
"""
"""a save way to set the audio mode"""
if new_mode in get_audio_mode_list():
global _audio_mode
_audio_mode = new_mode
Expand Down
14 changes: 10 additions & 4 deletions pupil_src/shared_modules/audio_playback.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import gl_utils
from audio_utils import Audio_Viz_Transform, NoAudioLoadedError, load_audio
from plugin import System_Plugin_Base
from version_utils import VersionFormat
from version_utils import parse_version


assert VersionFormat(av.__version__) >= VersionFormat("0.4.4")
assert parse_version(av.__version__) >= parse_version("0.4.4")


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -191,7 +191,8 @@ def _setup_filter_graph(self):
self.filter_graph_list[-2].link_to(self.filter_graph_list[-1])
self.filter_graph_list.append(
self.filter_graph.add(
"aresample", "osf={}".format(self.audio.stream.format.packed.name),
"aresample",
"osf={}".format(self.audio.stream.format.packed.name),
)
)
self.filter_graph_list[-2].link_to(self.filter_graph_list[-1])
Expand Down Expand Up @@ -421,7 +422,12 @@ def set_volume(val):

self.menu.append(
ui.Slider(
"req_audio_volume", self, step=0.05, min=0.0, max=1.0, label="Volume",
"req_audio_volume",
self,
step=0.05,
min=0.0,
max=1.0,
label="Volume",
)
)
self.menu.append(
Expand Down
6 changes: 3 additions & 3 deletions pupil_src/shared_modules/batch_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

def get_recording_dirs(data_dir):
"""
You can supply a data folder or any folder
- all folders within will be checked for necessary files
- in order to make a visualization
You can supply a data folder or any folder
- all folders within will be checked for necessary files
- in order to make a visualization
"""
if is_pupil_rec_dir(data_dir):
yield data_dir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ def ref_list(self, value):
def on_choreography_started(self, mode: ChoreographyMode):
self.notify_all(
ChoreographyNotification(
mode=mode, action=ChoreographyAction.STARTED,
mode=mode,
action=ChoreographyAction.STARTED,
).to_dict()
)

Expand Down Expand Up @@ -452,8 +453,7 @@ def update_ui(self):
)

def deinit_ui(self):
"""Gets called when the plugin get terminated, either voluntarily or forced.
"""
"""Gets called when the plugin get terminated, either voluntarily or forced."""
if self.is_active:
self._perform_stop()
self.remove_menu()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

class NaturalFeatureChoreographyPlugin(CalibrationChoreographyPlugin):
"""Calibrate using natural features in a scene.
Features are selected by a user by clicking on
Features are selected by a user by clicking on
"""

label = "Natural Feature Calibration"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def recent_events(self, events):
if isinstance(state, MarkerWindowStateIdle):
assert self.__currently_shown_marker_position is None # Sanity check
if self.__current_list_of_markers_to_show:
self.__currently_shown_marker_position = self.__current_list_of_markers_to_show.pop(
0
self.__currently_shown_marker_position = (
self.__current_list_of_markers_to_show.pop(0)
)
logger.debug(
f"Moving screen marker to site at {self.__currently_shown_marker_position}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class SingleMarkerChoreographyPlugin(
MonitorSelectionMixin, CalibrationChoreographyPlugin
):
"""Calibrate using a single marker.
Move your head for example in a spiral motion while gazing
at the marker to quickly sample a wide range gaze angles.
Move your head for example in a spiral motion while gazing
at the marker to quickly sample a wide range gaze angles.
"""

label = "Single Marker Calibration"
Expand Down
Loading

0 comments on commit f4aff3e

Please sign in to comment.