UNPKG

@flexabrain/mcp-server

Version:

Advanced electrical schematic analysis MCP server with rail engineering expertise

138 lines 4.24 kB
/** * FlexaBrain MCP Server - Enhanced OCR Service * * Advanced OCR service specifically designed for complex technical drawings * and multi-page traction generator monitoring control schematics. * * Extends the base OCR service with: * - Dense layout text extraction * - Line and connection detection * - Generator monitoring component patterns * - Multi-resolution processing * - Technical drawing feature recognition */ import { PSM } from 'tesseract.js'; import { OCRResult } from '../types/schematic.js'; import { SchematicPage } from '../types/pdf-schematic.js'; import { BoundingBox } from '../types/electrical.js'; export interface EnhancedOCROptions { language?: string; psm?: PSM; dpi?: number; enable_line_detection?: boolean; enable_symbol_recognition?: boolean; preprocessing_filters?: string[]; confidence_threshold?: number; generator_monitoring_mode?: boolean; } export interface LineDetectionResult { lines: DetectedLine[]; connections: LineConnection[]; processing_time: number; } export interface DetectedLine { id: string; start_point: { x: number; y: number; }; end_point: { x: number; y: number; }; line_type: 'power' | 'control' | 'signal' | 'mechanical' | 'unknown'; confidence: number; thickness: number; style: 'solid' | 'dashed' | 'dotted'; } export interface LineConnection { line_id: string; connected_components: string[]; connection_type: 'input' | 'output' | 'bidirectional'; wire_number?: string; signal_name?: string; } export interface SymbolRecognitionResult { symbols: DetectedSymbol[]; processing_time: number; } export interface DetectedSymbol { id: string; symbol_type: 'resistor' | 'capacitor' | 'transformer' | 'switch' | 'meter' | 'unknown'; location: BoundingBox; confidence: number; parameters?: Record<string, string>; } export interface TechnicalTextRegion { region_type: 'title_block' | 'component_list' | 'notes' | 'dimensions' | 'wire_labels'; location: BoundingBox; text_content: string; confidence: number; } export declare class EnhancedOCRService { private worker; private isInitialized; private processingCache; private readonly GENERATOR_COMPONENT_PATTERNS; constructor(); private initializeWorker; /** * Process a complete schematic page with enhanced OCR capabilities */ processSchematicPage(page: SchematicPage, options?: EnhancedOCROptions): Promise<{ ocr_result: OCRResult; line_detection?: LineDetectionResult; symbols?: SymbolRecognitionResult; }>; /** * Preprocess image for better OCR results on technical drawings */ private preprocessImage; /** * Perform OCR at multiple resolutions for better accuracy */ private performMultiResolutionOCR; /** * Enhance component recognition with generator monitoring patterns */ private enhanceGeneratorComponentRecognition; /** * Extract technical text regions (title blocks, component lists, etc.) */ private extractTechnicalTextRegions; /** * Detect lines and electrical connections */ private detectLinesAndConnections; /** * Recognize electrical symbols in the schematic */ private recognizeElectricalSymbols; /** * Extract specific generator monitoring components */ extractGeneratorMonitoringComponents(ocrResult: OCRResult): Promise<any[]>; /** * Batch process multiple pages efficiently */ batchProcessPages(pages: SchematicPage[], options?: EnhancedOCROptions): Promise<Map<number, any>>; /** * Get processing statistics and performance metrics */ getProcessingStats(): { cache_size: number; total_processed: number; average_confidence: number; worker_status: boolean; }; /** * Clear processing cache to free memory */ clearCache(): void; /** * Terminate the OCR service and clean up resources */ terminate(): Promise<void>; } export declare const enhancedOCRService: EnhancedOCRService; //# sourceMappingURL=enhanced-ocr-service.d.ts.map