Repository navigation
PERCEPTION
Status: Implemented
Last Updated: 2026-11-13
Audience: Developers who implement perception workers
Last verified: 2026-11-13 against 5f40af2d9 (source and command; tests not run)
Code: src/Martlet.Perception/, src/Martlet.Gateway/GatewayInferenceContracts.cs, src/Martlet.Gateway/GatewayInferenceJson.cs, src/Martlet.Gateway/GatewayPerceptionOutput.cs, src/Martlet.Desktop/ScreenGlancer.cs, tests/Martlet.Perception.Tests/, tests/Martlet.Gateway.Tests/
Martlet.Perception holds the contracts for the OCR and visual question
answering (VLM) workers of a host. OCR reads the text in a picture. A VLM
answers a question about a picture. The gateway (Martlet.Gateway) uses these
contracts for its PerceptionOcr and PerceptionVlm inference routes
(GatewayInferenceRoute.Perception).
The library has no screen capture, no network client and no model. The Desktop feature Watch my screen captures the active window itself and does not use this library.
An earlier selected-window capture engine, freshness scheduler, gateway client adapter and synthetic worker transport were in this project. No app used them, so they were removed (issue #942). Git keeps their history.
| File | Contents |
|---|---|
PerceptionIdentities.cs |
PerceptionWorkerIdentity: the worker role (OCR or VLM), build, runtime, model, artifacts, limits, resources and cancellation capability |
PerceptionFrames.cs |
PerceptionProtocol limits and SelectedWindowFrame with its PNG or ephemeral-reference content |
PerceptionWorkerContracts.cs |
Job intent, vision authorization, worker request and response, OCR and VLM output, cancellation |
PerceptionFailures.cs |
PerceptionWorkerFailure codes, their catalog of remedies and PerceptionWorkerException
|
DeterministicPerceptionFixtureIdentity.cs |
A synthetic worker identity for tests; it is not a model |
PerceptionProtocolVersion.Current is worker protocol 1.0, contract
martlet.perception.worker. It is not the gateway authentication protocol.
A worker identity match includes every field and artifact. There is no
detector role, compatibility fallback or model substitution.
SelectedWindowFrame binds an opaque selection, source and capture-permission
revision, frame ID, positive capture epoch, timestamp and content. Content is
an immutable copied PNG or an opaque ephemeral reference:
| Worker boundary | Hard limit and behavior |
|---|---|
| Encoded image | 4 MiB, checked before copying |
| Dimensions | 4,096 px per edge, 8,294,400 pixels in total |
| PNG | 8-bit RGB or RGBA, not interlaced, exact rows, CRC and zlib checks, no unknown or trailing chunks |
| Ephemeral reference | Opaque identifier, digest, size, dimensions and expiry; no URL or path |
| VLM question | 512 characters or 1,024 UTF-8 bytes |
| OCR result | 128 bounded regions in order, an immutable snapshot, normalized 0–10,000 bounds |
| Output text | 16 KiB UTF-8 or the smaller limit of the worker |
| Job and frame age | 15 seconds and 30 seconds at most; callers can set smaller limits |
PerceptionJobIntent binds one request, destination, worker, frame, task,
deadline and maximum frame age. Authorize rejects No and creates a
PerceptionVisionAuthorization only for Allow. The authorization expires,
is used only once and binds the exact request. It records the decision of a
trusted caller. It is not a human consent screen or an operating system
permission, and it does not authorize capture.
Failures use the typed PerceptionWorkerFailure codes, each with a stable
remedy. Do not show arbitrary worker error text to users. For unavailable,
late or resource-limited vision, the catalog tells callers to continue without
optional vision context and retry only deliberately.
tests/Martlet.Perception.Tests/ContractTests.cs covers the protocol, the
identity pins, PNG checks, references, job and authorization rules and the
failure catalog. Martlet.Gateway.Tests covers the gateway perception routes.
.\scripts\Test-Martlet.ps1 -Project Martlet.Perception.TestsMartlet: download · repository · changelog · issues
These pages come from docs/wiki in the repository. To suggest a change, open an issue or a pull request there.
- Home
- Accounts and households
- Accounts and Household
- Android phones and tablets: what it takes, and the plan
- Martlet's API for other apps and scripts
- App Guides
- App Settings and Updates
- App guides: game and app knowledge from the web
- Architecture
- Bounded PCM playback
- Audio dependency inventory and notices
- Avatar guide: Live2D, VRM and speech animation
- V01a explicit microphone capture
- Chatterbox voice engines
- Cleaning up disk space
- One Martlet on all your computers
- Companion controls and behavior requirements
- Components, jobs and placement (design)
- Live conversation
- Creations
- Decision map: which file owns each decision
- Deep research: web search and long research jobs
- The desktop app: updates, notification area, exiting and appearance
- Linux and macOS desktop companion: research, decision and plan
- Developer Guide
- Dia voice engine
- Diagnostics
- Discord
- Architecture and provider contracts
- Discord
- Memory (P03a/P03b/P03c)
- Singing
- Desktop troubleshooting and local support
- Recognizing people by voice, and Parakeet
- Echo cancellation
- ElevenLabs voice: your cloned voice with tones
- F5 worker and reference-voice foundation
- FAQ
- First Steps
- Game state plan: implementation history
- Glossary: one name for each concept
- GPT-SoVITS voice
- Hosted Thinking: cloud models when Thinking can't run on this PC
- Installation and support
- Installing Martlet
- iOS and iPadOS: what it takes, and the plan
- Repository instructions for coding agents
- Repository knowledge base
- Knowledge base maintenance
- GitHub Wiki mirror
- Linux and Mac
- Listening and Voice ID
- Local model apps
- Lorebooks
- macOS: what it takes, and the plan
- Martlet MCP Server
- MCP in Martlet
- MCP: The app's window
- MCP: Apps, home and memory
- MCP: Characters
- MCP: Diagnostics and logs
- MCP: Computers, network and accounts
- MCP: Other
- MCP: Tool permissions
- MCP pages
- MCP: Server and protocol internals
- MCP: Settings
- MCP: Start here
- MCP: Thinking and models
- MCP: Voice and listening
- Memory
- Messaging apps
- Model catalog: sources, conflicts and design
- Motion host role
- Multiple Computers
- Your Martlet network
- OCR host role
- Share your language models: the OpenAI-compatible endpoint
- Packaging
- Perception worker contracts
- Personality and Characters
- Picture making
- Pictures and Creations
- Picture making host role
- Platforms: what each device can do
- Prerequisites: what Martlet bundles, installs for you, or needs from you
- Privacy and Safety
- Reading the text on your screen
- Wiki source
- Recommendation design: ask three questions, plan for three situations
- Recommended setups: one machine to unlimited budget
- Releasing
- Repository Layout
- Research and provenance ledger
- Resource footprints
- Roadmap
- Watch my screen: screen-aware commentary
- Search engine
- Image and audio models: who sees, who hears, who answers
- Setting Up a Host
- Setup, Windows credentials and local audio
- Sharing with Friends
- Singing
- Smart Home
- Smart home and cameras
- Source Projects
- Talking to Martlet
- Telegram and WhatsApp
- The Character
- Thinking
- Tools and MCP
- Troubleshooting
- Martlet desktop UI design
- User stories and target flows
- Voice activity detection
- Validating changes
- Validation and Testing
- Vision
- Voice latency: from you stopping talking to Martlet's voice
- Voice recognition host role
- Multi-engine voice setup and comparison
- Voices
- The welcome wizard
- XTTS-v2 voice engine