humanemulator.net — справка.
Продукт, демо и покупка — на
хуманэмулятор.рф
|
Демо
|
Купить
|
API
|
Changelog
get_qr_code
get_qr_code($inpath,$outpath); - Получить область на картинке с QR кодом, как картинку и сохранить в отдельный файлФункция на вход принимает параметры:
После выполнения функции возвращаемое значение будет равно одному из двух :
Пример использования
<?php // Scenario: Extract QR code region from an image and save it as a separate file $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); } // Path to the source image containing QR code $sourceImagePath = __DIR__ . "/image/qr_code.png"; // Path for the resulting QR code image $qrCodePath = __DIR__ . "/image/extracted_qr.png"; // Make sure the source image file exists if (file_exists($sourceImagePath)) { echo "Source image found at: " . $sourceImagePath . "\n"; // Extract QR code region from the image echo "Extracting QR code region from the image...\n"; $result = DOM::$image->get_qr_code($sourceImagePath, $qrCodePath); if ($result) { echo "Successfully extracted QR code region\n"; echo "QR code image saved to: " . $qrCodePath . "\n"; // Verify the new image was created if (file_exists($qrCodePath)) { echo "QR code image file exists and has been saved\n"; // Get file size of the new image $fileSize = filesize($qrCodePath); echo "QR code image file size: " . $fileSize . " bytes\n"; // Now try to recognize the QR code from the extracted image echo "\nRecognizing QR code from extracted image...\n"; $qrText = DOM::$image->recognize_qr_code($qrCodePath); if ($qrText) { echo "QR code recognized successfully: " . $qrText . "\n"; } else { echo "Failed to recognize QR code from extracted image\n"; } } else { echo "Warning: QR code image file was not created\n"; } } else { echo "Failed to extract QR code region\n"; } } else { echo "Source image file not found at: " . $sourceImagePath . "\n"; // For demonstration purposes echo "For this example to work, you would need an image file with a QR code at: " . $sourceImagePath . "\n"; } // Quit the application WINDOW::$app->quit();
# Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7025" from xweb_human_emulator import * # начало echo("<hr><font color=blue>image.xxxxxxxxx</font><hr>") # путь к картинке path = "image/qr_code.png"; # 1 echo("\n1. Получим картинку с QR кодом : "); echo(image.get_qr_code(path,path+".qr_code.jpg")); # показать app.shell_execute("open",path+".qr_code.jpg"); # 2 echo("\n2. Распознаем картинку с QR кодом : "); echo(image.recognize_qr_code(path)); # конец 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.get_qr_code</font><hr>"); // путь к картинке var path = "image/qr_code.png"; // 1 echo("\n1. Получим картинку с QR кодом : "); echo(image.get_qr_code(path,path+".qr_code.jpg")); // показать app.shell_execute("open",path+".qr_code.jpg"); // 2 echo("\n2. Распознаем картинку с QR кодом : "); echo(image.recognize_qr_code(path)); // конец 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 = "image/qr_code.png"; // 1 echo("\n1. Получим картинку с QR кодом : "); echo(image.get_qr_code(path,path+".qr_code.jpg")); // показать app.shell_execute("open",path+".qr_code.jpg"); // 2 echo("\n2. Распознаем картинку с QR кодом : "); echo(image.recognize_qr_code(path)); // конец echo("\n"); // Quit app.quit();
=============================================
Image Объекты DOM System Vision Web Window
=============================================
Если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум.