CAWT 2.5.0 Reference Manual

# ::OcrTop, Main

The `Ocr` namespace provides commands to control Microsoft Document Imaging.

## CommandsOcr, Top, Main

#### Close [::Ocr]Ocr, Top, Main

Close an OCR document instance.

Close docId

`docId` | Identifier of the OCR document.

Returns no value.

See also: Open

Show source

    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]Ocr, Top, Main

Return the recognized text of an OCR layout.

GetFullText layoutId

`layoutId` | Identifier of the OCR layout.

Returns the recognized text of an OCR layout.

See also: Scan

Show source

    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]Ocr, Top, Main

Return the number of images of an OCR document.

GetNumImages docId

`docId` | Identifier of the OCR document.

Returns the number of images of an OCR document.

See also: OpenDocument, Scan

Show source

    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]Ocr, Top, Main

Return the number of words identified in an OCR document.

GetNumWords layoutId

`layoutId` | Identifier of the OCR layout.

Returns the number of words identified in an OCR document.

See also: GetFullText, GetNumImages, Scan

Show source

    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]Ocr, Top, Main

Return the text of a recognized word.

GetWord layoutId wordNum

`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

Show source

    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]Ocr, Top, Main

Return statistics of a recognized word.

GetWordStats layoutId wordNum

`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

Show source

    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]Ocr, Top, Main

Open an OCR document instance.

Open

Returns the OCR document identifier.

See also: OpenDocument, Close

Show source

    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]Ocr, Top, Main

Open an image file for OCR scanning.

OpenDocument docId fileName

`docId` | OCR document identifier.
`fileName` | Image to be scanned. Must be in `TIFF` or `BMP` format.

Returns no value.

See also: Open, Close

Show source

    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]Ocr, Top, Main

Scan an image.

Scan docId ?imgNum?

`docId` | Identifier of the OCR document.
`imgNum` | Image number to be scanned. Optional, default `0`.

Returns the layout identifier of the scanned image.

See also: OpenDocument, GetNumImages, GetFullText

Show source

    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
    }

# Start page

# Cawt

# Office

# Excel

# Ppt

# Word

# Outlook

# OneNote

# Office::Enum

# Excel::Enum

# Ppt::Enum

# Word::Enum

# Outlook::Enum

# OneNote::Enum

# Earth

# Explorer

# Ocr

# Reader

# Matlab

# Ocr

## Commands

#### Close Close an OCR document instance.

#### GetFullText Return the recognized text of an OCR layout.

#### GetNumImages Return the number of images of an OCR document.

#### GetNumWords Return the number of words identified in an OCR document.

#### GetWord Return the text of a recognized word.

#### GetWordStats Return statistics of a recognized word.

#### Open Open an OCR document instance.

#### OpenDocument Open an image file for OCR scanning.

#### Scan Scan an image.

Document generated by Ruff!