Entity

AI Data Capture SDK

Overview

The Entity interface represents a generic trackable entity within the Zebra AI Data Capture SDK. It defines the methods required for any trackable entity, including retrieving bounding box data, and performing equality checks.Implementations of this interface represent specific types of entities that can be detected and tracked by the vision system.

Use Cases:

  • Object Detection - Implementing Entity for objects detected in images to track their position and maintain metadata.

Methods

getBoundingBox()

    Rect Entity.Rect()

Retrieves the rectangular bounding box of the entity in pixel coordinates, providing a complete enclosure of the detected entity within an image. The bounding box is defined by its left, top, right, and bottom boundaries in absolute pixel coordinates relative to the original image dimensions. This information is valuable for quick collision detection, cropping operations, UI overlay positioning, and spatial analysis.

Return Value: Returns a Rect object representing the bounding box in pixel coordinates, or null if no bounding box is available.

NOTE: The Rect class is essential for graphical operations in Android, allowing developers to define and manipulate rectangular areas within an application’s UI or during drawing operations. The android.graphics.Rect is a class that represents a rectangle in a 2D coordinate system, defined by the coordinates of its top-left and bottom-right corners. It is extensively used for defining drawing boundaries, hit areas, and layout regions in Android applications. Rect holds four integer coordinates that define its edges (left, top, right bottom), which can be accessed directly. Use the width() and height() methods to retrieve the rectangle's width and height.


getCorners()

    List<Point>    getCorners();

Retrieves the corner points of the entity’s bounding box in pixel coordinates. This method returns a list of corner points that define the boundary of the detected entity within the image. The corners are typically returned in clockwise order starting from the top-left corner, with coordinates in absolute pixel values relative to the original image dimensions.

NOTE: android.graphics.Point is a fundamental Android class representing a 2D point with integer coordinates (x, y). The class provides direct access to x and y attributes, along with utility methods like set(int x, int y) for updating coordinates and equals(Object obj) for comparison.

Return Value: Returns a list of Point objects representing the corner coordinates in pixels, or an empty list if no corners are available.


equals(Object obj)

    boolean    Entity.equals(Object obj)

Compares this entity with another entity for equality. This method compares the current entity with another entity of the same type, based on criteria specific to the implementation.

Parameters:

  • obj - The entity to compare with the current entity.

Return Value:

  • true - The entities are considered equal based on implementation-specific criteria
  • false - The entities are not considered equal based on implementation-specific criteria.


hashCode()

    int Entity.hashCode()

Returns the hash code of the trackable object. This method returns the hash code of the trackable object, which is used in hash-based collections. It must be consistent with the equals(Object) method to ensure proper behavior when entities are stored in hash-based collections.

Return Value: Returns the hash code of the entity as an integer.


getAccuracy()

    float Entity.getAccuracy()

Retrieves the detection probability (accuracy) for this entity. This value typically represents the confidence or probability score associated with the detection of this entity.

Return Value: Returns the probability or confidence value for this entity as a float.


BarcodeEntity Class

The BarcodeEntity interface represents a barcode detected within an image. It defines the structure for barcode entities, providing methods to access key barcode properties such as the raw barcode data, symbology type, label type, and detection accuracy. This interface is designed to be used within the context of barcode recognition systems, enabling developers to interact with barcode information in a structured and standardized manner.

Use Cases:

  • Inventory Management: Automate inventory tracking by scanning barcodes from product images to retrieve product details.
  • Retail Checkout Systems: Efficiently process product barcodes in point-of-sale systems, managing transactions and inventory updates.
  • Logistics and Supply Chain: Use barcode scanning to track shipments, verify contents, and ensure accurate delivery.
  • Security and Access Control: Enhance security systems by managing and verifying access credentials encoded in barcodes.
  • Marketing and Promotions: Process QR codes or barcodes for promotional materials, providing links to content or special offers.

Methods

getBoundingBox()

    Rect getBoundingBox()

Retrieves the rectangular bounding box of the barcode entity in pixel coordinates.

Return Value: Returns a Rect object representing the bounding box in pixel coordinates, or null if no bounding box is available.


getCorners()

    List<Point> getCorners()

Retrieves the corner points of the barcode’s bounding box in pixel coordinates.

Return Value: Returns a list of Point objects representing the corner coordinates in pixels, or an empty list if no corners are available.


