Need Image recognition sample

Ask general questions here.
Posts: 8
Joined: Mon May 19, 2008 2:35 pm

Need Image recognition sample

Post by palanikumar.m » Sat Jun 28, 2008 1:39 pm


How to do image recognition? please explain me briefly with example...

Kindly reply me ASAP.

Thanks & regards,

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Post by Support Team » Tue Jul 01, 2008 8:48 am

You can find the following source samples in the RanorexNet API documentation:

The following sample searches the image "TrackBar.bmp" in the ToolStrip and returns the location of the first pixel in the control if the image could be found. The sample uses the CompareImage function to demonstrate how to compare an image loaded from a file with an other image in the control.

Code: Select all

Point point;
if (toolStrip.FindImage("TrackBar.bmp", out point) == true)
    Point offset = new Point(point.X - toolStrip.Location.X, point.Y - toolStrip.Location.Y);
    Console.WriteLine("ToolStrip Image \"TrackBar.bmp\" found at Location= {0} Offset= {1}", point, offset);
    if (toolStrip.CompareImage("TrackBar.bmp", offset) == true)
        Console.WriteLine("ToolStrip ImageCompare OK");
The following example searches and compares the image "MyImage.bmp" in the first subitem of a ListView.

Code: Select all

for (int index = 1; index < itemCount; index++)
    Point location = listView.GetSubItemLocation(index, 1, false);
    Size size = listView.GetSubItemSize(index, 1, false);
    string imageFileName = "MyImage.bmp";
    Point point;
    if (listView.FindImage(imageFileName, out point, location, size) == true)
        Console.WriteLine("  Image found Index={0} Name={1} {2} {3}", index, listView.GetItemText(index, 0), location, size);
        Point offset = new Point(point.X - listView.Location.X, point.Y - listView.Location.Y);
        if ( listView.CompareImage(imageFileName, offset) == true )
            Console.WriteLine("    Image compare OK");
        Mouse.Click(MouseButtonType.LeftButton, point.X, point.Y);
The sample uses the FindImage and ComparaImage functions.

Ranorex Team