Table of Contents

Class ImageUtils

Namespace
HP.LFT.SDK.Utils
Assembly
HP.LFT.SDK.dll

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

public class ImageUtils
Inheritance
ImageUtils
Inherited Members

Constructors

ImageUtils()

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.

public static bool CompareImages(Image firstImage, Image secondImage, ImageMaskArea maskArea, byte pixelTolerance = 0, byte rgbTolerance = 0)

Parameters

firstImage Image

The expected image.

secondImage Image

The image to compare to the expected image.

maskArea ImageMaskArea

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

pixelTolerance byte

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

rgbTolerance byte

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

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.

public static bool CompareImages(Image firstImage, Image secondImage, byte pixelTolerance = 0, byte rgbTolerance = 0)

Parameters

firstImage Image

The expected image.

secondImage Image

The image to compare to the expected image.

pixelTolerance byte

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

rgbTolerance byte

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

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.

public static Point[] GetImageLocations(Image sourceImage, Image imageToFind, byte similarity = 100)

Parameters

sourceImage Image

The source image to check.

imageToFind Image

The image to locate within the sourceImage.

similarity byte

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

Returns

Point[]

GetText(Image)

Returns all text within the supplied image.

public static string GetText(Image image)

Parameters

image Image

The image to use for the search.

Returns

string

GetText(Image, Rectangle)

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

public static string GetText(Image image, Rectangle textArea)

Parameters

image Image

The image to use for the search.

textArea Rectangle

An inner rectangle within the image.

Returns

string

LocateImage(Image, Image, byte)

Locates an image inside the provided source image.

public static Point? LocateImage(Image sourceImage, Image imageToFind, byte similarity = 100)

Parameters

sourceImage Image

The source image to check.

imageToFind Image

The image to locate within the sourceImage.

similarity byte

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

Returns

Point?

LocateText(Image, string)

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

public static Rectangle[] LocateText(Image image, string textToFind)

Parameters

image Image

The image to use for the search.

textToFind string

The text string to find.

Returns

Rectangle[]

LocateText(Image, string, Rectangle)

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

public static Rectangle[] LocateText(Image image, string textToFind, Rectangle textArea)

Parameters

image Image

The image to use for the search.

textToFind string

The text string to find.

textArea Rectangle

An inner rectangle within the image.

Returns

Rectangle[]