Module stages

Module stages 

Source
Expand description

Shared stage processors for the OCR pipeline.

This module provides reusable stage processors that eliminate code duplication across different pipeline flows (single-image, in-memory, dynamic batching, detection-from-memory). Each processor encapsulates the logic for a specific pipeline stage with consistent error handling, logging, and performance characteristics.

§Extensible Pipeline Architecture

The pipeline supports extensible stages through the PipelineStage trait and StageRegistry system, allowing new stages to be added without modifying core pipeline code.

§Stage Processor Pattern Abstraction

This module includes helper utilities that reduce code duplication across stage processors by abstracting common lifecycle patterns:

  • Timing management - Automatic start/stop timing for operations
  • Empty input handling - Consistent behavior for empty input collections
  • Parallel processing - Automatic decisions between sequential and parallel processing
  • Metrics collection - Standardized success/failure counting and metadata
  • Result wrapping - Consistent StageResult creation with metrics

These abstractions reduce repetitive code by approximately 25-35% across the orientation, cropping, and recognition processors while maintaining the same functionality and API compatibility.

See [processor_helper] for the concrete helper implementations.

Re-exports§

pub use config::ExtensiblePipelineConfig;
pub use config::GlobalPipelineSettings;

Modules§

config
Configuration system for extensible pipeline stages.

Structs§

BatchConfig
Configuration for batch processing behavior
BatchProcessor
Helper for processing collections with common lifecycle patterns
CroppingConfig
Configuration for cropping processing
CroppingResult
Result of cropping processing
CroppingStageProcessor
Processor for text box cropping stage.
ExtensibleCroppingStage
Extensible cropping stage that implements PipelineStage trait.
ExtensibleOrientationStage
Extensible orientation stage that implements PipelineStage trait.
ExtensiblePipeline
Extensible pipeline that uses the stage registry.
ExtensibleRecognitionStage
Extensible recognition stage that implements PipelineStage trait.
ExtensibleTextDetectionStage
Extensible text detection stage that implements PipelineStage trait.
ExtensibleTextLineOrientationStage
Text line orientation stage for the extensible pipeline.
GroupingStrategyFactory
Factory for creating grouping strategies
OrientationConfig
Configuration for orientation processing
OrientationCorrectionConfig
Configuration for orientation correction
OrientationCorrector
Component responsible for applying text line orientation corrections
OrientationResult
Result of orientation classification processing
OrientationStageProcessor
Processor for document orientation classification stage.
PipelineExecutor
Pipeline executor for running extensible pipelines.
RecognitionConfig
Configuration for recognition processing
RecognitionResult
Result of recognition processing
RecognitionStageProcessor
Processor for text recognition grouping and processing stage.
SingleItemProcessor
Helper for single item processing with timing and metrics
StageContext
Context information available to pipeline stages during execution.
StageData
Data that flows between pipeline stages.
StageId
Unique identifier for a pipeline stage.
StageMetrics
Metrics collected during stage processing.
StageProcessorHelper
Helper utility for common stage processing patterns.
StageResult
Result wrapper for stage processing operations.
TextDetectionConfig
Configuration for text detection processing.
TextDetectionResult
Result of text detection processing.
TextLineOrientationConfig
Configuration for text line orientation processing.

Enums§

GroupingStrategyConfig
Configuration for different grouping strategies
StageDependency
Dependency specification for a pipeline stage.

Traits§

GroupingStrategy
Trait for image grouping strategies
PipelineStage
Trait for extensible pipeline stages.
StageAlgorithm
Trait for stage algorithms that can be run with automatic timing and metrics.
StageProcessor
Trait for stage processors that follow the common lifecycle pattern.

Functions§

process_items
Generic utility function for processing collections with common patterns.
run_with_metrics
Generic stage harness that runs an algorithm with automatic timing and metrics.
run_with_metrics_and_fallback
Generic stage harness with custom error handling.