Skip to content

pupil labs code

Leon Cheung edited this page Mar 9, 2017 · 13 revisions

pupil labs code

good guide to zmq http://zguide.zeromq.org/page:all#Getting-the-Message-Out

IPC urls

print(ipc_pub_url)                                                          
print(ipc_sub_url)                                                          
print(ipc_push_url)                                                         


tcp://127.0.0.1:39545
tcp://127.0.0.1:40711
tcp://127.0.0.1:35291

These IPC urls are created from zmq.Context()

main() publishes on ipc_sub_url, subscribes on ipc_pub_url, and pulls on ipc_push_url. Therefore their naming convention is from the perspective of the client processes (the publishers), not the server (the intermediary). Therefore we should subscribe to ipc_pub_url, and pull from ipc_push_url.

eye.py

reference https://github.com/pupil-labs/pupil/blob/master/pupil_src/capture/eye.py#L44

comments

pupil_socket = zmq_tools.Msg_Streamer(zmq_ctx, ipc_pub_url)

 """reads eye video and detects the pupil.
    Creates a window, gl context.
    Grabs images from a capture.
    Streams Pupil coordinates.
    Reacts to notifications:
       ``set_detection_mapping_mode``: Sets detection method
       ``eye_process.should_stop``: Stops the eye process
       ``recording.started``: Starts recording eye video
       ``recording.stopped``: Stops recording eye video
       ``frame_publishing.started``: Starts frame publishing
       ``frame_publishing.stopped``: Stops frame publishing
    Emits notifications:
        ``eye_process.started``: Eye process started
        ``eye_process.stopped``: Eye process stopped
    Emits data:
        ``pupil.<eye id>``: Pupil data for eye with id ``<eye id>``
        ``frame.eye.<eye id>``: Eye frames with id ``<eye id>``
    """

notifications

emitted with self.ipc_socket.notify({'subject': 'eye_process.started', 'eye_id': self.eye_id}) self.ipc_socket comes from ipc_socket = zmq_tools.Msg_Dispatcher(zmq_ctx, ipc_push_url)

data

emitted with

pupil_socket.send('frame.eye.%s'%eye_id,{
                        'width': frame.width,
                        'height': frame.width,
                        'index': frame.index,
                        'timestamp': frame.timestamp,
                        'format': frame_publish_format,
                        '__raw_data__': [data]
})

where it comes from pupil_socket = zmq_tools.Msg_Streamer(zmq_ctx, ipc_pub_url)

Clone this wiki locally