equals(Object obj)

    boolean    BarcodeEntity.equals(Object obj)

Compares this barcode entity with another for equality based on value, symbology, and corners.

Parameters:

  • obj - The object to compare with this BarcodeEntity.

Return Value:

  • true - The specified object is equal to this entity.
  • false - The specified object is not equal to this entity.


hashCode()

    int    BarcodeEntity.hashCode()

Generates a hash code for this barcode entity based on its value, symbology, and corners.

Return Value: Returns an integer hash code for this barcode entity.


transformBoundingBox(Matrix transformationToTarget)

    boolean    transformBoundingBox(Matrix transformationToTarget)

Transforms the bounding box and corners of the barcode entity to a target coordinate system using the provided matrix.

Parameters: transformationToTarget - The Matrix used for transforming the bounding box and corners.

Return Value:

  • true - The transformation is successful.
  • false - The transformation is not successful.


getValue()

    String BarcodeEntity.getValue()

Retrieves the raw value of the barcode.

Return Value: Returns the barcode’s value as a String.


getSymbology()

    int    BarcodeEntity.getSymbology()

Retrieves the symbology type of the barcode.

Return Value: Returns an integer representing the barcode’s symbology type.


getLabel()

    String BarcodeEntity.getLabel()

Retrieves the label type or symbology of the barcode.

Return Value: Returns a string representing the barcode’s label type.


getAccuracy()

    float BarcodeEntity.getAccuracy()

Calculates and retrieves the accuracy of the barcode detection.

Return Value: Returns a float representing the accuracy of the barcode detection.


updateBoundingBox(Rect rect)

    boolean BarcodeEntity.updateBoundingBox(Rect rect)

Updates the bounding box of the barcode entity.

Parameters:

  • rect - The new Rect to update to.   Return Value: false


updateAccuracy(float accuracy)

    boolean BarcodeEntity.updateAccuracy(float accuracy)

Updates the accuracy of the barcode detection.

Parameters: accuracy - The new accuracy value for the barcode entity.

Return Value: false


setHash (UUID hash)

    boolean    BarcodeEntity.setHash(UUID hash)

Sets the unique hash for the barcode entity.

Parameters:

  • hash - The UUID to set as the hash.

Return Value:

  • true - The hash is set successfully.
  • false - The hash is not set successfully.


isEmpty()

    boolean    BarcodeEntity.isEmpty()

Checks if the barcode entity has an empty value.

Return Value:

  • true - The barcode value is empty.
  • false- The barcode value is not empty.


updateEntity (Entity entity)

    boolean    BarcodeEntity.updateEntity(Entity entity)

Updates the current entity’s value and symbology from another entity.

Parameters: entity - The Entity from which to update the current entity.

Return Value:

  • true - The entity is successfully updated.
  • false - The entity is not successfully updated.


clearEntity()

    public boolean clearEntity()

Clears the value and symbology of the barcode entity.

Return Value:

  • true - The entity was cleared successfully.
  • false - The entity was not cleared successfully.

Sample Code

Explanation of Code Sample:

  1. Process Image Data: The code initiates barcode detection process by calling barcodeDecoder.process, which accepts ImageData as input and returns a list of List<BarcodeEntity> objects representing detected barcodes.
  2. Iterate Over Results: The resulting list is iterated, performing operations on each entity to extract and utilize barcode data.
  3. Access Detection Confidence: The getAccuracy() method is called to retrieve the confidence level of the barcode detection, providing insights into detection reliability.
  4. Check Equality and Hash Code: The code demonstrates how to check equality between entities and retrieve their hash codes using equals() and hashCode(), respectively. Note that equals() requires a parameter of the same type for comparison.
  5. Access Bounding Box: The getBoundingBox() method obtains the dimensions of the barcode within the image.
  6. Type Cast to BarcodeEntity: The entity is type-casted to BarcodeEntity to access barcode-specific methods like getValue() and getSymbology(), which are essential for barcode data extraction.
  7. Access Barcode Data: Barcode-specific information such as the decoded value and symbology type is accessed for further processing or storage.

