User Tools

Site Tools


Sidebar



en:objects:image:tools:get_x_of_image

get_x_of_image

get_x_of_image($src_path,$image_path,$koeff=0.95); - get the x - coordinate of the occurrence of the specified image available since version 4.9.29

The function accepts parameters as input:br>
  • $src_path – the path to the original image (may be relative)
  • $image_path – the path to the picture, the entry of which is necessary to find (can be relative)
  • $koeff – image similarity coefficient (from 0.1 to 1)

    After testing, the function returns the result of its work to the script :
  • x-coordinate – x-coordinate of occurrence of the specified image in the original
  • false – operation failed (boolean)

    PHP example:

    <?php $xhe_host = "127.0.0.1:7014";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
      $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> image->".basename(__FILE__)."</font> <hr>";
     
    //1
    echo "1.Let's go to the polygon:";
    echo $browser->navigate("http://bigfozzy.com")."<br>";
    sleep(1);
     
    //2
    echo "2.Screenshot of web page to file:";
    echo $webpage->print_screen("test \ test.bmp")." n";
    sleep(1);
     
    //3
    echo "3.Get the coordinates of the picture(similarity coefficient 0.9):";
    $x = $image->get_x_of_image("test \ test.bmp", "image \ kak.bmp", 0.9);
    $y = $image->get_y_of_image("test \ test.bmp", "image \ kak.bmp", 0.9);
    echo $x."x".$y." n";
     
    $mouse->move($x, $y, false);
    sleep(2);
     
    //4
    echo "4.Let's go to the polygon:";
    echo $browser->navigate("http://www.humanemulator.net/poligon/image.html")."<br>";
     
    //five
    echo "5.Screenshot of the src image to file:";
    echo $image->screenshot_by_src("test \ test.bmp", "http://www.humanemulator.net/screenshots/02.jpg")." n";
     
    //6
    echo "6.Cut the picture from the file:";
    echo $image->get_image("test \ test.bmp", "test \ part.bmp", 126,72,40,33)." n";
     
    //7
    echo "7.Get the coordinates of the picture(similarity coefficient 0.9):";
    $x = $image->get_x_of_image("test \ test.bmp", "test \ part.bmp", 0.9);
    $y = $image->get_y_of_image("test \ test.bmp", "test \ part.bmp", 0.9);
    echo $x."x".$y." n";
     
    $mouse->move($x, $y, false);
    sleep(2);
     
    //end
    echo "<hr> <br>";
     
    //Quit
    $app->quit();
    ?>

    Python example:

    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
     
    xhe_host = "127.0.0.1:7070"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> image.xxxxxxxxx </font> <hr>")
     
    # 1
    echo("1.Let's go to the polygon:")
    echo(browser.navigate("http://bigfozzy.com"), "<br>")
    time.sleep(1)
     
    # 2
    echo("2.Screenshot of web page to file:")
    echo(webpage.print_screen("test \ test.bmp"), "
    ")
    time.sleep(1)
     
    # 3
    echo("3.Get the coordinates of the picture:")
    x = image.get_x_of_image("test \ test.bmp", "test \ kak1.bmp")
    y = image.get_y_of_image("test \ test.bmp", "test \ kak1.bmp")
    echo(str(x) + "x" + str(y), "
    ")
     
    # 4
    echo("4.Move to polygon:")
    echo(browser.navigate("http://www.humanemulator.net/poligon/image.html"), "<br>")
     
    # five
    echo("5.Screenshot of the src image to file:")
    echo(image.screenshot_by_src("test \ test.bmp", "http://www.humanemulator.net/screenshots/02.jpg"), "
    ")
     
    # 6
    echo("6.Cut the picture from the file:")
    echo(image.get_image("test \ test.bmp", "test \ part.bmp", 126,72,40,33), "
    ")
     
    # 7
    echo("7.Get the coordinates of the picture:")
    x = image.get_x_of_image("test \ test.bmp", "test \ part.bmp")
    y = image.get_y_of_image("test \ test.bmp", "test \ part.bmp")
    echo(str(x) + "x" + str(y), "
    ")
     
    # end
    echo("<hr> <br>")
     
    # Quit
    app.quit()

    C# example:

    #region using
     
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
     
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
     
    #endregion
     
     class Program: XHEScript
     {
    static void Main(string [] args)
    {
    //init XHE
    server = "127.0.0.1:7072";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> image.get_x_of_image </font> <hr>");
     
    //1 step
    echo("1.Let's go to the polygon:");
    echo(browser.navigate("http://bigfozzy.com") + "<br>");
     
    //step 2
    echo("2.Screenshot of web page to file:");
    echo(webpage.print_screen("test \ test.bmp") + " n");
     
    //step 3
    echo("3.Get the coordinates of the picture:");
    int x = image.get_x_of_image("test \ test.bmp", "image \ kak.bmp");
    int y = image.get_y_of_image("test \ test.bmp", "image \ kak.bmp");
    echo(x.ToString() + "x" + y.ToString() + " n");
     
    //step 4
    echo("4.Let's go to the polygon:");
    echo(browser.navigate("http://www.humanemulator.net/poligon/image.html") + "<br>");
     
    //step 5
    echo("5.Screenshot of the src image to file:");
    echo(image.screenshot_by_src("test \ test.bmp", "http://www.humanemulator.net/screenshots/02.jpg") + " n");
     
    //step 6
    echo("6.Get the coordinates of the picture:");
    x = image.get_x_of_image("test \ test.bmp", "image \ part.bmp");
    y = image.get_y_of_image("test \ test.bmp", "image \ part.bmp");
    echo(x.ToString() + "x" + y.ToString() + " n");
     
    //end
    echo("<hr> <br>");
     
    app.quit();
    }
    }

    Java Script example:

    //connect the object to control the emulator, if not already connected
    xhe_host = "127.0.0.1:7070";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> image.get_x_of_image </font> <hr>");
     
    //1 step
    echo("1.Let's go to the polygon:");
    echo(browser.navigate("http://bigfozzy.com") + "<br>");
     
    //step 2
    echo("2.Screenshot of web page to file:");
    echo(webpage.print_screen("test \ test.bmp") + " n");
     
    //step 3
    echo("3.Get the coordinates of the picture:");
    x = image.get_x_of_image("test \ test.bmp", "image \ kak.bmp");
    y = image.get_y_of_image("test \ test.bmp", "image \ kak.bmp");
    echo(x + "x" + y + " n");
     
    //step 4
    echo("4.Let's go to the polygon:");
    echo(browser.navigate("http://www.humanemulator.net/poligon/image.html") + "<br>");
     
    //step 5
    echo("5.Screenshot of the src image to file:");
    echo(image.screenshot_by_src("test \ test.bmp", "http://www.humanemulator.net/screenshots/02.jpg") + " n");
     
    //step 6
    echo("6.Get the coordinates of the picture:");
    x = image.get_x_of_image("test \ test.bmp", "image \ part.bmp");
    y = image.get_y_of_image("test \ test.bmp", "image \ part.bmp");
    echo(x + "x" + y + " n");
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/image/tools/get_x_of_image.txt · Last modified: 2026/08/05 22:44 (external edit)