Skip to main content

Camera Module Reference

Complete API reference for camera capture and vision intent detection components.

VisionIntentDetector

Intelligently detects when camera capture should be activated based on user speech.

Location: src/Components/VisionIntentDetector.ts

import { VisionIntentDetector, VisionIntentConfig, VisionIntentResult } from 'estuary-lens-studio-sdk';

Constructor

const detector = new VisionIntentDetector(config: VisionIntentConfig);

VisionIntentConfig

PropertyTypeDefaultDescription
apiKeystring''Optional LLM API key (uses heuristic if empty)
debugLoggingbooleanfalseEnable debug logging
confidenceThresholdnumber0.7Threshold for triggering camera (0-1)
endpointstringOpenAI URLOptional LLM API endpoint
modelstring'gpt-4o-mini'LLM model if using API
customSystemPromptstringBuilt-in promptCustom classification prompt

Methods

MethodParametersReturnsDescription
startListening()character: EstuaryCharactervoidStart monitoring character transcripts
stopListening()-voidStop monitoring transcripts
analyzeTranscript()transcript: stringPromise<VisionIntentResult | null>Manually analyze text for vision intent
dispose()-voidClean up resources

Properties

PropertyTypeDescription
isListeningbooleanWhether detector is monitoring transcripts
debugLoggingbooleanDebug mode enabled
confidenceThresholdnumberCurrent confidence threshold

Events

EventPayloadDescription
visionIntentDetected(request: CameraCaptureRequest, result: VisionIntentResult)Vision intent was detected

VisionIntentResult

interface VisionIntentResult {
requiresVision: boolean; // Whether visual context is needed
confidence: number; // Confidence score (0-1)
transcript: string; // Original transcript analyzed
reason?: string; // Explanation for the decision
}

Example Usage

import { VisionIntentDetector } from 'estuary-lens-studio-sdk';

const detector = new VisionIntentDetector({
confidenceThreshold: 0.7,
debugLogging: true
});

detector.startListening(character);

detector.on('visionIntentDetected', (request, result) => {
print(`Vision intent detected: ${result.confidence}`);
print(`Reason: ${result.reason}`);
});

VisionIntentDetectorComponent

Lens Studio component wrapper for VisionIntentDetector.

Location: src/Components/VisionIntentDetector.ts

import { VisionIntentDetectorComponent } from 'estuary-lens-studio-sdk';

Inspector Inputs

InputTypeDefaultDescription
confidenceThresholdnumber0.7Threshold for triggering camera (0-1)
debugModebooleantrueEnable debug logging
autoConnectbooleantrueAuto-connect to EstuaryCharacter

Static Properties

PropertyTypeDescription
instanceVisionIntentDetectorComponent | nullSingleton instance
hasInstancebooleanWhether instance exists

Properties

PropertyTypeDescription
detectorVisionIntentDetector | nullUnderlying detector instance

Methods

MethodParametersReturnsDescription
connectToCharacter()character: EstuaryCharactervoidConnect to a character
disconnect()-voidDisconnect from current character
analyzeTranscript()transcript: stringvoidManually analyze a transcript
onVisionIntent()handler: (request, result) => void() => voidSubscribe to vision intent events (returns unsubscribe)

Example Usage

import { VisionIntentDetectorComponent } from 'estuary-lens-studio-sdk';

@component
export class MyVisionScript extends BaseScriptComponent {

onAwake() {
const detector = VisionIntentDetectorComponent.instance;

if (detector) {
const unsubscribe = detector.onVisionIntent((request, result) => {
print(`Captured request: ${request.request_id}`);
print(`Confidence: ${result.confidence}`);
});
}
}
}

EstuaryVoiceConnection (Example)

Example component that handles voice connection and vision intent detection.

Location: Examples/EstuaryVoiceConnection.ts (class: SimpleAutoConnect)

Example Component

EstuaryVoiceConnection is an example implementation provided in the SDK's Examples/ folder. Copy it to your project and customize as needed.

InputTypeDefaultDescription
enableVisionIntentDetectionbooleantrueEnable natural language camera activation
visionConfidenceThresholdnumber0.7Confidence threshold for camera trigger (0-1)

Methods

MethodParametersReturnsDescription
getVisionIntentDetector()-VisionIntentDetector | nullGet the vision intent detector instance

EstuaryCamera (Example)

Example component for handling camera capture on Spectacles hardware.

Location: Examples/EstuaryCamera.ts

Example Component

EstuaryCamera is an example implementation provided in the SDK's Examples/ folder. Copy it to your project and customize as needed.

Inspector Inputs

InputTypeDefaultDescription
debugModebooleantrueEnable debug logging
captureResolutionnumber512Image resolution (smaller dimension in px)
enableVisionAcknowledgmentbooleantrueAI says acknowledgment before analyzing

Methods

MethodParametersReturnsDescription
manualCapture()text?: stringvoidManually trigger camera capture

Lifecycle

// CameraModule APIs cannot be called in onAwake!
// Component automatically initializes in OnStartEvent

Example Usage

@component
export class CameraController extends BaseScriptComponent {

@input
estuaryCamera: ScriptComponent;

onAwake() {
// Set up a tap to capture
this.createEvent("TapEvent").bind(() => {
(this.estuaryCamera as any).manualCapture("What is this?");
});
}
}

CameraCaptureRequest

Request object sent when camera capture is needed.

Location: src/Core/EstuaryEvents.ts

import { CameraCaptureRequest } from 'estuary-lens-studio-sdk';

Interface

interface CameraCaptureRequest {
request_id: string; // Unique identifier for this request
text?: string; // Optional text context for the capture
}

