C/C++ OCR and Barcode Recognition

High performance, royalty-free C/C++ OCR and barcode recognition on Windows, Linux, Mac OS and Unix

C/C++ OCR Demos

    Basics

    Programming with Asprise OCR is very straightforward. Below is the typical source code sample in C/C++ to recognize images:

    #include <iostream>
    #include "asprise_ocr_api.h"
    
    void testOcr() {
       const char * libFolder = "LIB_FOLDER";
       LIBRARY_HANDLE libHandle = dynamic_load_aocr_library(libFolder);
    
       // one time setup
       int setup = c_com_asprise_ocr_setup(false);
    
       // starts the ocr engine; the pointer must be of long long type
       long long ptrToApi = c_com_asprise_ocr_start("eng", OCR_SPEED_FAST, NULL, NULL, NULL);
    
       char * s = c_com_asprise_ocr_recognize(ptrToApi, "image.png", -1, -1, -1, -1, -1,
          OCR_RECOGNIZE_TYPE_ALL, OCR_OUTPUT_FORMAT_PDF,
          "PROP_PDF_OUTPUT_FILE=result.pdf|PROP_PDF_OUTPUT_TEXT_VISIBLE=true|\
                PROP_PDF_OUTPUT_RETURN_TEXT=text", "|", "=");
    
       std::cout << "Returned: " << s << std::endl;
    
       // do more recognition here ...
    
       // finally, stops the OCR engine.
       c_com_asprise_ocr_stop(ptrToApi);
    
       dynamic_unload_aocr_library(libHandle);
    }

    With the below sample input image:

    Extract Text and Barcodes in Plain Text Format

    Asprise OCR and Barcode Recognition
    
    High performance, royalty-free OCR and barcode recognition on Windows,
    ...
    ISBN-l3, Interleaved 2 of 5, Code 39, Code 128, PDF417, and QR Code.
    
    [[QR-Code: www.asprise.com]]
    [[CODE-128: Asprise]].

    XML Format Provides Information Like Confidence and Coordinates & Tables

    If you need additional information like accuracy confidence and text coordinates, you can select XML as the output format. Additionally, table information like rows and cells are also available in XML.

    <?xml version="1.0"?>
    <asprise-ocr input="test-image.png">
      <page no="1" width="2400" height="3200" words="124" confidence="92">
        <block type="text"  x="320" y="248" width="1176" height="63" words="5" confidence="88">
    Asprise OCR and Barcode Recognition
        </block>
    ...
        <block type="barcode" subtype="QR-Code" x="1397" y="1647" width="441" height="441">www.asprise.com</block>
        <block type="barcode" subtype="CODE-128" x="348" y="1651" width="583" height="147">Asprise</block>
      </page>
    </asprise-ocr>


    Click here to view the actual XML

    Searchable PDF Combines Original Image and Recognized Text Perfectly

    Asprise OCR supports generating searchable PDF:


    PDF output with recognized text highlighted


    PDF output with transparent text

    Asprise OCR offer property for you to configure whether text should be highlighted or transparent. Please refer to the developer's guide for details.

    User Editable Rich Text Format (RTF)

    Choose RTF format if the user needs to further edit the recognition result in a word processor.


    RTF output


    Read the developer's guide for more details