Methods
run
Execute the K21 capture and processing pipeline
The run
method executes the configured capture and processing pipeline. It can handle different combinations of capture sources (screen or file) and processing methods (OCR or Vision).
Usage
Return Type: ProcessedFrameData[]
The method returns an array of ProcessedFrameData
objects, each representing a processed frame:
Parameter | Type | Description |
---|---|---|
timestamp | string | ISO timestamp when the frame was captured |
frameNumber | number | Sequential number of the frame in the capture sequence |
content | string | Processed content from the frame (e.g., OCR text) |
processingType | string | Type of processing applied (e.g., “OCR”, “CLASSIFICATION”) |
Examples
Basic Screen Capture with OCR
Example output:
Process Existing File
Capture Only (No Processing)
Error Handling
The method will throw an error in these cases:
- If neither screen capturer nor file capturer is set
- If screen capture or processing fails
- If the configuration state is invalid
Pipeline Behavior
The run
method handles different configurations:
-
Capturer Only
- Captures frames but returns empty array
- Useful for saving captures without processing
-
Capturer + Processor
- Captures frames and processes them
- Returns array of processed frames
-
File Capturer + Processor
- Processes existing file
- Returns array with processed results
Important Notes
- The method is asynchronous and returns a Promise
- Frame numbers start from 1 and increment sequentially
- Timestamps are in ISO format
- Content format depends on the processing type:
- OCR: Extracted text
- Vision: Model-specific output
- Empty array is returned if no processor is configured