GithubHelp home page GithubHelp logo

Comments (10)

neko-para avatar neko-para commented on August 24, 2024 1

是的,默认maa会缩放为短边720,你可以用controller上的set_controller_option设置为特定宽高。不过因为模板匹配之类的识别要求分辨率和模板一致,所以最好是按固定分辨率处理。

from maa-node.

neko-para avatar neko-para commented on August 24, 2024 1

试了下确实能复现,但是看不出来具体是个啥情况
下个版本打算直接把之前的实现去掉了。不过这样在返回encoded的时候必然触发一次复制了。

from maa-node.

neko-para avatar neko-para commented on August 24, 2024

我测试一下. 因为get_image_encoded返回的是实际数据的引用, 没有复制到js侧来, 所以可能会有些bug. 我用下面这个代码测试了一下是ok的

import * as maa from '@nekosu/maa-node'

console.log(maa.version())

async function main() {
  // 查询所有Adb设备
  const devices = await maa.AdbController.find()
  if (!devices) {
    return
  }

  // 使用第一个设备创建控制器
  const ctrl = new maa.AdbController(devices[0])
  ctrl.notify = (msg, detail) => {
    console.log(msg, detail)
  }
  // 连接设备
  await ctrl.post_connection()

  // 创建资源
  const res = new maa.Resource()
  res.notify = (msg, detail) => {
    console.log(msg, detail)
  }

  // 创建实例
  const inst = new maa.Instance()
  inst.notify = (msg, detail) => {
    console.log(msg, detail)
  }

  // 绑定控制器和资源
  inst.bind(ctrl)
  inst.bind(res)

  // 检查是否正确创建
  console.log(inst.inited)

  inst.register_custom_recognizer('CustomReco', (ctx, name, param, img) => {
    console.log(img.info)
    // console.log(img.encoded)
    console.log(maa.get_image_encoded(img.handle))
    return {
      out_box: {
        x: 0,
        y: 0,
        width: 10,
        height: 10
      },
      out_detail: '11111'
    }
  })

  // 执行任务, Task1来自pipeline/Task.json
  await inst
    .post_task('Test', {
      Test: {
        recognition: 'Custom',
        custom_recognition: 'CustomReco'
      }
    })
    .wait()
}

main()

process.on('SIGINT', () => {
  process.exit()
})
true
Task.Started {"entry":"Test","hash":"0","id":1,"name":"Test","uuid":"855c39afc684c675"}
{ width: 1280, height: 720, type: 16 }
ArrayBuffer {
  [Uint8Contents]: <89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 05 00 00 00 02 d0 08 02 00 00 00 40 1f 4a 01 00 00 20 00 49 44 41 54 78 01 ec c1 0f bc e7 75 41 e7 fb d7 fb f3 fb fd ce 39 73 e6 2f cc c0 8c 23 02 ca 88 06 a2 a6 24 ad a9 bb b9 6d 96 d5 2a 1b 50 01 56 76 8b 6e de 25 8b ac 50 6f 82 09 68 3e b6 bb ... 313994 more bytes>,
  byteLength: 314094
}
Task.Completed {"entry":"Test","hash":"0","id":1,"name":"Test","uuid":"855c39afc684c675"}
destroy TrivialCallback
destroy CustomActionRun
destroy TrivialCallback
destroy TrivialCallback

我测试的版本是1.3.4, 你试试看更新能否解决问题呢?

from maa-node.

neko-para avatar neko-para commented on August 24, 2024

我更新了1.3.5, 加了encoded_copied方法, 也可以试试看

from maa-node.

skrlst avatar skrlst commented on August 24, 2024

非常感谢你的回复,等晚上我试试看

from maa-node.

skrlst avatar skrlst commented on August 24, 2024

虽然不知道这两种为啥还是会闪退,但新加的 encoded_copied 方法很好用

赞赞赞👍

// console.log(img.encoded)
// console.log(maa.get_image_encoded(img.handle))

image

from maa-node.

neko-para avatar neko-para commented on August 24, 2024

可以提供一下测试代码和具体node版本吗,后续研究一下

from maa-node.

skrlst avatar skrlst commented on August 24, 2024

可以提供一下测试代码和具体node版本吗,后续研究一下

当然可以,我打包了一份项目,模板用的是你另一个仓库 https://github.com/neko-para/maa-node-template

具体方法在 pkgs/main/src/gameManager/emu/hooks.ts 文件中一个叫做 useFirstEmulator 的方法

运行起来后,打开 EmulatorTest 页面,然后按照顺序点击按钮就可以完成复现了

pipeline 中 Task3 就是自定义的识别任务

> npm -v
10.8.1
> node -v
v20.12.2

操作系统:Windows 10
模拟器:MuMu V3.8.5(2722)

demo.zip

from maa-node.

skrlst avatar skrlst commented on August 24, 2024

之前注意力一直集中在获取图片,等拿到 ArrayBuffer 之后开始处理,发现怎么调试都跟之前 mock 的结果对不上。

刚刚发现,原来是像素尺寸没对上...

是这样的,MuMu 模拟器我这边设置的是竖屏 900 * 1600

但拿到的 ArrayBuffer 尺寸却是 { width: 1280, height: 720, type: 16 }


  1. 为啥尺寸会变成这样呢,是 MaaFramework 那边做了什么处理吗?

  2. 有没有可能在我们使用方做些什么设置,让得到的 ArrayBuffer 与模拟器配置的分辨率一致呢?

from maa-node.

skrlst avatar skrlst commented on August 24, 2024

是的,默认maa会缩放为短边720,你可以用controller上的set_controller_option设置为特定宽高。不过因为模板匹配之类的识别要求分辨率和模板一致,所以最好是按固定分辨率处理。

有用有用,谢谢指点~

from maa-node.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.