humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
лог изменений
fix_skew_text
fix_skew_text($inpath,$outpath); - исправить наклонный текст на картинке доступна с версии 7.0.62Функция на вход принимает параметры:
После отработки функция возвращает результат своей работы в скрипт :
Пример использования
<?php // Scenario: Fix skew in text images by detecting the text angle and rotating the image to make the text horizontal. This is useful for preprocessing scanned documents or images with rotated text before OCR processing. $xhe_host = "localhost:7010"; if (!isset($path)){ // Path to the init.php file for connecting to the XHE API $path = "../../../Templates/init.php"; // Including init.php grants access to all classes and functionality for working with the XHE API require($path); } // Create output directory if it doesn't exist $outputDir = "output"; if (!is_dir($outputDir)) { mkdir($outputDir, 0777, true); echo "Created output directory: $outputDir\n"; } // Check if the source image exists $sourceImage = "skewed_text.png"; if (file_exists($sourceImage)) { // Fix skew in the text image $outputPath = "$outputDir/fixed_skew_text.png"; echo "Fixing skew in text image: $sourceImage\n"; $result = DOM::$image->fix_skew_text($sourceImage, $outputPath); if ($result) { echo "Text skew fixed successfully and saved to: $outputPath\n"; // Check if the file was actually created if (file_exists($outputPath)) { echo "File size: " . filesize($outputPath) . " bytes\n"; } else { echo "Warning: Fixed skew text image file was not created despite success return value\n"; } } else { echo "Failed to fix text skew\n"; } } else { echo "Source image does not exist: $sourceImage\n"; } // Quit the application WINDOW::$app->quit(); ?>
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:3035" from xweb_human_emulator import * # начало echo("<hr><font color=blue>image.xxxxxxxxx</font><hr>") # 1 echo("1. Выровняем сдвиг текста из скана: "); echo(image.fix_skew_text("E:\\zp3.png_mrz.png","e:/mrz_fixed.png"),"<br>"); # 2 echo("2. Покажем результат : "); echo(app.shell_execute("open","e:/mrz_fixed.png")); # конец echo("<hr><br>") # Quit app.quit()
#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 = "localhost:7010"; InitXHE(); // начало echo("<hr><font color=blue>image.add_image</font><hr>"); // 1 echo("1. Выровняем сдвиг текста из скана : "); echo(image.fix_skew_text("E:\\zp3.png_mrz.png","e:/mrz_fixed.png")+"<br>"); // 2 echo("2. Покажем результат : "); echo(app.shell_execute("open","e:/mrz_fixed.png")); // конец echo("\n\n"); app.quit(); } }
// подключим функциональные объекты, если еще не подключен xhe_host="127.0.0.1:3035"; echo=require("../../../Templates JS/init.js"); // начало echo("<hr><font color=blue>image.add_image</font><hr>"); // 1 echo("1. Выровняем сдвиг текста из скана : "); echo(image.fix_skew_text("E:\\zp3.png_mrz.png","e:/mrz_fixed.png")+"<br>"); // 2 echo("2. Покажем результат : "); echo(app.shell_execute("open","e:/mrz_fixed.png")); // конец echo("\n"); // Quit app.quit();
=============================================
Image Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.