get_region_by_text(path, text); - получить регион текста
Функция на вход принимает параметры:
path – путь к файлу с картинкой text – текст, регион которого надо получить
После отработки функция возвращает результат своей работы в робот :
регион – регион заданного текста
Пример использования get_region_by_text (PHP):
<?php $xhe_host = "127.0.0.1:7024"; // подключим объект для управления эмулятором, если еще не подключен if (!isset($path)) $path="../../../Templates/init.php"; require($path); // начало echo "<hr><font color=blue>image->".basename (__FILE__)."</font><hr>"; // 1 echo "\n\n1. Получим регион текста : <br><br>"; $regionText=$tesseractOCR->get_region_by_text("test\\capcha_100_3.png","information","rus+eng"); echo print_r($regionText); // получим подкартинку $image->get_image("test\\capcha_100_3.png","test\\capcha_100_3_sub.png",$regionText->X,$regionText->Y,$regionText->Width,$regionText->Height); $app->shell_execute("open","test\\capcha_100_3_sub.png"); // конец echo "<hr><br>"; // Quit $app->quit(); ?>
Пример использования get_region_by_text (C#):
#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:7024"; InitXHE(); // начало echo("<hr><font color=blue>browser.clear_cookies</font><hr>"); // 1 echo "\n\n1. Получим регион текста : <br><br>"; $regionText=$tesseractOCR->get_region_by_text("test\\capcha_100_3.png","information","rus+eng"); echo print_r($regionText); // получим подкартинку $image->get_image("test\\capcha_100_3.png","test\\capcha_100_3_sub.png",$regionText->X,$regionText->Y,$regionText->Width,$regionText->Height); $app->shell_execute("open","test\\capcha_100_3_sub.png"); // конец echo("<hr><br>"); app.quit(); } }
Пример использования get_region_by_text (Python):
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7024" from xweb_human_emulator import * # начало echo("<hr><font color=blue>yandexVision.xxxxxxxxx</font><hr>") // 1 echo "\n\n1. Получим регион текста : <br><br>"; $regionText=$tesseractOCR->get_region_by_text("test\\capcha_100_3.png","information","rus+eng"); echo print_r($regionText); // получим подкартинку $image->get_image("test\\capcha_100_3.png","test\\capcha_100_3_sub.png",$regionText->X,$regionText->Y,$regionText->Width,$regionText->Height); $app->shell_execute("open","test\\capcha_100_3_sub.png"); # конец echo("<hr><br>") # Quit app.quit()
Пример использования get_region_by_text (JS):
xhe_host="127.0.0.1:7024"; echo=require("../../../Templates JS/init.js"); // 1 echo "\n\n1. Получим регион текста : <br><br>"; $regionText=$tesseractOCR->get_region_by_text("test\\capcha_100_3.png","information","rus+eng"); echo print_r($regionText); // получим подкартинку $image->get_image("test\\capcha_100_3.png","test\\capcha_100_3_sub.png",$regionText->X,$regionText->Y,$regionText->Width,$regionText->Height); $app->shell_execute("open","test\\capcha_100_3_sub.png"); // конец echo("<hr><br>"); // Quit app.quit();