Analyzers API Reference¶
video_processor.analyzers.diagram_analyzer
¶
Diagram analysis using vision model classification and single-pass extraction.
DiagramAnalyzer
¶
Vision model-based diagram detection and analysis.
Source code in video_processor/analyzers/diagram_analyzer.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |
analyze_diagram_single_pass(image_path)
¶
Full single-pass diagram analysis — description, text, mermaid, chart data.
Returns parsed dict or empty dict on failure.
Source code in video_processor/analyzers/diagram_analyzer.py
caption_frame(image_path)
¶
Get a brief caption for a screengrab fallback.
Source code in video_processor/analyzers/diagram_analyzer.py
classify_frame(image_path)
¶
Classify a single frame using vision model.
Returns dict with is_diagram, diagram_type, confidence, brief_description.
Source code in video_processor/analyzers/diagram_analyzer.py
extract_screenshot_knowledge(image_path)
¶
Extract knowledge from a screenshot — text, entities, topics.
Source code in video_processor/analyzers/diagram_analyzer.py
process_frames(frame_paths, diagrams_dir=None, captures_dir=None, cache_dir=None)
¶
Process a list of extracted frames: classify, analyze diagrams, screengrab fallback.
Classification and analysis run in parallel using a thread pool. Results are cached by frame content hash so re-runs skip already-analyzed frames.
Thresholds
- confidence >= 0.7 → full diagram analysis (story 3.2)
- 0.3 <= confidence < 0.7 → screengrab fallback (story 3.3)
- confidence < 0.3 → skip
Returns (diagrams, screen_captures).
Source code in video_processor/analyzers/diagram_analyzer.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
video_processor.analyzers.content_analyzer
¶
Content cross-referencing between transcript and diagram entities.
ContentAnalyzer
¶
Cross-references transcript and diagram entities for richer knowledge.
Source code in video_processor/analyzers/content_analyzer.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
cross_reference(transcript_entities, diagram_entities)
¶
Merge entities from transcripts and diagrams.
Merges by exact name overlap first, then uses LLM for fuzzy matching of remaining entities. Adds source attribution.
Source code in video_processor/analyzers/content_analyzer.py
enrich_key_points(key_points, diagrams, transcript_text)
¶
Link key points to relevant diagrams by entity overlap and temporal proximity.
Source code in video_processor/analyzers/content_analyzer.py
video_processor.analyzers.action_detector
¶
Enhanced action item detection from transcripts and diagrams.
ActionDetector
¶
Detects action items from transcripts using heuristics and LLM.
Source code in video_processor/analyzers/action_detector.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
detect_from_diagrams(diagrams)
¶
Extract action items mentioned in diagram text content.
Looks for action-oriented language in diagram text/elements.
Source code in video_processor/analyzers/action_detector.py
detect_from_transcript(text, segments=None)
¶
Detect action items from transcript text.
Uses LLM extraction when available, falls back to pattern matching. Segments are used to attach timestamps.
Source code in video_processor/analyzers/action_detector.py
merge_action_items(transcript_items, diagram_items)
¶
Merge action items from transcript and diagram sources.
Deduplicates by checking for similar action text.
Source code in video_processor/analyzers/action_detector.py
Overview¶
The analyzers module contains the core content extraction logic for PlanOpticon. These analyzers process video frames and transcripts to extract structured knowledge: diagrams, key points, action items, and cross-referenced entities.
All analyzers accept an optional ProviderManager instance. When provided, they use LLM capabilities for richer extraction. Without one, they fall back to heuristic/pattern-based methods where possible.
DiagramAnalyzer¶
Vision model-based diagram detection and analysis. Classifies video frames as diagrams, slides, screenshots, or other content, then performs full extraction on high-confidence frames.
Constructor¶
def __init__(
self,
provider_manager: Optional[ProviderManager] = None,
confidence_threshold: float = 0.3,
)
| Parameter | Type | Default | Description |
|---|---|---|---|
provider_manager |
Optional[ProviderManager] |
None |
LLM provider (creates a default if not provided) |
confidence_threshold |
float |
0.3 |
Minimum confidence to process a frame at all |
classify_frame()¶
Classify a single frame using a vision model. Determines whether the frame contains a diagram, slide, or other visual content worth extracting.
Parameters:
| Parameter | Type | Description |
|---|---|---|
image_path |
Union[str, Path] |
Path to the frame image file |
Returns: dict with the following keys:
| Key | Type | Description |
|---|---|---|
is_diagram |
bool |
Whether the frame contains extractable content |
diagram_type |
str |
One of: flowchart, sequence, architecture, whiteboard, chart, table, slide, screenshot, unknown |
confidence |
float |
Detection confidence from 0.0 to 1.0 |
content_type |
str |
Content category: slide, diagram, document, screen_share, whiteboard, chart, person, other |
brief_description |
str |
One-sentence description of the frame content |
Important: Frames showing people, webcam feeds, or video conference participant views return confidence: 0.0. The classifier is tuned to detect only shared/presented content.
analyzer = DiagramAnalyzer()
result = analyzer.classify_frame("/path/to/frame_042.jpg")
if result["confidence"] >= 0.7:
print(f"Diagram detected: {result['diagram_type']}")
analyze_diagram_single_pass()¶
Full single-pass diagram analysis. Extracts description, text content, elements, relationships, Mermaid syntax, and chart data in a single LLM call.
Returns: dict with the following keys:
| Key | Type | Description |
|---|---|---|
diagram_type |
str |
Diagram classification |
description |
str |
Detailed description of the visual content |
text_content |
str |
All visible text, preserving structure |
elements |
list[str] |
Identified elements/components |
relationships |
list[str] |
Relationships in "A -> B: label" format |
mermaid |
str |
Valid Mermaid diagram syntax |
chart_data |
dict \| None |
Chart data with labels, values, chart_type (only for data charts) |
Returns an empty dict on failure.
caption_frame()¶
Get a brief 1-2 sentence caption for a frame. Used as a fallback when full diagram analysis is not warranted.
Returns: str -- a brief description of the frame content.
process_frames()¶
def process_frames(
self,
frame_paths: List[Union[str, Path]],
diagrams_dir: Optional[Path] = None,
captures_dir: Optional[Path] = None,
) -> Tuple[List[DiagramResult], List[ScreenCapture]]
Process a batch of extracted video frames through the full classification and analysis pipeline.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
frame_paths |
List[Union[str, Path]] |
required | Paths to frame images |
diagrams_dir |
Optional[Path] |
None |
Output directory for diagram files (images, mermaid, JSON) |
captures_dir |
Optional[Path] |
None |
Output directory for screengrab fallback files |
Returns: Tuple[List[DiagramResult], List[ScreenCapture]]
Confidence thresholds:
| Confidence Range | Action |
|---|---|
| >= 0.7 | Full diagram analysis -- extracts elements, relationships, Mermaid syntax |
| 0.3 to 0.7 | Screengrab fallback -- saves frame with a brief caption |
| < 0.3 | Skipped entirely |
Output files (when directories are provided):
For diagrams (diagrams_dir):
diagram_N.jpg-- original frame imagediagram_N.mermaid-- Mermaid source (if generated)diagram_N.json-- full DiagramResult as JSON
For screen captures (captures_dir):
capture_N.jpg-- original frame imagecapture_N.json-- ScreenCapture metadata as JSON
from pathlib import Path
from video_processor.analyzers.diagram_analyzer import DiagramAnalyzer
from video_processor.providers.manager import ProviderManager
analyzer = DiagramAnalyzer(
provider_manager=ProviderManager(),
confidence_threshold=0.3,
)
frame_paths = list(Path("output/frames").glob("*.jpg"))
diagrams, captures = analyzer.process_frames(
frame_paths,
diagrams_dir=Path("output/diagrams"),
captures_dir=Path("output/captures"),
)
print(f"Found {len(diagrams)} diagrams, {len(captures)} screengrabs")
for d in diagrams:
print(f" [{d.diagram_type.value}] {d.description}")
ContentAnalyzer¶
Cross-references transcript and diagram entities for richer knowledge extraction. Merges entities found in different sources and enriches key points with diagram links.
Constructor¶
| Parameter | Type | Default | Description |
|---|---|---|---|
provider_manager |
Optional[ProviderManager] |
None |
Required for LLM-based fuzzy matching |
cross_reference()¶
def cross_reference(
self,
transcript_entities: List[Entity],
diagram_entities: List[Entity],
) -> List[Entity]
Merge entities from transcripts and diagrams into a unified list with source attribution.
Merge strategy:
- Index all transcript entities by lowercase name, marked with
source="transcript" - Merge diagram entities: if a name matches, set
source="both"and combine descriptions/occurrences; otherwise add assource="diagram" - If a
ProviderManageris available, use LLM fuzzy matching to find additional matches among unmatched entities (e.g., "PostgreSQL" from transcript matching "Postgres" from diagram)
Parameters:
| Parameter | Type | Description |
|---|---|---|
transcript_entities |
List[Entity] |
Entities extracted from transcript |
diagram_entities |
List[Entity] |
Entities extracted from diagrams |
Returns: List[Entity] -- merged entity list with source attribution.
from video_processor.analyzers.content_analyzer import ContentAnalyzer
from video_processor.models import Entity
analyzer = ContentAnalyzer(provider_manager=pm)
transcript_entities = [
Entity(name="PostgreSQL", type="technology"),
Entity(name="Alice", type="person"),
]
diagram_entities = [
Entity(name="Postgres", type="technology"),
Entity(name="Redis", type="technology"),
]
merged = analyzer.cross_reference(transcript_entities, diagram_entities)
# "PostgreSQL" and "Postgres" may be fuzzy-matched and merged
enrich_key_points()¶
def enrich_key_points(
self,
key_points: List[KeyPoint],
diagrams: list,
transcript_text: str,
) -> List[KeyPoint]
Link key points to relevant diagrams by entity overlap. Examines word overlap between key point text and diagram elements/text content.
Parameters:
| Parameter | Type | Description |
|---|---|---|
key_points |
List[KeyPoint] |
Key points to enrich |
diagrams |
list |
List of DiagramResult objects or dicts |
transcript_text |
str |
Full transcript text (reserved for future use) |
Returns: List[KeyPoint] -- key points with related_diagrams indices populated.
A key point is linked to a diagram when they share 2 or more words (excluding short words) between the key point text/details and the diagram's elements/text content.
ActionDetector¶
Detects action items from transcripts and diagram content using LLM extraction with a regex pattern fallback.
Constructor¶
| Parameter | Type | Default | Description |
|---|---|---|---|
provider_manager |
Optional[ProviderManager] |
None |
Required for LLM-based extraction |
detect_from_transcript()¶
def detect_from_transcript(
self,
text: str,
segments: Optional[List[TranscriptSegment]] = None,
) -> List[ActionItem]
Detect action items from transcript text.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
str |
required | Transcript text to analyze |
segments |
Optional[List[TranscriptSegment]] |
None |
Transcript segments for timestamp attachment |
Returns: List[ActionItem] -- detected action items with source="transcript".
Extraction modes:
- LLM mode (when
provider_manageris set): Sends the transcript to the LLM with a structured extraction prompt. Extracts action, assignee, deadline, priority, and context. - Pattern mode (fallback): Matches sentences against regex patterns for action-oriented language.
Pattern matching detects sentences containing:
- "need/needs to", "should/must/shall"
- "will/going to", "action item/todo/follow-up"
- "assigned to/responsible for", "deadline/due by"
- "let's/let us", "make sure/ensure"
- "can you/could you/please"
Timestamp attachment: When segments are provided, each action item is matched to the most relevant transcript segment (by word overlap, minimum 3 matching words), and a timestamp is added to context.
detect_from_diagrams()¶
Extract action items from diagram text content and elements. Processes each diagram's combined text using either LLM or pattern extraction.
Parameters:
| Parameter | Type | Description |
|---|---|---|
diagrams |
list |
List of DiagramResult objects or dicts |
Returns: List[ActionItem] -- action items with source="diagram".
merge_action_items()¶
def merge_action_items(
self,
transcript_items: List[ActionItem],
diagram_items: List[ActionItem],
) -> List[ActionItem]
Merge action items from multiple sources, deduplicating by action text (case-insensitive, whitespace-normalized).
Returns: List[ActionItem] -- deduplicated merged list.
Usage example¶
from video_processor.analyzers.action_detector import ActionDetector
from video_processor.providers.manager import ProviderManager
detector = ActionDetector(provider_manager=ProviderManager())
# From transcript
transcript_items = detector.detect_from_transcript(
text="Alice needs to update the API docs by Friday. "
"Bob should review the PR before merging.",
segments=transcript_segments,
)
# From diagrams
diagram_items = detector.detect_from_diagrams(diagram_results)
# Merge and deduplicate
all_items = detector.merge_action_items(transcript_items, diagram_items)
for item in all_items:
print(f"[{item.priority or 'unset'}] {item.action}")
if item.assignee:
print(f" Assignee: {item.assignee}")
if item.deadline:
print(f" Deadline: {item.deadline}")