Sample Code:

    List<BarcodeEntity> resultList = barcodeDecoder.process(ImageData.fromImageProxy(image));

    for (BarcodeEntity entity:resultList) {
        // Access detection confidence
        float confidence = entity.getAccuracy();

        // Check equality (method requires a parameter, here it's assumed another entity for comparison)
        boolean isEqual = entity. equals(); // Note: Correct usage requires passing another entity

        // Retrieve hash code
        int hashcode = entity. hashcode();

        // Access bounding box
        BoundingBox boundingBox = entity. getBoundingBox();

        // Type cast Entity to BarcodeEntity for specific operations
        BarcodeEntity barcodeentity = (BarcodeEntity) entity;

        // Access barcode-specific data
        String value = barcodeentity.getvalue();
        Int symbology = barcodeentity.getSymbology();
        String label_type = barcodeentity.getLabel(); 
    }

LocalizerEntity Class

The LocalizerEntity class represents an entity detected by a Localizer, encapsulating details such as the object’s bounding box and its location within the image. This class offers methods for accessing and updating bounding box information, managing custom user data, and performing equality checks. It implements both the LocalizerEntity and MutableEntity interfaces.

Use Cases:

  • Object Detection and Classification: Detect and classify objects within images, providing precise location and category information for each detected entity.
  • Augmented Reality Applications: Anchor digital content to real-world objects based on their location and classification in AR systems.
  • Robotics and Navigation: Enable robots to navigate and interact with their environment by recognizing and classifying objects.
  • Security and Surveillance: Monitor and track objects of interest in security systems to enhance threat detection and response capabilities.
  • Retail and Inventory Management: Automate the identification and location of products within a store or warehouse for inventory tracking and management.

Methods

getBoundingBox()

    Rect LocalizerEntity.getBoundingBox()

Retrieves the rectangular bounding box of the entity in pixel coordinates. This method returns a rectangle that completely encloses the detected entity within the image.

Return Value: Returns a Rect object representing the bounding box in pixel coordinates, or null if no bounding box is available.


getCorners()

    List<Point>    LocalizerEntity.getCorners()

Retrieves the corner points of the entity’s bounding box in pixel coordinates. The corners are returned in a list, typically in clockwise order starting from the top-left corner.

Return Value: Returns a list of Point objects representing the corner coordinates in pixels, or an empty list if no corners are available.


equals(Object obj)

    boolean    LocalizerEntity.equals(Object obj)

Compares this entity with another object for equality. This method considers two entities equal if their bounding box data, probability, and class ID match.

Parameters: obj - The object to compare with this LocalizerEntity.

Return Value:

  • true - The specified object is equal to this entity.
  • false - The specified object is not equal to this entity.


hashCode()

    int    LocalizerEntity.hashCode()

Returns a hash code value for this entity. The hash code is based on the bounding box, probability, and class ID.

Return Value: Returns an integer hash code for this entity.


getAccuracy()

    float LocalizerEntity.getAccuracy()

Retrieves the detection probability (accuracy) for this entity.

Return Value: Returns the probability value as a float.


getClassId()

    int LocalizerEntity.getClassId()

Retrieves the class ID for this entity.

Return Value: Returns the class ID as an integer.


updateBoundingBox(Rect rect)

    boolean    LocalizerEntity.updateBoundingBox(Rect rect)

Updates the current bounding box with a new one.

Parameters: rect - The new Rect to update the bounding box to.

Return Value:

  • true - The bounding box was updated.
  • false - The bounding box was not updated.


updateAccuracy(float accuracy)

    boolean    LocalizerEntity.updateAccuracy(float accuracy)

Updates the accuracy of the entity.

Parameters: accuracy - The new accuracy value.

Return Value: false


calcBoundingBoxArea()

    float LocalizerEntity.calcBoundingBoxArea()

Calculates the area of the bounding box.

Return Value: Returns the area of the bounding box as a float, or -1 if the bounding box is invalid.


isEmpty()

    boolean    LocalizerEntity.isEmpty()

Checks if the bounding box area is zero or negative, indicating an invalid or empty entity.

Return Value:

  • true - The bounding box area is less than or equal to zero.
  • false - The bounding box area is greater than zero.


updateEntity(Entity entity)

    boolean    LocalizerEntity.updateEntity(Entity entity)

Updates the current entity with values from another entity.

Parameters: entity - This parameter is used to update the current entity.

Return Value:

  • true - The entity is successfully updated.
  • false - The entity is not successfully updated.


clearEntity()

    boolean    clearEntity()

