本文整理汇总了Python中types.SimpleNamespace.zmq_ctx方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleNamespace.zmq_ctx方法的具体用法?Python SimpleNamespace.zmq_ctx怎么用?Python SimpleNamespace.zmq_ctx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类types.SimpleNamespace
的用法示例。
在下文中一共展示了SimpleNamespace.zmq_ctx方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: service
# 需要导入模块: from types import SimpleNamespace [as 别名]
# 或者: from types.SimpleNamespace import zmq_ctx [as 别名]
def service(
timebase,
eye_procs_alive,
ipc_pub_url,
ipc_sub_url,
ipc_push_url,
user_dir,
version,
preferred_remote_port,
):
"""Maps pupil to gaze data, can run various plug-ins.
Reacts to notifications:
``set_detection_mapping_mode``: Sets detection method
``start_plugin``: Starts given plugin with the given arguments
``eye_process.started``: Sets the detection method eye process
``service_process.should_stop``: Stops the service process
Emits notifications:
``eye_process.should_start``
``eye_process.should_stop``
``set_detection_mapping_mode``
``service_process.started``
``service_process.stopped``
``launcher_process.should_stop``
Emits data:
``gaze``: Gaze data from current gaze mapping plugin.``
``*``: any other plugin generated data in the events that it not [dt,pupil,gaze].
"""
# We defer the imports because of multiprocessing.
# Otherwise the service process each process also loads the other imports.
# This is not harmful but unnecessary.
# general imports
from time import sleep
import logging
import zmq
import zmq_tools
# zmq ipc setup
zmq_ctx = zmq.Context()
ipc_pub = zmq_tools.Msg_Dispatcher(zmq_ctx, ipc_push_url)
gaze_pub = zmq_tools.Msg_Streamer(zmq_ctx, ipc_pub_url)
pupil_sub = zmq_tools.Msg_Receiver(zmq_ctx, ipc_sub_url, topics=("pupil",))
notify_sub = zmq_tools.Msg_Receiver(zmq_ctx, ipc_sub_url, topics=("notify",))
poller = zmq.Poller()
poller.register(pupil_sub.socket)
poller.register(notify_sub.socket)
# log setup
logging.getLogger("OpenGL").setLevel(logging.ERROR)
logger = logging.getLogger()
logger.handlers = []
logger.addHandler(zmq_tools.ZMQ_handler(zmq_ctx, ipc_push_url))
# create logger for the context of this function
logger = logging.getLogger(__name__)
def launch_eye_process(eye_id, delay=0):
n = {"subject": "eye_process.should_start", "eye_id": eye_id, "delay": delay}
ipc_pub.notify(n)
def stop_eye_process(eye_id):
n = {"subject": "eye_process.should_stop", "eye_id": eye_id}
ipc_pub.notify(n)
try:
# helpers/utils
from file_methods import Persistent_Dict
from methods import delta_t, get_system_info
from version_utils import VersionFormat
import audio
from uvc import get_time_monotonic
# trigger pupil detector cpp build:
import pupil_detectors
del pupil_detectors
# Plug-ins
from plugin import Plugin, Plugin_List, import_runtime_plugins
from calibration_routines import calibration_plugins, gaze_mapping_plugins
from pupil_remote import Pupil_Remote
from pupil_groups import Pupil_Groups
from frame_publisher import Frame_Publisher
from blink_detection import Blink_Detection
from service_ui import Service_UI
from background_helper import IPC_Logging_Task_Proxy
IPC_Logging_Task_Proxy.push_url = ipc_push_url
logger.info("Application Version: {}".format(version))
logger.info("System Info: {}".format(get_system_info()))
# g_pool holds variables for this process they are accesible to all plugins
g_pool = SimpleNamespace()
g_pool.app = "service"
#.........这里部分代码省略.........
示例2: player
# 需要导入模块: from types import SimpleNamespace [as 别名]
# 或者: from types.SimpleNamespace import zmq_ctx [as 别名]
def player(rec_dir, ipc_pub_url, ipc_sub_url, ipc_push_url, user_dir, app_version):
# general imports
from time import sleep
import logging
from glob import glob
from time import time, strftime, localtime
# networking
import zmq
import zmq_tools
import numpy as np
# zmq ipc setup
zmq_ctx = zmq.Context()
ipc_pub = zmq_tools.Msg_Dispatcher(zmq_ctx, ipc_push_url)
notify_sub = zmq_tools.Msg_Receiver(zmq_ctx, ipc_sub_url, topics=("notify",))
# log setup
logging.getLogger("OpenGL").setLevel(logging.ERROR)
logger = logging.getLogger()
logger.handlers = []
logger.setLevel(logging.NOTSET)
logger.addHandler(zmq_tools.ZMQ_handler(zmq_ctx, ipc_push_url))
# create logger for the context of this function
logger = logging.getLogger(__name__)
try:
from background_helper import IPC_Logging_Task_Proxy
IPC_Logging_Task_Proxy.push_url = ipc_push_url
from tasklib.background.patches import IPCLoggingPatch
IPCLoggingPatch.ipc_push_url = ipc_push_url
# imports
from file_methods import Persistent_Dict, next_export_sub_dir
# display
import glfw
# check versions for our own depedencies as they are fast-changing
from pyglui import __version__ as pyglui_version
from pyglui import ui, cygl
from pyglui.cygl.utils import Named_Texture, RGBA
import gl_utils
# capture
from video_capture import File_Source
# helpers/utils
from version_utils import VersionFormat
from methods import normalize, denormalize, delta_t, get_system_info
import player_methods as pm
from csv_utils import write_key_value_file
# Plug-ins
from plugin import Plugin, Plugin_List, import_runtime_plugins
from plugin_manager import Plugin_Manager
from vis_circle import Vis_Circle
from vis_cross import Vis_Cross
from vis_polyline import Vis_Polyline
from vis_light_points import Vis_Light_Points
from vis_watermark import Vis_Watermark
from vis_fixation import Vis_Fixation
# from vis_scan_path import Vis_Scan_Path
from seek_control import Seek_Control
from surface_tracker import Surface_Tracker_Offline
# from marker_auto_trim_marks import Marker_Auto_Trim_Marks
from fixation_detector import Offline_Fixation_Detector
from eye_movement import Offline_Eye_Movement_Detector
from log_display import Log_Display
from annotations import Annotation_Player
from raw_data_exporter import Raw_Data_Exporter
from log_history import Log_History
from pupil_producers import Pupil_From_Recording, Offline_Pupil_Detection
from gaze_producer.gaze_from_recording import GazeFromRecording
from gaze_producer.gaze_from_offline_calibration import (
GazeFromOfflineCalibration,
)
from system_graphs import System_Graphs
from system_timelines import System_Timelines
from blink_detection import Offline_Blink_Detection
from audio_playback import Audio_Playback
from video_export.plugins.imotions_exporter import iMotions_Exporter
from video_export.plugins.eye_video_exporter import Eye_Video_Exporter
from video_export.plugins.world_video_exporter import World_Video_Exporter
from video_capture import File_Source
from video_overlay.plugins import Video_Overlay, Eye_Overlay
assert VersionFormat(pyglui_version) >= VersionFormat(
"1.23"
), "pyglui out of date, please upgrade to newest version"
runtime_plugins = import_runtime_plugins(os.path.join(user_dir, "plugins"))
system_plugins = [
#.........这里部分代码省略.........
示例3: world
# 需要导入模块: from types import SimpleNamespace [as 别名]
# 或者: from types.SimpleNamespace import zmq_ctx [as 别名]
def world(
timebase,
eye_procs_alive,
ipc_pub_url,
ipc_sub_url,
ipc_push_url,
user_dir,
version,
preferred_remote_port,
):
"""Reads world video and runs plugins.
Creates a window, gl context.
Grabs images from a capture.
Maps pupil to gaze data
Can run various plug-ins.
Reacts to notifications:
``set_detection_mapping_mode``
``eye_process.started``
``start_plugin``
Emits notifications:
``eye_process.should_start``
``eye_process.should_stop``
``set_detection_mapping_mode``
``world_process.started``
``world_process.stopped``
``recording.should_stop``: Emits on camera failure
``launcher_process.should_stop``
Emits data:
``gaze``: Gaze data from current gaze mapping plugin.``
``*``: any other plugin generated data in the events
that it not [dt,pupil,gaze].
"""
# We defer the imports because of multiprocessing.
# Otherwise the world process each process also loads the other imports.
# This is not harmful but unnecessary.
# general imports
from time import sleep
import logging
# networking
import zmq
import zmq_tools
# zmq ipc setup
zmq_ctx = zmq.Context()
ipc_pub = zmq_tools.Msg_Dispatcher(zmq_ctx, ipc_push_url)
notify_sub = zmq_tools.Msg_Receiver(zmq_ctx, ipc_sub_url, topics=("notify",))
# log setup
logging.getLogger("OpenGL").setLevel(logging.ERROR)
logger = logging.getLogger()
logger.handlers = []
logger.setLevel(logging.NOTSET)
logger.addHandler(zmq_tools.ZMQ_handler(zmq_ctx, ipc_push_url))
# create logger for the context of this function
logger = logging.getLogger(__name__)
def launch_eye_process(eye_id, delay=0):
n = {
"subject": "eye_process.should_start.{}".format(eye_id),
"eye_id": eye_id,
"delay": delay,
}
ipc_pub.notify(n)
def stop_eye_process(eye_id):
n = {
"subject": "eye_process.should_stop.{}".format(eye_id),
"eye_id": eye_id,
"delay": 0.2,
}
ipc_pub.notify(n)
def start_stop_eye(eye_id, make_alive):
if make_alive:
launch_eye_process(eye_id)
else:
stop_eye_process(eye_id)
def set_detection_mapping_mode(new_mode):
n = {"subject": "set_detection_mapping_mode", "mode": new_mode}
ipc_pub.notify(n)
try:
from background_helper import IPC_Logging_Task_Proxy
IPC_Logging_Task_Proxy.push_url = ipc_push_url
from tasklib.background.patches import IPCLoggingPatch
IPCLoggingPatch.ipc_push_url = ipc_push_url
# display
import glfw
#.........这里部分代码省略.........