JSPM

@polina123/node-red-ocr-image-to-text

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q49637F
  • License MIT

Node-RED node for text recognition from images using EasyOCR/PaddleOCR/Tesseract with multi-language support and parallel processing

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@polina123/node-red-ocr-image-to-text) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Node-RED Image OCR (Multi-Engine)

    Node-RED compatible npm version License: MIT

    Node-RED node for automatic text recognition from images using multiple OCR engines: PaddleOCR (default), EasyOCR, and Tesseract. Supports Russian, English, and many other languages. Optimized for maximum performance with image resizing functionality.

    Features

    • Three OCR Engines: PaddleOCR (recommended), EasyOCR, Tesseract
    • Text Recognition from JPG, JPEG, PNG images
    • Multi-language - support for 20+ languages simultaneously
    • Speed Optimization - image resizing before processing
    • Flexible Configuration - choose OCR engine, languages, GPU, quality control
    • Error Handling - detailed processing status information
    • Performance Monitoring - processing time and statistics
    • Batch Processing - multiple images at once

    OCR Engine Comparison

    OCR Engine Installation Speed* Quality Languages Recommendation
    Tesseract System install Fastest (0.5s) Good 100+ languages Best for speed
    EasyOCR pip install Medium (2.3s) Excellent 80+ languages Best quality
    PaddleOCR pip install Slower (4.2s) Good Multilingual Balanced option

    *Test conditions: Single image, CPU, resize_factor 0.5, languages: en+ru

    Performance

    NEW: Parallel Processing

    The node now supports parallel processing of multiple images simultaneously!

    Speedup: up to 8-10x when processing multiple images

    // Example: 10 images processed in parallel
    // Sequential: 20 seconds
    // Parallel (4 threads): ~5 seconds
    Scenario Resize Factor GPU Mode Speed Quality
    Maximum speed 0.3 Yes Parallel Very Fast Medium
    Balanced (recommended) 0.5 Yes Parallel Fast Good
    High quality 0.7 Yes Batch Medium High
    Critical quality 1.0 Yes Sequential Slow Maximum

    Recommendation: Use resize_factor: 0.5 with parallel processing for 8-10x speedup!

    Installation

    1. Open Node-RED
    2. Go to menu → Manage Palette
    3. In the Install tab, search for node-red-image-xocr-to-text
    4. Click Install

    Method 2: Via npm

    cd ~/.node-red
    npm install node-red-image-xocr-to-text

    Method 3: Manual installation for development

    # Clone the repository
    git clone https://github.com/polinaSuvorova/node-red-image-xocr-to-text.git
    cd node-red-image-xocr-to-text
    
    # Create symlink
    npm link
    
    # In Node-RED folder
    cd ~/.node-red
    npm link node-red-image-xocr-to-text

    Installing Python Dependencies

    OCR engines will automatically install dependencies on first use. For manual installation:

    # For all engines
    pip install opencv-python pillow
    
    # PaddleOCR (recommended)
    pip install paddlepaddle paddleocr
    
    # EasyOCR
    pip install easyocr
    
    # Tesseract (requires system installation)
    pip install pytesseract

    Installing Tesseract OCR

    Tesseract requires separate system installation:

    Windows:

    1. Download from https://github.com/UB-Mannheim/tesseract/wiki
    2. Install and add to PATH

    Linux (Ubuntu/Debian):

    sudo apt install tesseract-ocr tesseract-ocr-rus tesseract-ocr-eng

    macOS:

    brew install tesseract

    Usage

    Input Data

    The node expects a JSON object with an array of files:

    {
      "files": [
        {
          "FILENAME": "document.jpg",
          "MIMETYPE": "image/jpeg",
          "FILEBASE64": "base64_encoded_image_data..."
        },
        {
          "FILENAME": "screenshot.png",
          "MIMETYPE": "image/png",
          "FILEBASE64": "base64_encoded_image_data..."
        }
      ]
    }

    Output Data

    {
      "success": true,
      "results": [
        {
          "filename": "document.jpg",
          "mimetype": "image/jpeg",
          "status": "success",
          "text": "Recognized text from image combined into one line",
          "ocr_model": "paddleocr",
          "languages": ["en", "ru"],
          "resize_factor": 0.5,
          "processing_time": 1.23,
          "error": null
        }
      ],
      "processed": 1,
      "total": 1,
      "errors": 0,
      "ocr_model": "paddleocr",
      "languages": ["en", "ru"],
      "resize_factor": 0.5,
      "performance": {
        "total_time": 1.45,
        "average_time_per_image": 1.23,
        "images_per_second": 0.81
      }
    }

    Processing Statuses

    Status Description
    success Text successfully recognized
    no_text No text found in image
    error Error processing image
    unsupported_format Unsupported image format
    no_data No image data provided

    Node Settings

    Parameter Description Default
    Name Node name (optional) -
    OCR Model Choose OCR engine: PaddleOCR, EasyOCR, Tesseract paddleocr
    Languages Languages for recognition (multiple selection) en, ru
    Resize Factor Image resize coefficient (0.1-1.0) 1.0
    Use GPU Use GPU for acceleration (requires CUDA) false

    Supported Languages

    • English (en)
    • Russian (ru)
    • German (de)
    • French (fr)
    • Spanish (es)
    • And many more...

    Usage Examples

    Example 1: Fast processing with optimal settings

    // Node configuration in Node-RED
    {
      "id": "ocr-node",
      "type": "ocr-engine",
      "name": "Fast Recognition",
      "ocr_model": "paddleocr",
      "languages": ["en", "ru"],
      "resize_factor": 0.5,
      "gpu": true
    }

    Example 2: Preparing data for processing

    // JavaScript function to prepare data
    var files = [
      {
        FILENAME: "image1.jpg",
        MIMETYPE: "image/jpeg",
        FILEBASE64: msg.payload.base64data1
      },
      {
        FILENAME: "image2.png",
        MIMETYPE: "image/png",
        FILEBASE64: msg.payload.base64data2
      }
    ];
    
    msg.payload = { files: files };
    return msg;

    Example 3: Processing results with performance metrics

    // After OCR node
    if (msg.payload.success) {
      node.log(`OCR engine: ${msg.payload.ocr_model}`);
      node.log(`Processed ${msg.payload.processed} of ${msg.payload.total} images`);
      node.log(`Total time: ${msg.payload.performance.total_time} sec`);
      node.log(`Speed: ${msg.payload.performance.images_per_second} img/sec`);
    
      msg.payload.results.forEach(function(result) {
        if (result.status === 'success') {
          node.log(`Text from ${result.filename}: ${result.text.substring(0, 100)}...`);
          node.log(`Processing time: ${result.processing_time} sec`);
        } else if (result.status === 'no_text') {
          node.warn(`No text found in ${result.filename}`);
        } else if (result.status === 'error') {
          node.error(`Error in ${result.filename}: ${result.error}`);
        }
      });
    } else {
      node.error('OCR error: ' + msg.payload.error);
    }

    Requirements

    • Node.js >= 14.0.0
    • Node-RED >= 2.0.0
    • Python >= 3.7
    • Memory: ~2GB+ RAM (for recognition models)

    Supported Image Formats

    • JPEG/JPG (.jpg, .jpeg)
    • PNG (.png)

    Troubleshooting

    Error: "Module not found"

    # Reinstall Python dependencies
    pip install --upgrade paddleocr easyocr pytesseract opencv-python pillow

    Error: "GPU not available"

    # Option 1: Install CUDA to use GPU
    # Option 2: Disable "Use GPU" option in node settings

    Slow Performance

    Recommendations:

    1. USE PARALLEL PROCESSING for multiple images
    2. Reduce image size (resize_factor: 0.5)
    3. Use GPU for acceleration (requires CUDA)
    4. Use PaddleOCR instead of EasyOCR
    5. Run performance test: npm run test:async

    Tesseract not found

    Windows:

    Download and install: https://github.com/UB-Mannheim/tesseract/wiki
    Add path to PATH

    Linux:

    sudo apt install tesseract-ocr tesseract-ocr-rus tesseract-ocr-eng

    macOS:

    brew install tesseract

    Development

    Project Structure

    node_red_ocr_image_to_text/
    ├── nodes/
    │   └── ocr-engine/
    │       ├── node_red_ocr_image_to_text.html    # UI configuration
    │       ├── node_red_ocr_image_to_text.js      # Node.js logic
    │       ├── node_red_ocr_image_to_text.py      # Python main script
    │       ├── ocr_engine.py                  # Abstract base class
    │       ├── easyocr_engine.py              # EasyOCR implementation
    │       ├── paddleocr_engine.py            # PaddleOCR implementation
    │       └── tesseract_engine.py            # Tesseract implementation
    ├── test/
    │   ├── .mocharc.json                      # Mocha configuration
    │   ├── sample_test_data.json              # Test data
    │   ├── test_ocr.py                        # Test script
    │   ├── test_performance_comparison.py     # Performance comparison
    │   ├── test_async_performance.py          # Parallel processing test
    │   ├── test_model_switching.py            # Model switching test
    │   ├── node_spec.js                       # Node-RED unit tests
    │   └── README.md                          # Testing documentation
    ├── logs_test/                             # Test logs (in .gitignore)
    │   └── performance_test_results_*.json    # Performance test results
    ├── package.json
    ├── LICENSE
    ├── README.md

    Local Development

    1. Clone the repository
    2. Install dependencies: npm install
    3. Create symlink: npm link
    4. In Node-RED folder: npm link node-red-image-xocr-to-text
    5. Restart Node-RED

    Testing

    # Basic test (requires test/sample_test_data.json)
    npm run test:python
    # or
    python test/test_ocr.py
    
    # Performance comparison of all engines
    npm run test:performance
    # or
    python test/test_performance_comparison.py
    
    # NEW: Parallel vs Sequential processing test
    npm run test:async
    # or
    python test/test_async_performance.py
    
    # Node-RED unit tests
    npm test

    License

    MIT License - see LICENSE file for details.

    Support

    If you have problems or questions:

    Acknowledgments

    Additional Information

    Tesseract Architecture

    Pytesseract is a Python wrapper for Tesseract OCR. Tesseract OCR is a powerful open-source library for optical character recognition (OCR), originally developed by HP and now maintained by Google.

    How it works:

    Python code → pytesseract → Tesseract OCR (system program) → result

    Two-component system:

    • pytesseract (Python package) — installed via pip
    • tesseract (system program) — installed separately in OS

    Author: Polina Suvorova Repository: https://github.com/polinaSuvorova/node-red-image-xocr-to-text