Documentation

This page contains information about Eye 2.

API Documentation

Click here to view the API Documentation.

Examples

Small examples of how to use the Eye 2 API from Java.

public boolean clickImageExample(String imagePath)
{
	// Create an Eye
	Eye eye = new Eye();
	// Load the image to locate
	BufferedImage image = eye.loadImage(imagePath);
	if (image != null)
	{
		// Locate the image
		Match match = eye.findImage(image);
		if (match != null)
		{
			// A match - click in the center of the image
			if(eye.click(match.getCenterLocation()))
			{
				return true;
			}
		}
	}
	return false;
}
public boolean compareImageExample(String imagePath)
{
	// Create an Eye
	Eye eye = new Eye();
	// Load the image to locate
	BufferedImage image = eye.loadImage(imagePath);
	if (image != null)
	{
		// Locate the image and compare if identical
		List rectangles=eye.compare(image);
		if(rectangles.size()>0)
		{
			// There are differences - create an image that shows the differences
			BufferedImage imageDiff=eye.createRectangleImage(image, rectangles, Color.red);
			// Save the image
			Eye.savePngImage(imageDiff, "filediff.png");
			return false;
		}
		// The images are identical
		return true;
	}
	return false;
}
public boolean checkImageExample(String imagePath)
{
	// Create an Eye
	Eye eye = new Eye();
	// Load the image to check
	BufferedImage image = eye.loadImage(imagePath);
	if (image != null)
	{
		// Define a target area that will be checked in detail
		Rectangle targetArea=new Rectangle(0, 0, 20, 20);
		// Locate the image
		Match match = eye.findImage(image, targetArea);
		if (match != null)
		{
			return true;
		}
	}
	return false;
}