Usage

import { EstuaryManager, CameraCaptureRequest } from 'estuary-lens-studio-sdk';

// Receiving camera capture requests
EstuaryManager.instance.on('cameraCaptureRequest', (request: CameraCaptureRequest) => {
print(`Capture requested: ${request.request_id}`);
print(`Context: ${request.text}`);
});

EstuaryManager Camera Methods

Camera-related methods on the EstuaryManager singleton.

Location: src/Components/EstuaryManager.ts

sendCameraImage

Send a captured image to the server for AI analysis.

sendCameraImage(
imageBase64: string,
mimeType?: string,
requestId?: string,
text?: string,
sampleRate?: number
): void
ParameterTypeDefaultDescription
imageBase64stringrequiredBase64-encoded image data
mimeTypestring'image/jpeg'MIME type of the image
requestIdstring-Request ID if responding to server request
textstring-Text context to send with image
sampleRatenumber16000TTS output sample rate
import { EstuaryManager } from 'estuary-lens-studio-sdk';

EstuaryManager.instance.sendCameraImage(
base64ImageData,
'image/jpeg',
'request-123',
'What do you see?'
);

sendVisionPending

Signal that an image is about to be sent.

sendVisionPending(text: string, requestId?: string): void
ParameterTypeDescription
textstringTranscript that triggered vision detection
requestIdstringOptional request ID for correlation
import { EstuaryManager } from 'estuary-lens-studio-sdk';

EstuaryManager.instance.sendVisionPending(
"What do you think of this vase?",
"vision-intent-12345"
);

updatePreferences

Update session preferences including vision settings.

updatePreferences(preferences: ClientPreferences): void
interface ClientPreferences {
enableVisionAcknowledgment?: boolean; // AI acknowledges before analyzing
}
import { EstuaryManager } from 'estuary-lens-studio-sdk';

EstuaryManager.instance.updatePreferences({
enableVisionAcknowledgment: true
});

Events

cameraCaptureRequest

Emitted by EstuaryManager when the server requests a camera capture.

import { EstuaryManager, CameraCaptureRequest } from 'estuary-lens-studio-sdk';

EstuaryManager.instance.on('cameraCaptureRequest', (request: CameraCaptureRequest) => {
print(`Server requested capture: ${request.request_id}`);
});

visionIntentDetected

Emitted by VisionIntentDetector when vision intent is detected.

import { VisionIntentDetector, CameraCaptureRequest, VisionIntentResult } from 'estuary-lens-studio-sdk';

detector.on('visionIntentDetected', (request: CameraCaptureRequest, result: VisionIntentResult) => {
print(`Vision intent: ${result.confidence}`);
});

Heuristic Detection Keywords

The VisionIntentDetector uses these patterns for heuristic detection:

Strong Indicators (Confidence ~0.9)

const strongIndicators = [
'look at this', 'look at that', 'see this', 'see that',
'what is this', 'what is that', 'what\'s this', 'what\'s that',
'can you see', 'do you see', 'show you',
'looking at', 'i\'m looking', 'i am looking',
'this thing', 'that thing', 'what thing',
'identify this', 'identify that', 'recognize this',
'what kind of', 'what type of', 'what breed',
'is this a', 'is that a', 'is this an', 'is that an',
'read this', 'read that', 'what does this say',
'help me with this', 'check this out'
];

Medium Indicators (Confidence ~0.5-0.75)

const mediumIndicators = [
'this', 'that', 'here', 'over here',
'in front of me', 'right here',
'what do you think', 'your opinion',
'is it', 'does it look', 'how does this look'
];

const contextClues = [
'vase', 'plant', 'flower', 'dog', 'cat', 'animal', 'bird',
'painting', 'picture', 'photo', 'art', 'artwork',
'food', 'dish', 'fruit', 'vegetable', 'meal',
'shirt', 'dress', 'outfit', 'clothes', 'wearing',
'car', 'building', 'house', 'room', 'landscape',
'sign', 'text', 'writing', 'label', 'menu',
'color', 'shape', 'pattern', 'design',
'ripe', 'fresh', 'broken', 'damaged'
];

When a medium indicator is found with a context clue, confidence is ~0.75. Medium indicator alone gives ~0.5 confidence. Context clue alone gives ~0.4 confidence.


Type Definitions

Complete Type Reference

// Vision Intent Configuration
interface VisionIntentConfig {
apiKey?: string;
debugLogging?: boolean;
confidenceThreshold?: number;
endpoint?: string;
model?: string;
customSystemPrompt?: string;
}

// Vision Intent Detection Result
interface VisionIntentResult {
requiresVision: boolean;
confidence: number;
transcript: string;
reason?: string;
}

// Camera Capture Request
interface CameraCaptureRequest {
request_id: string;
text?: string;
}

// Client Preferences
interface ClientPreferences {
enableVisionAcknowledgment?: boolean;
}

SDK Structure

estuary-lens-studio-sdk/
├── src/
│ ├── Components/
│ │ ├── VisionIntentDetector.ts ← VisionIntentDetector, VisionIntentDetectorComponent
│ │ └── EstuaryManager.ts ← sendCameraImage, sendVisionPending, updatePreferences
│ └── Core/
│ └── EstuaryEvents.ts ← CameraCaptureRequest type
└── Examples/
├── EstuaryVoiceConnection.ts ← Vision intent settings (enableVisionIntentDetection, visionConfidenceThreshold)
└── EstuaryCamera.ts ← Camera capture settings (captureResolution, enableVisionAcknowledgment)

See Also