Clears the entity’s data. Currently a placeholder that always returns true.

Return Value: true


setHash(UUID hash)

    boolean LocalizerEntity.setHash(UUID hash)

Sets a unique hash identifier for the entity.

Parameters: hash - The UUID to set as the hash.

Return Value:

  • true - The hash is set successfully.



Sample Code

Explanation of Code Sample:

  1. Process Image Data: The code processes an image with the localizer.process() method, which accepts ImageData as input and returns a list of Entity<LocalizerEntity> objects.
  2. Iterate Over Results: The resulting list is iterated over, and various operations are performed on each entity to extract and utilize localization data.
  3. Access Detection Confidence: The getAccuracy() method is called to obtain the confidence level of the detection, offering insights into the reliability of the localization.
  4. Check Equality and Hash Code: The code demonstrates how to check equality between entities and retrieve their hash codes using equals() and hashCode(), respectively. Note that equals() requires a parameter of the same type for comparison.
  5. Access Bounding Box: The getBoundingBox() method is used to obtain the spatial location and dimensions of the localized entity within the image.
  6. Type Cast to LocalizerEntity: The entity is type-cast to LocalizerEntity to access specific methods like getAccuracy() and getClassId(), which are essential for extracting localization data.
  7. Access Localizer Data: Localizer-specific information such as detection confidence and class ID is accessed for further processing or classification.

Sample Code:

    List<LocalizerEntity> resultList = localizer.process(ImageData.fromImageProxy(image));

    for (LocalizerEntity entity: resultList) {
        // Access detection confidence
        float confidence = entity.getAccuracy();

        // Check equality (method requires a parameter, here it's assumed another entity for comparison)
        boolean isEqual = entity.equals(); // Note: Correct usage requires passing another entity

        // Retrieve hash code
        int hashcode = entity. hashcode();

        // Access bounding box
        BoundingBox boundingBox = entity.getBoundingBox();

        //Access probability of barcode 
        float value = entity.getAccuracy(); 

        // Typecast Entity to LocalizerEntity for specific operations 
        LocalizerEntity localizerentity = (LocalizerEntity)entity;

        // Access barcode-specific data
        Int getClassId = localizerentity.getClassId ();
    }

ParagraphEntity Class

The ParagraphEntity class represents a paragraph of text detected in an image. It encapsulates information about a detected text paragraph, including its bounding box and component lines. The class provides access to the individual line entities that make up the paragraph.

Use Cases:

  • Document Digitization: Digitize and analyze printed or handwritten documents, extracting structured text information for digital storage or processing.
  • Content Management Systems: Automate the organization and indexing of text from scanned documents in content management applications.
  • Text Analysis and Summarization: Analyze and summarize text content, facilitating tasks such as data extraction, summarization, and sentiment analysis.
  • Optical Character Recognition (OCR): Enhance text recognition accuracy in OCR systems by leveraging structured paragraph data.
  • Educational Tools: Assist in reading comprehension and analysis in educational software, providing tools for students to interact with text in images.

Methods

getBoundingBox()

    Rect ParagraphEntity.getBoundingBox()

Retrieves the rectangular bounding box of the paragraph entity in pixel coordinates. This method returns a rectangle that completely encloses the detected entity within the image.

Return Value: Returns a Rect object representing the bounding box in pixel coordinates, or null if no bounding box is available.


getCorners()

    List<Point> getCorners()

Retrieves the corner points of the paragraph’s bounding box in pixel coordinates. The corners are returned in a list, typically in clockwise order starting from the top-left corner.

Return Value: Returns a list of Point objects representing the corner coordinates in pixels, or an empty list if no corners are available.


equals(Object obj)

    boolean    ParagraphEntity.equals(Object obj)

Compares this paragraph entity with another object for equality. This method considers two entities equal if their text content, bounding box, line entities, and probability match.

Parameters:

  • obj - The object to compare with this ParagraphEntity.

Return Value:

  • true - The specified object is equal to this entity.
  • false - The specified object is not equal to this entity.


hashCode()

    int    ParagraphEntity.hashCode()

Returns a hash code value for this text paragraph entity. The hash code is based on the text content, bounding box, line entities, and probability.

Return Value: Returns an integer hash code for this entity.


getTextParagraph()

    Paragraph ParagraphEntity.getTextParagraph()

