Open topic with navigation

com.hp.lft.sdk.utils

## Class ImageUtils

- java.lang.Object
- - com.hp.lft.sdk.utils.ImageUtils

-     public class ImageUtils
      extends java.lang.Object

  A class for image utilities, such as OCR, image comparisons, and image find operations.

- - ### Constructor Summary

    Constructor and Description
    `ImageUtils()`

  - ### Method Summary

    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `compareImages(java.awt.image.RenderedImage firstImage, java.awt.image.RenderedImage secondImage)` Checks whether two images are identical.
    `static boolean` | `compareImages(java.awt.image.RenderedImage firstImage, java.awt.image.RenderedImage secondImage, byte pixelTolerance)` Checks whether two images are a match, given the specified pixel tolerance value.
    `static boolean` | `compareImages(java.awt.image.RenderedImage firstImage, java.awt.image.RenderedImage secondImage, byte pixelTolerance, byte rgbTolerance)` Checks whether two images are a match, given the specified pixel and RGB tolerance values.
    `static boolean` | `compareImages(java.awt.image.RenderedImage firstImage, java.awt.image.RenderedImage secondImage, ImageMaskArea maskArea)` Checks whether the defined mask areas within two images are identical.
    `static boolean` | `compareImages(java.awt.image.RenderedImage firstImage, java.awt.image.RenderedImage secondImage, ImageMaskArea maskArea, byte pixelTolerance)` Checks whether the defined mask areas within two images match, given the specified pixel tolerance value.
    `static boolean` | `compareImages(java.awt.image.RenderedImage firstImage, java.awt.image.RenderedImage secondImage, ImageMaskArea maskArea, byte pixelTolerance, byte rgbTolerance)` Checks whether the defined mask areas within two images match, given the specified pixel and RGB tolerance values.
    `static java.awt.Point[]` | `getImageLocations(java.awt.image.RenderedImage sourceImage, java.awt.image.RenderedImage imageToFind)` Returns the first 100 locations of an image inside the source image, with a default similarity of 100%.
    `static java.awt.Point[]` | `getImageLocations(java.awt.image.RenderedImage sourceImage, java.awt.image.RenderedImage imageToFind, byte similarity)` Returns the first 100 locations of an image inside the source image that meet the provided similarity threshold.
    `static java.lang.String` | `getText(java.awt.image.RenderedImage image)` Returns all text within the supplied image.
    `static java.lang.String` | `getText(java.awt.image.RenderedImage image, java.awt.Rectangle textArea)` Returns all text within the supplied rectangle inside the supplied image.
    `static java.awt.Point` | `locateImage(java.awt.image.RenderedImage sourceImage, java.awt.image.RenderedImage imageToFind)` Locates an image inside the provided source image, with a default similarity of 100%.
    `static java.awt.Point` | `locateImage(java.awt.image.RenderedImage sourceImage, java.awt.image.RenderedImage imageToFind, byte similarity)` Locates an image inside the provided source image.
    `static java.awt.Rectangle[]` | `locateText(java.awt.image.RenderedImage image, java.lang.String textToFind)` Returns all rectangular areas within the supplied image that contain the specified text.
    `static java.awt.Rectangle[]` | `locateText(java.awt.image.RenderedImage image, java.lang.String textToFind, java.awt.Rectangle textArea)` Returns all rectangular areas within the supplied rectangle that contain the specified text.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ImageUtils

          public ImageUtils()

  - ### Method Detail

    - #### getText

          public static java.lang.String getText(java.awt.image.RenderedImage image)
                                          throws GeneralLeanFtException

      Returns all text within the supplied image.
      Parameters:
        `image` - the image to use for the search.
      Returns:
        all text within the supplied image.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### getText

          public static java.lang.String getText(java.awt.image.RenderedImage image,
                                                 java.awt.Rectangle textArea)
                                          throws GeneralLeanFtException

      Returns all text within the supplied rectangle inside the supplied image.
      Parameters:
        `image` - the image to use for the search.
        `textArea` - an inner rectangle within the image.
      Returns:
        all text within the supplied rectangle inside the supplied image.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### locateText

          public static java.awt.Rectangle[] locateText(java.awt.image.RenderedImage image,
                                                        java.lang.String textToFind)
                                                 throws GeneralLeanFtException

      Returns all rectangular areas within the supplied image that contain the specified text.
      Parameters:
        `image` - the image to use for the search.
        `textToFind` - the text string to find.
      Returns:
        all rectangular areas within the supplied image that contain the specified text.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### locateText

          public static java.awt.Rectangle[] locateText(java.awt.image.RenderedImage image,
                                                        java.lang.String textToFind,
                                                        java.awt.Rectangle textArea)
                                                 throws GeneralLeanFtException

      Returns all rectangular areas within the supplied rectangle that contain the specified text.
      Parameters:
        `image` - the image to use for the search.
        `textToFind` - the text string to find.
        `textArea` - an inner rectangle within the image.
      Returns:
        all rectangular areas within the supplied rectangle that contain the specified text.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### locateImage

          public static java.awt.Point locateImage(java.awt.image.RenderedImage sourceImage,
                                                   java.awt.image.RenderedImage imageToFind)
                                            throws GeneralLeanFtException

      Locates an image inside the provided source image, with a default similarity of 100%.
      Parameters:
        `sourceImage` - the source image to check.
        `imageToFind` - the image to locate within the sourceImage.
      Returns:
        the point where the image was located, or null if it was not found.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### locateImage

          public static java.awt.Point locateImage(java.awt.image.RenderedImage sourceImage,
                                                   java.awt.image.RenderedImage imageToFind,
                                                   byte similarity)
                                            throws GeneralLeanFtException

      Locates an image inside the provided source image.
      Parameters:
        `sourceImage` - the source image to check.
        `imageToFind` - the image to locate within the source image.
        `similarity` - the minimum similarity (as a percentage), above which the find is considered successful.
      Returns:
        the point where the image was located, or null if it was not found.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### getImageLocations

          public static java.awt.Point[] getImageLocations(java.awt.image.RenderedImage sourceImage,
                                                           java.awt.image.RenderedImage imageToFind)
                                                    throws GeneralLeanFtException

      Returns the first 100 locations of an image inside the source image, with a default similarity of 100%. If the number of images found exceeds 100 images, an GeneralLeanFtException is thrown.
      Parameters:
        `sourceImage` - the source image to check.
        `imageToFind` - the image to locate within the sourceImage.
      Returns:
        an array of points where the image was located.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### getImageLocations

          public static java.awt.Point[] getImageLocations(java.awt.image.RenderedImage sourceImage,
                                                           java.awt.image.RenderedImage imageToFind,
                                                           byte similarity)
                                                    throws GeneralLeanFtException

      Returns the first 100 locations of an image inside the source image that meet the provided similarity threshold. If the number of images found exceeds 100 images, an GeneralLeanFtException is thrown.
      Parameters:
        `sourceImage` - the source image to check.
        `imageToFind` - the image to locate within the source image.
        `similarity` - the minimum similarity (as a percentage), above which the find is considered successful.
      Returns:
        an array of points where the image was located.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### compareImages

          public static boolean compareImages(java.awt.image.RenderedImage firstImage,
                                              java.awt.image.RenderedImage secondImage)
                                       throws GeneralLeanFtException

      Checks whether two images are identical.
      Parameters:
        `firstImage` - the expected image.
        `secondImage` - the image to compare to the expected image.
      Returns:
        true if the images are identical, else false.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### compareImages

          public static boolean compareImages(java.awt.image.RenderedImage firstImage,
                                              java.awt.image.RenderedImage secondImage,
                                              byte pixelTolerance)
                                       throws GeneralLeanFtException

      Checks whether two images are a match, given the specified pixel tolerance value.
      Parameters:
        `firstImage` - the expected image.
        `secondImage` - the image to compare to the expected image.
        `pixelTolerance` - the percentage of pixels that can differ between the two images, and still be considered a match.
      Returns:
        true if the images match, else false.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### compareImages

          public static boolean compareImages(java.awt.image.RenderedImage firstImage,
                                              java.awt.image.RenderedImage secondImage,
                                              byte pixelTolerance,
                                              byte rgbTolerance)
                                       throws GeneralLeanFtException

      Checks whether two images are a match, given the specified pixel and RGB tolerance values.
      Parameters:
        `firstImage` - the expected image.
        `secondImage` - the image to compare to the expected image.
        `pixelTolerance` - the percentage of pixels that can differ between the two images, and still be considered a match.
        `rgbTolerance` - the percent by which the RGB values of the pixels in the two images can differ, and still be considered a match.
      Returns:
        true if the images match, else false.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### compareImages

          public static boolean compareImages(java.awt.image.RenderedImage firstImage,
                                              java.awt.image.RenderedImage secondImage,
                                              ImageMaskArea maskArea)
                                       throws GeneralLeanFtException

      Checks whether the defined mask areas within two images are identical.
      Parameters:
        `firstImage` - the expected image.
        `secondImage` - the image to compare to the expected image.
        `maskArea` - the mask area within the two images to use for the comparison.
      Returns:
        true if the mask areas within the images are identical and the two full images are the same size, else false.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### compareImages

          public static boolean compareImages(java.awt.image.RenderedImage firstImage,
                                              java.awt.image.RenderedImage secondImage,
                                              ImageMaskArea maskArea,
                                              byte pixelTolerance)
                                       throws GeneralLeanFtException

      Checks whether the defined mask areas within two images match, given the specified pixel tolerance value.
      Parameters:
        `firstImage` - the expected image.
        `secondImage` - the image to compare to the expected image.
        `maskArea` - the mask area within the two images to use for the comparison.
        `pixelTolerance` - the percent by which the RGB values of the pixels in the two images can differ, and still be considered a match.
      Returns:
        true if the mask areas within the images match and the two full images are the same size, else false.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.

    - #### compareImages

          public static boolean compareImages(java.awt.image.RenderedImage firstImage,
                                              java.awt.image.RenderedImage secondImage,
                                              ImageMaskArea maskArea,
                                              byte pixelTolerance,
                                              byte rgbTolerance)
                                       throws GeneralLeanFtException

      Checks whether the defined mask areas within two images match, given the specified pixel and RGB tolerance values.
      Parameters:
        `firstImage` - the expected image.
        `secondImage` - the image to compare to the expected image.
        `maskArea` - the mask area within the two images to use for the comparison.
        `pixelTolerance` - the percentage of pixels that can differ between the two images, and still be considered a match.
        `rgbTolerance` - the percent by which the RGB values of the pixels in the two images can differ, and still be considered a match.
      Returns:
        true if the mask areas within the images match and the two full images are the same size, else false.
      Throws:
        `GeneralLeanFtException` - if an error occurs during execution.