# appliedperceptionlab/marin architecture

> Architecture diagram of the GitHub repository appliedperceptionlab/marin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/appliedperceptionlab/marin
- Repository: https://github.com/appliedperceptionlab/marin
- Video tour (about a minute): https://gitdiagram.com/appliedperceptionlab/marin/video

## Overview

MARIN is a mobile augmented-reality neuronavigation application: it captures camera video, exchanges video and interaction commands with a neuronavigation platform over OpenIGTLink, and presents AR guidance on the mobile device. The sampled entry point wires camera frames, UI commands, and networking threads; the README documents Ibis use and portability to other platforms. Several runtime files are represented by their exact paths from the tree, but their internals were not sampled, so uncertain implementation links are omitted.

Main entry points: [`src/main.cpp`](https://github.com/appliedperceptionlab/marin/blob/main/src/main.cpp) (App startup), [`src/threadshandler.cpp`](https://github.com/appliedperceptionlab/marin/blob/main/src/threadshandler.cpp) (Thread coordinator), [`src/qmlmainwindow.cpp`](https://github.com/appliedperceptionlab/marin/blob/main/src/qmlmainwindow.cpp) (AR interface), [`src/receiver.cpp`](https://github.com/appliedperceptionlab/marin/blob/main/src/receiver.cpp) (Data receiver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and interaction"]
  node_entry["App startup<br/>[main.cpp]"]
  node_qml["AR interface<br/>[qmlmainwindow.cpp]"]
  node_graphics["Graphics view<br/>[glwidget.cpp]"]
  node_gestures["Gesture handling<br/>[gesturehandler.cpp]"]
end

subgraph group_capture["Camera and video"]
  node_camera["Camera control<br/>[camera.cpp]"]
  node_grabber["Frame capture"]
  node_video_sender["Video sender<br/>[sendervideo.cpp]"]
end

subgraph group_network["Network exchange"]
  node_command_sender["Command sender<br/>[sendercommand.cpp]"]
  node_sender["Sender base<br/>[sender.cpp]"]
  node_receiver["Data receiver<br/>[receiver.cpp]"]
  node_threads["Thread coordinator<br/>[threadshandler.cpp]"]
  node_send_thread["Send worker"]
  node_video_thread["Video receive worker"]
  node_command_thread["Command receive worker"]
  node_commands["Command model<br/>[sendercommand.cpp]"]
end

subgraph group_protocol["OpenIGTLink"]
  node_igtl["OpenIGTLink messages and sockets<br/>[igtlMessageBase.h]"]
  node_video_messages["Video messages and codecs<br/>[igtlVideoMessage.h]"]
  node_session["Session management"]
end

node_user(("Mobile user"))
node_nav["Neuronavigation platform"]

node_user -->|"uses"| node_qml
node_entry -->|"creates"| node_camera
node_entry -->|"creates"| node_grabber
node_entry -->|"creates"| node_receiver
node_entry -->|"creates"| node_qml
node_entry -->|"creates"| node_video_sender
node_entry -->|"creates"| node_command_sender
node_entry -->|"starts"| node_threads
node_camera -->|"provides frames"| node_grabber
node_grabber -->|"copies frames"| node_video_sender
node_entry -->|"configures workers"| node_threads
node_threads -->|"starts"| node_send_thread
node_threads -->|"configures receiver"| node_video_thread
node_threads -->|"configures receiver"| node_command_thread
node_threads -->|"sets receiver"| node_receiver
node_threads -->|"updates host"| node_video_sender
node_threads -->|"updates host"| node_receiver
node_qml -->|"emits commands"| node_command_sender
node_qml -->|"freezes camera"| node_camera
node_qml -.->|"handles input"| node_gestures
node_qml -.->|"renders view"| node_graphics
node_video_sender -->|"sent by"| node_send_thread
node_command_sender -->|"sent by"| node_send_thread
node_video_sender -.->|"encodes video"| node_video_messages
node_video_sender -->|"sends video"| node_nav
node_command_sender -->|"sends commands"| node_nav
node_nav -->|"sends data"| node_receiver
node_receiver -.->|"video input"| node_video_thread
node_receiver -.->|"command input"| node_command_thread
node_video_thread -.->|"delivers video"| node_qml
node_command_thread -.->|"delivers data"| node_qml
node_sender -.->|"uses protocol"| node_igtl
node_receiver -.->|"uses protocol"| node_igtl
node_igtl -.->|"manages sessions"| node_session

click node_entry "https://github.com/appliedperceptionlab/marin/blob/main/src/main.cpp"
click node_qml "https://github.com/appliedperceptionlab/marin/blob/main/src/qmlmainwindow.cpp"
click node_graphics "https://github.com/appliedperceptionlab/marin/blob/main/src/glwidget.cpp"
click node_gestures "https://github.com/appliedperceptionlab/marin/blob/main/src/gesturehandler.cpp"
click node_camera "https://github.com/appliedperceptionlab/marin/blob/main/src/camera.cpp"
click node_grabber "https://github.com/appliedperceptionlab/marin/blob/main/src/videoFrameGrabber.cpp"
click node_video_sender "https://github.com/appliedperceptionlab/marin/blob/main/src/sendervideo.cpp"
click node_command_sender "https://github.com/appliedperceptionlab/marin/blob/main/src/sendercommand.cpp"
click node_sender "https://github.com/appliedperceptionlab/marin/blob/main/src/sender.cpp"
click node_receiver "https://github.com/appliedperceptionlab/marin/blob/main/src/receiver.cpp"
click node_threads "https://github.com/appliedperceptionlab/marin/blob/main/src/threadshandler.cpp"
click node_send_thread "https://github.com/appliedperceptionlab/marin/blob/main/src/openigtlsendthread.cpp"
click node_video_thread "https://github.com/appliedperceptionlab/marin/blob/main/src/videoreceivethread.cpp"
click node_command_thread "https://github.com/appliedperceptionlab/marin/blob/main/src/commandsreceivethread.cpp"
click node_commands "https://github.com/appliedperceptionlab/marin/blob/main/src/sendercommand.cpp"
click node_igtl "https://github.com/appliedperceptionlab/marin/blob/main/includes/OpenIGTLink/igtlMessageBase.h"
click node_video_messages "https://github.com/appliedperceptionlab/marin/blob/main/includes/OpenIGTLink/VideoStreaming/igtlVideoMessage.h"
click node_session "https://github.com/appliedperceptionlab/marin/blob/main/includes/OpenIGTLink/igtlSessionManager.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_qml,node_graphics,node_gestures,node_user toneBlue
class node_camera,node_grabber,node_video_sender toneAmber
class node_command_sender,node_sender,node_receiver,node_threads,node_send_thread,node_video_thread,node_command_thread,node_commands toneMint
class node_igtl,node_video_messages,node_session toneRose
class node_nav toneIndigo
```

## Components

### App and interaction

- [App startup](https://github.com/appliedperceptionlab/marin/blob/main/src/main.cpp): `src/main.cpp`
- [AR interface](https://github.com/appliedperceptionlab/marin/blob/main/src/qmlmainwindow.cpp): `src/qmlmainwindow.cpp`
- [Graphics view](https://github.com/appliedperceptionlab/marin/blob/main/src/glwidget.cpp): `src/glwidget.cpp`
- [Gesture handling](https://github.com/appliedperceptionlab/marin/blob/main/src/gesturehandler.cpp): `src/gesturehandler.cpp`

### Camera and video

- [Camera control](https://github.com/appliedperceptionlab/marin/blob/main/src/camera.cpp): `src/camera.cpp`
- [Frame capture](https://github.com/appliedperceptionlab/marin/blob/main/src/videoFrameGrabber.cpp): `src/videoFrameGrabber.cpp`
- [Video sender](https://github.com/appliedperceptionlab/marin/blob/main/src/sendervideo.cpp): `src/sendervideo.cpp`

### Network exchange

- [Command sender](https://github.com/appliedperceptionlab/marin/blob/main/src/sendercommand.cpp): `src/sendercommand.cpp`
- [Sender base](https://github.com/appliedperceptionlab/marin/blob/main/src/sender.cpp): `src/sender.cpp`
- [Data receiver](https://github.com/appliedperceptionlab/marin/blob/main/src/receiver.cpp): `src/receiver.cpp`
- [Thread coordinator](https://github.com/appliedperceptionlab/marin/blob/main/src/threadshandler.cpp): `src/threadshandler.cpp`
- [Send worker](https://github.com/appliedperceptionlab/marin/blob/main/src/openigtlsendthread.cpp): `src/openigtlsendthread.cpp`
- [Video receive worker](https://github.com/appliedperceptionlab/marin/blob/main/src/videoreceivethread.cpp): `src/videoreceivethread.cpp`
- [Command receive worker](https://github.com/appliedperceptionlab/marin/blob/main/src/commandsreceivethread.cpp): `src/commandsreceivethread.cpp`
- [Command model](https://github.com/appliedperceptionlab/marin/blob/main/src/sendercommand.cpp): `src/sendercommand.cpp`

### OpenIGTLink

- [OpenIGTLink messages and sockets](https://github.com/appliedperceptionlab/marin/blob/main/includes/OpenIGTLink/igtlMessageBase.h): `includes/OpenIGTLink/igtlMessageBase.h`
- [Video messages and codecs](https://github.com/appliedperceptionlab/marin/blob/main/includes/OpenIGTLink/VideoStreaming/igtlVideoMessage.h): `includes/OpenIGTLink/VideoStreaming/igtlVideoMessage.h`
- [Session management](https://github.com/appliedperceptionlab/marin/blob/main/includes/OpenIGTLink/igtlSessionManager.h): `includes/OpenIGTLink/igtlSessionManager.h`

### Other components

- **Mobile user**
- **Neuronavigation platform**

## Connections

- Mobile user → AR interface: uses
- App startup → Camera control: creates
- App startup → Frame capture: creates
- App startup → Data receiver: creates
- App startup → AR interface: creates
- App startup → Video sender: creates
- App startup → Command sender: creates
- App startup → Thread coordinator: starts
- Camera control → Frame capture: provides frames
- Frame capture → Video sender: copies frames
- App startup → Thread coordinator: configures workers
- Thread coordinator → Send worker: starts
- Thread coordinator → Video receive worker: configures receiver
- Thread coordinator → Command receive worker: configures receiver
- Thread coordinator → Data receiver: sets receiver
- Thread coordinator → Video sender: updates host
- Thread coordinator → Data receiver: updates host
- AR interface → Command sender: emits commands
- AR interface → Camera control: freezes camera
- AR interface → Gesture handling: handles input
- AR interface → Graphics view: renders view
- Video sender → Send worker: sent by
- Command sender → Send worker: sent by
- Video sender → Video messages and codecs: encodes video
- Video sender → Neuronavigation platform: sends video
- Command sender → Neuronavigation platform: sends commands
- Neuronavigation platform → Data receiver: sends data
- Data receiver → Video receive worker: video input
- Data receiver → Command receive worker: command input
- Video receive worker → AR interface: delivers video
- Command receive worker → AR interface: delivers data
- Sender base → OpenIGTLink messages and sockets: uses protocol
- Data receiver → OpenIGTLink messages and sockets: uses protocol
- OpenIGTLink messages and sockets → Session management: manages sessions