Retrieves the underlying Paragraph object that contains the raw paragraph data.

Return Value: Returns the Paragraph object for this entity.


getLineEntities()

    List<Entity> ParagraphEntity.getLineEntities()

Retrieves the list of line entities that make up this text paragraph. Returns an unmodifiable list of line entities to prevent modification of the paragraph’s structure.

Return Value: List<Entity>: Returns an unmodifiable list of line entities within the text paragraph.


getAccuracy()

    float ParagraphEntity.getAccuracy()

Retrieves the detection probability (accuracy) for this paragraph entity.

Return Value: Returns a float value representing the detection probability.


Sample Code

Explanation of Code Sample:

  1. Process Image Data: Use the textocr.process() method to extract a list of List<ParagraphEntity> objects from ImageData, resulting in a list of various text entities.
  2. Iterate Over Results: The resulting list is iterated through, performing operations on each entity to extract and utilize paragraph data.
  3. Access Detection Confidence: The getAccuracy() method is called to retrieve the confidence level of the paragraph detection, providing insights into the reliability of the recognition.
  4. Check Equality and Hash Code: The code demonstrates how to check equality between entities and retrieve their hash codes using equals() and hashCode(). Note that equals() requires a parameter of the same type for comparison.
  5. Access Bounding Box: The getBoundingBox() method retrieves the dimensions of the paragraph within the image.
  6. Type Cast to ParagraphEntity: The entity is type-casted to ParagraphEntity to access specific methods like getTextParagraph() and getLineEntities(), which are essential for paragraph data extraction.
  7. Access Paragraph Data: Paragraph-specific information, such as the raw paragraph data and list of line entities, is accessed for further processing or analysis.

Sample Code:

    List<ParagraphEntity> resultList = textocr.process(ImageData.fromImageProxy(image)).get();
    for (ParagraphEntity entity: resultList) {
        // Access detection confidence
        float confidence = entity.getAccuracy();

        // Check equality (method requires a parameter, here it's assumed another entity for comparison)
        boolean isEqual = entity. equals();// Note: Correct usage requires passing another entity

        // Retrieve hash code
        int hashcode = entity. hashcode();

        // Access bounding box
        Rect boundingBox = entity. getBoundingBox();

        // Access paragraph-specific data
        OCR.Paragraph para = paragraphentity.getTextParagraph()
        List<LineEntity> lineEntity = paragraphentity.getLineEntities()
    }

LineEntity Class

The LineEntity class represents a line of text detected within an image. It encapsulates information such as the line’s bounding box and its component words. This class provides methods to access the individual word entities that compose the line and allows for the storage of custom user data associated with it.

Use Cases:

  • Document Processing: Extract and analyze lines of text from documents to support tasks such as indexing, searching, and archiving text data.
  • Optical Character Recognition (OCR): Improve text recognition accuracy and deliver structured output for further processing.
  • Text Layout Analysis: Analyze and understand text layout within documents to aid in reconstructing document structure.
  • Transcription Services: Convert scanned text lines into editable and searchable digital text for transcription applications.
  • Language Learning Tools: Assist learners in analyzing and understanding text lines with educational software, offering tools for language learning and comprehension.

Methods

getBoundingBox()

    Rect LineEntity.getBoundingBox()

Retrieves the rectangular bounding box of the line entity in pixel coordinates. This method returns a rectangle that completely encloses the detected entity within the image.

Return Value: Returns a Rect object representing the bounding box in pixel coordinates, or null if no bounding box is available.


getCorners()

    List<Point> getCorners()

Retrieves the corner points of the line’s bounding box in pixel coordinates. The corners are returned in a list, typically in clockwise order starting from the top-left corner.

Return Value: Returns a list of Point objects representing the corner coordinates in pixels, or an empty list if no corners are available.


equals(Object obj)

    boolean LineEntity.equals(Object obj)

Compares this line entity with another line entity for equality. Two line entities are considered equal if their text content, bounding box, word entities, and bounding box probability are all equal.

Parameters:

  • obj - The object to compare with this LineEntity.

Return Value:

  • true - The specified object is equal to this entity.
  • false - The specified object is not equal to this entity.


hashCode()

    int    LineEntity.hashCode()

Returns a hash code value for this text line entity. The hash code is based on the text content, bounding box, word entities, and probability.

