Основной сайт хуманэмулятор.рф | Демо | Купить | API | Wiki
DOM / image
get_rotated_angle
get_rotated_angle($inpath,$min=-8,$max=8,$step=1); - Получить угол наклона картинкиФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Determine the rotation angle of an image. This function analyzes the image to detect if it has been rotated and returns the angle of rotation, which is useful for correcting image orientation. $xhe_host = getenv("RPABOT_HOST_URL"); 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 = "rotated_image.png"; if (file_exists($sourceImage)) { // Get the rotation angle of the image echo "Detecting rotation angle of image: $sourceImage\n"; $angle = DOM::$image->get_rotated_angle($sourceImage); if ($angle !== -1) { echo "Image rotation angle detected: $angle degrees\n"; } else { echo "Failed to detect image rotation angle\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>") # путь к картинке path = "E:/40.jpeg"; # 1 echo("1. Получим угол на который наклонен текст : "); angle = image.get_rotated_angle(path); echo(angle); # 2 echo("\n2. Повернем картинку : "); echo(image.rotate(path,path+".rotated.jpg",angle)); # показать app.shell_execute("open",path+".rotated.jpg"); # конец 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 = Environment.GetEnvironmentVariable("RPABOT_HOST_URL"); InitXHE(); // начало echo("<hr><font color=blue>image.add_image</font><hr>"); // путь к картинке var path = "E:/40.jpeg"; // 1 echo("1. Получим угол на который наклонен текст : "); var angle = image.get_rotated_angle(path); echo(angle); // 2 echo("\n2. Повернем картинку : "); echo(image.rotate(path,path+".rotated.jpg",angle)); // показать app.shell_execute("open",path+".rotated.jpg"); // конец 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>"); // путь к картинке var path = "E:/40.jpeg"; // 1 echo("1. Получим угол на который наклонен текст : "); var angle = image.get_rotated_angle(path); echo(angle); // 2 echo("\n2. Повернем картинку : "); echo(image.rotate(path,path+".rotated.jpg",angle)); // показать app.shell_execute("open",path+".rotated.jpg"); // конец echo("\n"); // Quit app.quit();
=============================================
Image Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.