Table of Contents

Class ImageUtils

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

Inheritance
ImageUtils
Namespace: HP.LFT.SDK.Utils
Assembly: HP.LFT.SDK.dll
Syntax
public class ImageUtils

Constructors

ImageUtils()

Declaration
public ImageUtils()

Methods

CompareImages(Image, Image, ImageMaskArea, byte, byte)

Checks whether the defined mask areas within two images match, given the specified pixel and RGB tolerance values.

Declaration
public static bool CompareImages(Image firstImage, Image secondImage, ImageMaskArea maskArea, byte pixelTolerance = 0, byte rgbTolerance = 0)
Parameters
Type Name Description
Image firstImage

The expected image.

Image secondImage

The image to compare to the expected image.

ImageMaskArea maskArea

The mask area within the two images to use for the comparison.

byte pixelTolerance

Optional. The percentage of pixels that can differ between the two mask areas, and still be considered a match. Default = 0.

byte rgbTolerance

Optional. The percent by which the RGB values of the pixels in the two images can differ, and still be considered a match. Default = 0.

Returns
Type Description
bool
Remarks

Returns true only if the mask areas match and the two provided images are the same size.

CompareImages(Image, Image, byte, byte)

Checks whether two images are a match, given the specified pixel and RGB tolerance values.

Declaration
public static bool CompareImages(Image firstImage, Image secondImage, byte pixelTolerance = 0, byte rgbTolerance = 0)
Parameters
Type Name Description
Image firstImage

The expected image.

Image secondImage

The image to compare to the expected image.

byte pixelTolerance

Optional. The percentage of pixels that can differ between the two images, and still be considered a match. Default = 0.

byte rgbTolerance

Optional. The percent by which the RGB values of the pixels in the two images can differ, and still be considered a match. Default = 0.

Returns
Type Description
bool

GetImageLocations(Image, Image, byte)

Returns the first 100 locations of an image inside the source image. If the number of images found exceeds 100 images, a GeneralReplayException is thrown.

Declaration
public static Point[] GetImageLocations(Image sourceImage, Image imageToFind, byte similarity = 100)
Parameters
Type Name Description
Image sourceImage

The source image to check.

Image imageToFind

The image to locate within the sourceImage.

byte similarity

Optional. The minimum similarity (as a percentage) above which the find is considered successful. Default = 100.

Returns
Type Description
Point[]

GetText(Image)

Returns all text within the supplied image.

Declaration
public static string GetText(Image image)
Parameters
Type Name Description
Image image

The image to use for the search.

Returns
Type Description
string

GetText(Image, Rectangle)

Returns all text within the supplied rectangle inside the supplied image.

Declaration
public static string GetText(Image image, Rectangle textArea)
Parameters
Type Name Description
Image image

The image to use for the search.

Rectangle textArea

An inner rectangle within the image.

Returns
Type Description
string

LocateImage(Image, Image, byte)

Locates an image inside the provided source image.

Declaration
public static Point? LocateImage(Image sourceImage, Image imageToFind, byte similarity = 100)
Parameters
Type Name Description
Image sourceImage

The source image to check.

Image imageToFind

The image to locate within the sourceImage.

byte similarity

Optional. The minimum similarity (as a percentage) above which the find is considered successful. Default = 100.

Returns
Type Description
Point?

LocateText(Image, string)

Returns all rectangle areas within the supplied image that contain the specified text.

Declaration
public static Rectangle[] LocateText(Image image, string textToFind)
Parameters
Type Name Description
Image image

The image to use for the search.

string textToFind

The text string to find.

Returns
Type Description
Rectangle[]

LocateText(Image, string, Rectangle)

Returns all rectangle areas within the supplied rectangle that contain the specified text.

Declaration
public static Rectangle[] LocateText(Image image, string textToFind, Rectangle textArea)
Parameters
Type Name Description
Image image

The image to use for the search.

string textToFind

The text string to find.

Rectangle textArea

An inner rectangle within the image.

Returns
Type Description
Rectangle[]