Return Value: Returns an integer hash code for this entity.


getTextLine()

    Line LineEntity.getTextLine()

Retrieves the underlying Line object that contains the raw text line data.

Return Value: Returns the Line object for this entity.


getWordEntities()

    List<Entity> LineEntity.getWordEntities()

Retrieves the list of word entities that make up this text line. Returns an unmodifiable list of word entities to prevent modification of the line’s structure.

Return Value: List<Entity>: Returns an unmodifiable list of word entities in this text line.


getAccuracy()

    float LineEntity.getAccuracy()

Retrieves the detection probability (accuracy) for this line entity.

Return Value: Returns the probability value as a float.


Sample Code

Explanation of Code Sample:

  1. Iterate Over Results: The code iterates over a list of List<Entity> objects, each representing a detected line of text.
  2. Access Detection Confidence: The getAccuracy() method is called to retrieve the confidence level of line detection, providing insights into the reliability of the recognition.
  3. Check Equality and Hash Code: The code demonstrates how to check equality between entities and retrieve their hash codes using equals() and hashCode(). Note that equals() requires a parameter of the same type for comparison.
  4. Access Bounding Box: The getBoundingBox() method retrieves the dimensions of the line within the image.
  5. Type Cast to LineEntity: The entity is type-casted to LineEntity to access specific methods like getTextLine() and getWordEntities(), which are essential for line data extraction.
  6. Access Line Data: Line-specific information such as raw line data and the list of word entities is accessed for further processing or analysis.

Sample Code:

    for (List<LineEntity>entity:resultList) {
        // Access detection confidence
        float confidence = entity.getAccuracy();
        // Check equality (method requires a parameter, here it's assumed another entity for comparison)
        boolean isEqual = entity.equals();// Note: Correct usage requires passing another entity
        // Retrieve hash code
        int hashcode = entity. hashcode();

        // Access bounding box
        BoundingBox boundingBox = entity. getBoundingBox();

        // Type cast Entity to LineEntity for specific operations
        LineEntity lineEntity = (LineEntity) entity;

        // Access line-specific data
        OCR.Line line = lineEntity.getTextLine();
        List<wordEntity>wordEntity = lineEntity.getWordEntities();
    }

WordEntity Class

The WordEntity class represents a word detected within an image. It encapsulates information about a detected word, such as its bounding box and decoded text alternatives. This class allows access to the individual decoded text entities that form the word and supports the storage of custom user data linked to the word.

Use Cases:

  • Text Recognition and Processing: Extract and analyze words from images, facilitating tasks such as text recognition, indexing, and searching.
  • Document Digitization: Convert scanned documents into editable and searchable text formats within digitization workflows.
  • Optical Character Recognition (OCR): Enhance text recognition accuracy and deliver structured word-level output in OCR systems for further processing.
  • Language Learning Applications: Assist learners in analyzing and understanding words with educational software, providing tools for language learning and comprehension.
  • Data Extraction from Forms: Extract text data from structured forms to enable automated data entry and processing.

Methods

getCorners()

    List<Point>    getCorners()

Retrieves the corner points of the word’s bounding box in pixel coordinates. The corners are returned in a list, typically in clockwise order starting from the top-left corner.

Return Value: Returns a list of Point objects representing the corner coordinates in pixels, or an empty list if no corners are available.


getBoundingBox()

    Rect WordEntity.getBoundingBox()

Retrieves the rectangular bounding box of the word entity in pixel coordinates. This method returns a rectangle that completely encloses the detected entity within the image.

Return Value: Returns a Rect object representing the bounding box in pixel coordinates, or null if no bounding box is available.


equals(Object obj)

    boolean    WordEntity.equals(Object obj)

Compares this word entity with another object for equality. Two word entities are considered equal if their text content, bounding box, decoded text entities, and bounding box probability are all equal.

Parameters:

  • obj - The object to compare with this WordEntity.

Return Value:

  • true - The specified object is equal to this entity.
  • false - The specified object is equal to this entity.


hashCode()

    int    WordEntity.hashCode()

Returns a hash code value for this word entity. The hash code is generated based on the decoded text content if available, otherwise based on the bounding box.

Return Value: Returns an integer hash code for this entity.


getWord()

    Word WordEntity.getWord()

Retrieves the underlying Word object that contains the raw word data.

