注册时间
最后登录
新帖
发布在 技术交流 阅读更多

18:26:32.086/E: Wrapped java.lang.IllegalStateException: image has been recycled (/android_asset/modules/paddle.js#10)
Wrapped java.lang.IllegalStateException: image has been recycled
at /android_asset/modules/paddle.js:10:0
at captureAndOcr (/storage/emulated/0/脚本/GetGold-x/OCR/OCR.js:37:0)
at /storage/emulated/0/脚本/GetGold-x/OCR/OCR.js:47:0
at /storage/emulated/0/脚本/GetGold-x/App/com.antisent.compass/ExternalScript.js:39:0

![0_1706869931792_965c9aaff1c0aeb06bceab530745607.png](正在上传 100%)

代码:// 识别结果和截图信息
let result = []
let img = null
let capturing = true
/**

  • 截图并识别OCR文本信息
    */
    function captureAndOcr() {
    capturing = true
    img && img.recycle()
    img = captureScreen();
    if (!img) {
    toastLog('截图失败')
    }
    let start = new Date()
    result = paddle.ocr(img);
    // log(result);
    toastLog('OCR耗时' + (new Date() - start) + 'ms')
    capturing = false
    // 回收图片
    }

OCR.find = function (elementName) {
captureAndOcr()
if (result && result.length > 0) {
for (let i = 0; i < result.length; i++) {
let ocrResult = result[i]
// log(ocrResult.words);
for (let s = 0; s < elementName.length; s++) {
if (ocrResult.words == elementName[s]) {
// draw(ocrResult.words + ' #信心:' + ocrResult.confidence.toFixed(2), ocrResult.bounds);
toastLog(ocrResult.words + " ,坐标:" + ocrResult.bounds.centerX() + ',' + ocrResult.bounds.centerY());
return [ocrResult.bounds.centerX(), ocrResult.bounds.centerY()]
}
}
}
} else {
return null;
}
}

发布在 技术交流 阅读更多

我用找色获取的坐标,用click()点击之后,怎么才能把这个坐标现在是手机上是块红点或字体,麻烦大佬给个建议