CAWT 2.9.1 Reference Manual

::OcrTop, Main, Index

The Ocr namespace provides commands to control Microsoft Document Imaging.

CommandsTop, Main, Index

Close [::Ocr]Top, Main, Index

Close an OCR document instance.

Close docId
docIdIdentifier of the OCR document.

Returns no value.

See also: Open

proc ::Ocr::Close {docId} {

    # Close an OCR document instance.
    #
    # docId - Identifier of the OCR document.
    #
    # Returns no value.
    #
    # See also: Open

    $docId Close
}

GetFullText [::Ocr]Top, Main, Index

Return the recognized text of an OCR layout.

GetFullText layoutId
layoutIdIdentifier of the OCR layout.

Returns the recognized text of an OCR layout.

See also: Scan

proc ::Ocr::GetFullText {layoutId} {

    # Return the recognized text of an OCR layout.
    #
    # layoutId - Identifier of the OCR layout.
    #
    # Returns the recognized text of an OCR layout.
    #
    # See also: Scan

    return [$layoutId Text]
}

GetNumImages [::Ocr]Top, Main, Index

Return the number of images of an OCR document.

GetNumImages docId
docIdIdentifier of the OCR document.

Returns the number of images of an OCR document.

See also: OpenDocument, Scan

proc ::Ocr::GetNumImages {docId} {

    # Return the number of images of an OCR document.
    #
    # docId - Identifier of the OCR document.
    #
    # Returns the number of images of an OCR document.
    #
    # See also: OpenDocument Scan

    return [$docId -with { Images } Count]
}

GetNumWords [::Ocr]Top, Main, Index

Return the number of words identified in an OCR document.

GetNumWords layoutId
layoutIdIdentifier of the OCR layout.

Returns the number of words identified in an OCR document.

See also: GetFullText, GetNumImages, Scan

proc ::Ocr::GetNumWords {layoutId} {

    # Return the number of words identified in an OCR document.
    #
    # layoutId - Identifier of the OCR layout.
    #
    # Returns the number of words identified in an OCR document.
    #
    # See also: GetFullText GetNumImages Scan

    return [$layoutId -with { Words } Count]
}

GetWord [::Ocr]Top, Main, Index

Return the text of a recognized word.

GetWord layoutId wordNum
layoutIdIdentifier of the OCR layout.
wordNumIndex number of the word (starting at zero).

Returns the text of a recognized word.

See also: GetFullText, GetNumWords, Scan

proc ::Ocr::GetWord {layoutId wordNum} {

    # Return the text of a recognized word.
    #
    # layoutId - Identifier of the OCR layout.
    # wordNum  - Index number of the word (starting at zero).
    #
    # Returns the text of a recognized word.
    #
    # See also: GetFullText GetNumWords Scan

    set word [$layoutId -with { Words } Item [expr int($wordNum)]]
    set wordText [$word Text]
    Cawt Destroy $word
    return $wordText
}

GetWordStats [::Ocr]Top, Main, Index

Return statistics of a recognized word.

GetWordStats layoutId wordNum
layoutIdIdentifier of the OCR layout.
wordNumIndex number of the word (starting at zero).

The statistics is returned as a dictionary containing the following keys:

Returns statistics of a recognized word.

See also: GetFullText, GetWord, Scan

proc ::Ocr::GetWordStats {layoutId wordNum} {

    # Return statistics of a recognized word.
    #
    # layoutId - Identifier of the OCR layout.
    # wordNum  - Index number of the word (starting at zero).
    #
    # The statistics is returned as a dictionary containing the
    # following keys:
    # * Id
    # * LineId
    # * RegionId
    # * FontId
    # * Confidence
    #
    # Returns statistics of a recognized word.
    #
    # See also: GetFullText GetWord Scan

    set word [$layoutId -with { Words } Item [expr int($wordNum)]]
    dict set wordStats "Id" [$word Id]
    dict set wordStats "LineId" [$word LineId]
    dict set wordStats "RegionId" [$word RegionId]
    dict set wordStats "FontId" [$word FontId]
    dict set wordStats "Confidence" [$word RecognitionConfidence]
    Cawt Destroy $word
    return $wordStats
}

Open [::Ocr]Top, Main, Index

Open an OCR document instance.

Open

Returns the OCR document identifier.

See also: OpenDocument, Close

proc ::Ocr::Open {} {

            # Open an OCR document instance.
            #
            # Returns the OCR document identifier.
            #
            # See also: OpenDocument Close

    	variable ocrAppName

            set docId [Cawt GetOrCreateApp $ocrAppName true]
            return $docId
}

OpenDocument [::Ocr]Top, Main, Index

Open an image file for OCR scanning.

OpenDocument docId fileName
docIdOCR document identifier.
fileNameImage to be scanned. Must be in TIFF or BMP format.

Returns no value.

See also: Open, Close

proc ::Ocr::OpenDocument {docId fileName} {

    # Open an image file for OCR scanning.
    #
    # docId    - OCR document identifier.
    # fileName - Image to be scanned. Must be in `TIFF` or `BMP` format.
    #
    # Returns no value.
    #
    # See also: Open Close

    $docId Create $fileName
}

Scan [::Ocr]Top, Main, Index

Scan an image.

Scan docId ?imgNum?
docIdIdentifier of the OCR document.
imgNumImage number to be scanned. Optional, default 0.

Returns the layout identifier of the scanned image.

See also: OpenDocument, GetNumImages, GetFullText

proc ::Ocr::Scan {docId {imgNum 0}} {

    # Scan an image.
    #
    # docId  - Identifier of the OCR document.
    # imgNum - Image number to be scanned.
    #
    # Returns the layout identifier of the scanned image.
    #
    # See also: OpenDocument GetNumImages GetFullText

    $docId OCR
    set imgId [$docId -with { Images } Item [expr int($imgNum)]]
    set layoutId [$imgId Layout]
    Cawt Destroy $imgId
    return $layoutId
}