自动发帖软件

标题: AIWROK软件用图找图示例templateMat方法 [打印本页]

作者: 发帖软件    时间: 13 小时前
标题: AIWROK软件用图找图示例templateMat方法
AIWROK软件用图找图示例templateMat方法
AIWROK软件用图找图示例templateMat方法 群发软件发帖工具

AIWROK软件用图找图示例templateMat方法 群发软件发帖工具

  1. //🍎交流 QQ 群 711841924 群一,苹果内测群,528816639
  2. //适用本文档ES5系统安卓 JavaScript引擎Rhino
  3. //图找图示例templateMat方法

  4. function safeImageMatching() {
  5.     printl("图找图示例");
  6.    
  7.     // 只截取一次屏幕作为基础图像
  8.     var screenshot = screen.screenShot(1080, 1920, 100);
  9.     var mat = screenshot.getMat();
  10.     printl("基础图像: " + mat.width() + "x" + mat.height());
  11.    
  12.     // 从基础图像中提取模板区域 (左上角200x200区域)
  13.     var templateMat = mat.submat(0, 200, 0, 200);
  14.     printl("模板图像: " + templateMat.width() + "x" + templateMat.height());
  15.    
  16.     // 转换模板为Base64
  17.     var templateBase64 = templateMat.ToBase64();
  18.     printl("模板Base64长度: " + ('' + templateBase64).length);
  19.    
  20.     // 使用整个基础图像作为搜索图像
  21.     var searchMat = mat;
  22.     printl("搜索图像: " + searchMat.width() + "x" + searchMat.height());
  23.    
  24.     // 图像匹配
  25.     var results = opencv.templateMatch(searchMat, [templateBase64], 0.9, [0, 0, 1, 1], true);
  26.    
  27.     if (results && results.length > 0) {
  28.         printl("匹配成功!");
  29.         // 安全地访问匹配结果属性
  30.         var result = results[0];
  31.         // 尝试访问各种属性
  32.         if (result.x !== undefined) {
  33.             printl("位置X: " + result.x);
  34.         }
  35.         if (result.y !== undefined) {
  36.             printl("位置Y: " + result.y);
  37.         }
  38.         if (result.score !== undefined) {
  39.             printl("相似度: " + result.score);
  40.         }
  41.         // 尝试调用click方法
  42.         if (typeof result.click === 'function') {
  43.             printl("支持点击操作");
  44.         }
  45.     } else {
  46.         printl("未找到匹配");
  47.     }
  48.    
  49.     // 释放资源
  50.     templateMat = null;
  51.     mat = null;
  52.     screenshot = null;
  53.    
  54.     printl("示例结束");
  55. }

  56. safeImageMatching();
复制代码







欢迎光临 自动发帖软件 (http://www.fatiegongju.com/) Powered by Discuz! X3.2