Return Value: Returns the Word object for this entity.


getDecodedTextEntities()

    List<DecodedTextEntity> WordEntity.getDecodedTextEntities()

Retrieves the list of decoded text entities that represent alternative interpretations of this word. Returns an unmodifiable list of decoded text entities to prevent modification of the word’s interpretations.

Return Value: List<DecodedTextEntity> - Returns an unmodifiable list of decoded text entities for this word.


getAccuracy()

    float WordEntity.getAccuracy()

Retrieves the detection probability (accuracy) for this word entity.

Return Value: Returns the probability value as a float.


Sample Code

Explanation of Code Sample:

  1. Iterating Over Results: The code iterates over a list of Entity objects, each representing a detected word.

  2. Accessing Detection Confidence: The getAccuracy method is called to retrieve the confidence level of the word detection, providing insights into the reliability of the recognition.

  3. Checking Equality and Hash Code: The code demonstrates how to check equality between entities and retrieve their hash codes using equals and hashCode, respectively. Note that the equals method requires a parameter of the same type to compare against.

  4. Accessing Bounding Box: The getBoundingBox method retrieves the spatial location and dimensions of the word within the image.

  5. Type Casting to WordEntity: The entity is type-casted to WordEntity to access specific methods like getWord and getDecodedTextEntities, which are essential for word data extraction.

  6. Accessing Word Data: Finally, word-specific information such as the raw word data and list of decoded text entities is accessed, enabling further processing or analysis.

  7. Iterate Over Results: The code processes a list of List<WordEntity> objects, with each object representing a detected word.

  8. Access Detection Confidence: The getAccuracy() method is invoked to retrieve the confidence level of word detection, providing insights into the reliability of the recognition.

  9. Check Equality and Hash Code: The code demonstrates how to check equality between entities and retrieve their hash codes using equals() and hashCode(). Note that equals() requires a parameter of the same type for comparison.

  10. Access Bounding Box: The getBoundingBox() method retrieves the dimensions of the word within the image.

  11. Type Cast to WordEntity: The entity is cast to WordEntity to access specific methods like getWord() and getDecodedTextEntities(), which are essential for extracting word data.

  12. Access Word Data: Specific word-related information, such as raw word data and the list of decoded text entities, is accessed for further processing or analysis.   Sample Code:

    for (List<WordEntity> entity: resultList) {
        // Access detection confidence
        float confidence = entity.getAccuracy();
    
    
    // Check equality (method requires a parameter, here it's assumed another entity for comparison)
    boolean isEqual = entity. equals();// Note: Correct usage requires passing another entity
    
    // Retrieve hash code
    int hashcode = entity. hashcode();
    
    // Access bounding box
    BoundingBox boundingBox = entity. getBoundingBox();
    
    // Type cast Entity to BarcodeEntity
    WordEntity wordentity = (WordEntity) entity;
    
    // Access word-specific data
    OCR.word word = wordentity. getWord ()
    List&lt;Entity&lt;DecodedTextEntity&gt;&gt;decodedtextentity = wordentity. getDecodedTextEntities ()
    
    }

DecodedTextEntity Class

The DecodedTextEntity class represents a decoded text entity that encapsulates information about the text, including its content and confidence level. This class offers methods to access the raw decoded text data and allows for the storage of custom user data associated to the text entity.

Use Cases:

  • Text Recognition and Analysis Extract and analyze text from images, facilitating tasks such as text recognition, indexing, and searching.
  • Document Digitization: Convert scanned documents into editable and searchable text formats within digitization workflows.
  • Optical Character Recognition (OCR): Improve text recognition accuracy and provide structured output for further processing in OCR systems.
  • Data Extraction: Extract text data from forms or documents to enable automated data entry and processing.
  • Language Processing: Store and retrieve language information or custom metadata for each decoded text entity to enhance text processing workflows.

Methods

getBoundingBox()

    Rect DecodedTextEntity.getBoundingBox()

Retrieves the rectangular bounding box of the entity in pixel coordinates. For decoded text entities, this method always returns null since decoded text typically doesn’t include spatial position information.

Return Value:

  • Rect - The pixel coordinates of the rectangular bounding box.
  • null - The decoded text entities do not have bounding boxes.


getCorners()

    List<Point> getCorners()

Retrieves the corner points of the entity’s bounding box in pixel coordinates. For decoded text entities, this method always returns null since decoded text typically do not include spatial position information.

Return Value: Returns null since decoded text entities do not have corner coordinates.


equals(Object obj)

    boolean    DecodedTextEntity.equals(Object obj)

Compares this text entity with another object for equality. Two decoded text entities are considered equal if their text content and confidence are equal.

Parameters: obj - The object to compare with this DecodedTextEntity.

Return Value:

  • true - The specified object is equal to this entity.
  • false - The specified object is not equal to this entity.


hashCode()

    int    DecodedTextEntity.hashCode()

Returns a hash code value for this text entity. The hash code is generated based on the text content and confidence.

Return Value: Returns an integer hash code for this entity.  

getDecodedText()

    DecodedText DecodedTextEntity.getDecodedText()

Retrieves the underlying DecodedText object that contains the raw text data.

Return Value: Returns the DecodedText object for this entity.


getAccuracy()

    float DecodedTextEntity.getAccuracy()

Retrieves the detection probability (accuracy) for this decoded text entity.

Return Value: Returns the confidence value as a float.


updateBoundingBox (Rect rect)

    boolean DecodedTextEntity.updateBoundingBox(Rect rect)

Updates the bounding box for the entity. This method always returns false as decoded text entities don’t have a bounding box.

Parameters: rect - The Rect that updates the bounding box.

Return Value: Always returns false.


updateAccuracy (float accuracy)

    boolean DecodedTextEntity.updateAccuracy(float accuracy)

Updates the accuracy (confidence) of the decoded text entity.

Parameters: accuracy - The new confidence value to set.

Return Value: Returns a boolean true, indicating the accuracy is successfully updates.


isEmpty()

    public DecodedTextEntity.boolean isEmpty()

Checks if the decoded text entity is empty, i.e., has no content and zero confidence.

Return Value: Boolean:

  • true - The confidence is less than or equal to zero and the content is empty.
  • false - The confidence is greater than zero and the content is not empty.


updateEntity (Entity entity)

    boolean    DecodedTextEntity.updateEntity(Entity entity)

Updates the current entity with values from another entity.

Parameters: entity - The current entity updated.

Return Value: Boolean:

  • true - The entity is successfully updated.
  • true - The entity is not successfully updated.


clearEntity

    boolean    clearEntity()

Clears the content and confidence of the decoded text entity.

Return Value: Returns true after clearing the entity.


setHash (UUID hash)

    boolean    DecodedTextEntity.setHash(UUID hash)

Sets a unique hash for this entity.

Parameters:

  • hash - The UUID to set as the hash.

Return Value: Returns boolean true when the hash is successfully set.


Sample Code

Explanation of Code Sample:

  1. Iterate Over Results: The code processes a list of List<DecodedTextEntity> objects, each representing a piece of decoded text from the image.
  2. Access Detection Confidence: The getAccuracy() method retrieves the confidence level of the decoded text, offering insights into the reliability of the text extraction.
  3. Check Equality and Hash Code: The code demonstrates how to check equality between entities and obtain their hash codes using equals() and hashCode(). Note that equals() requires a parameter of the same type for comparison.
  4. Access Bounding Box: The getBoundingBox() method retrieves the dimensions of the decoded text within the image. However, for DecodedTextEntity, the bounding box may not apply, and this step could return null.
  5. Type Cast to DecodedTextEntity: The entity is cast to DecodedTextEntity to access specific methods like getDecodedText(), which are essential for extracting text data.
  6. Access Decoded Text Data: Specific information related to the decoded text is accessed, enabling further processing or analysis of the extracted text.

Sample Code:

    for (List<DecodedTextEntity> entity: resultList) {
        // Access detection confidence
        float confidence = entity.getAccuracy();

        // Check equality (method requires a parameter, here it's assumed another entity for comparison)
        boolean isEqual = entity. equals();// Note: Correct usage requires passing another entity

        // Retrieve hash code
        int hashcode = entity. hashcode();

        // Access bounding box
        BoundingBox boundingBox = entity. getBoundingBox();

        // Type cast Entity to DecodedTextEntity for specific operations
        DecodedTextEntity decodedtextentity = (DecodedTextEntity) entity;

        // Access decoded text-specific data
        OCR.DecodedText decodedtext = decodedtextentity. getDecodedText ()
    }