@@ -74,6 +74,8 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
### 更新日志
|
### 更新日志
|
||||||
|
### 1.3.6(2025.08.07)
|
||||||
|
1.进一步优化内存占用
|
||||||
### 1.3.5(2025.08.07)
|
### 1.3.5(2025.08.07)
|
||||||
1.使用dispose极大优化内存占用
|
1.使用dispose极大优化内存占用
|
||||||
### 1.3.4(2025.08.07)
|
### 1.3.4(2025.08.07)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//当前js版本 1.3.5
|
//当前js版本 1.3.6
|
||||||
|
|
||||||
//拾取时上下滑动的时间
|
//拾取时上下滑动的时间
|
||||||
const timeMoveUp = 500;
|
const timeMoveUp = 500;
|
||||||
@@ -10,6 +10,7 @@ if (settings.activeDumperMode) { //处理泥头车信息
|
|||||||
dumpers = [];
|
dumpers = [];
|
||||||
}
|
}
|
||||||
trigger = (+settings.trigger || 50);
|
trigger = (+settings.trigger || 50);
|
||||||
|
let gameRegion;
|
||||||
|
|
||||||
(async function () {
|
(async function () {
|
||||||
//自定义配置处理
|
//自定义配置处理
|
||||||
@@ -501,7 +502,7 @@ async function runPath(pathFilePath, map_name, whitelistKeywords, blacklistKeywo
|
|||||||
try {
|
try {
|
||||||
let template = file.ReadImageMatSync(imagePath);
|
let template = file.ReadImageMatSync(imagePath);
|
||||||
let recognitionObject = RecognitionObject.TemplateMatch(template, xMin, yMin, width, height);
|
let recognitionObject = RecognitionObject.TemplateMatch(template, xMin, yMin, width, height);
|
||||||
const gameRegion = captureGameRegion();
|
gameRegion = captureGameRegion();
|
||||||
let result = gameRegion.find(recognitionObject);
|
let result = gameRegion.find(recognitionObject);
|
||||||
gameRegion.dispose();
|
gameRegion.dispose();
|
||||||
if (result.isExist()) {
|
if (result.isExist()) {
|
||||||
@@ -542,7 +543,7 @@ async function runPath(pathFilePath, map_name, whitelistKeywords, blacklistKeywo
|
|||||||
try {
|
try {
|
||||||
let template = file.ReadImageMatSync(imagePath);
|
let template = file.ReadImageMatSync(imagePath);
|
||||||
let recognitionObject = RecognitionObject.TemplateMatch(template, xMin, yMin, width, height);
|
let recognitionObject = RecognitionObject.TemplateMatch(template, xMin, yMin, width, height);
|
||||||
const gameRegion = captureGameRegion();
|
gameRegion = captureGameRegion();
|
||||||
let result = gameRegion.find(recognitionObject);
|
let result = gameRegion.find(recognitionObject);
|
||||||
gameRegion.dispose();
|
gameRegion.dispose();
|
||||||
if (result.isExist()) {
|
if (result.isExist()) {
|
||||||
@@ -578,44 +579,39 @@ async function runPath(pathFilePath, map_name, whitelistKeywords, blacklistKeywo
|
|||||||
|
|
||||||
// 定义一个函数用于执行OCR识别和交互
|
// 定义一个函数用于执行OCR识别和交互
|
||||||
async function performOcrAndInteract(imagePath, whitelistKeywords, textxRange, texttolerance) {
|
async function performOcrAndInteract(imagePath, whitelistKeywords, textxRange, texttolerance) {
|
||||||
async function performOcr(whitelistKeywords, xRange, yRange, timeout = 200) {
|
async function performOcr(whitelistKeywords, xRange, yRange) {
|
||||||
let startTime = Date.now();
|
try {
|
||||||
while (Date.now() - startTime < timeout) {
|
// 在捕获的区域内进行OCR识别
|
||||||
try {
|
gameRegion = captureGameRegion();
|
||||||
// 在捕获的区域内进行OCR识别
|
let resList = gameRegion.findMulti(RecognitionObject.ocr(
|
||||||
let ra = captureGameRegion();
|
xRange.min, yRange.min,
|
||||||
let resList = ra.findMulti(RecognitionObject.ocr(
|
xRange.max - xRange.min, yRange.max - yRange.min
|
||||||
xRange.min, yRange.min,
|
));
|
||||||
xRange.max - xRange.min, yRange.max - yRange.min
|
gameRegion.dispose();
|
||||||
));
|
// 遍历识别结果,检查是否找到目标文本
|
||||||
ra.dispose();
|
let results = [];
|
||||||
// 遍历识别结果,检查是否找到目标文本
|
for (let i = 0; i < resList.count; i++) {
|
||||||
let results = [];
|
let res = resList[i];
|
||||||
for (let i = 0; i < resList.count; i++) {
|
let correctedText = res.text;
|
||||||
let res = resList[i];
|
|
||||||
let correctedText = res.text;
|
|
||||||
|
|
||||||
// 如果 whitelistKeywords 为空,则直接将所有文本视为匹配
|
// 如果 whitelistKeywords 为空,则直接将所有文本视为匹配
|
||||||
if (whitelistKeywords.length === 0) {
|
if (whitelistKeywords.length === 0) {
|
||||||
results.push({ text: correctedText, x: res.x, y: res.y, width: res.width, height: res.height });
|
results.push({ text: correctedText, x: res.x, y: res.y, width: res.width, height: res.height });
|
||||||
} else {
|
} else {
|
||||||
// 否则,检查是否包含目标文本
|
// 否则,检查是否包含目标文本
|
||||||
for (let targetText of whitelistKeywords) {
|
for (let targetText of whitelistKeywords) {
|
||||||
if (correctedText.includes(targetText)) {
|
if (correctedText.includes(targetText)) {
|
||||||
results.push({ text: correctedText, x: res.x, y: res.y, width: res.width, height: res.height });
|
results.push({ text: correctedText, x: res.x, y: res.y, width: res.width, height: res.height });
|
||||||
break; // 匹配到一个目标文本后即可跳出循环
|
break; // 匹配到一个目标文本后即可跳出循环
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
|
||||||
} catch (error) {
|
|
||||||
log.error(`识别文字时发生异常: ${error.message}`);
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
return results;
|
||||||
|
} catch (error) {
|
||||||
|
log.error(`识别文字时发生异常: ${error.message}`);
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
log.warn("OCR识别超时");
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!state.completed && !state.cancelRequested) {
|
while (!state.completed && !state.cancelRequested) {
|
||||||
@@ -626,13 +622,12 @@ async function runPath(pathFilePath, map_name, whitelistKeywords, blacklistKeywo
|
|||||||
try {
|
try {
|
||||||
let template = file.ReadImageMatSync(imagePath);
|
let template = file.ReadImageMatSync(imagePath);
|
||||||
let recognitionObject = RecognitionObject.TemplateMatch(template, xMin, yMin, width, height);
|
let recognitionObject = RecognitionObject.TemplateMatch(template, xMin, yMin, width, height);
|
||||||
const gameRegion = captureGameRegion();
|
gameRegion = captureGameRegion();
|
||||||
let result = gameRegion.find(recognitionObject);
|
let result = gameRegion.find(recognitionObject);
|
||||||
gameRegion.dispose();
|
|
||||||
if (result.isExist()) {
|
if (result.isExist()) {
|
||||||
return { success: true, x: result.x, y: result.y, width: result.width, height: result.height };
|
return { success: true, x: result.x, y: result.y, width: result.width, height: result.height };
|
||||||
} else {
|
} else {
|
||||||
|
gameRegion.dispose();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(`识别图像时发生异常: ${error.message}`);
|
log.error(`识别图像时发生异常: ${error.message}`);
|
||||||
@@ -665,7 +660,7 @@ async function runPath(pathFilePath, map_name, whitelistKeywords, blacklistKeywo
|
|||||||
let centerYF = fRes.y + fRes.height / 2;
|
let centerYF = fRes.y + fRes.height / 2;
|
||||||
|
|
||||||
// 在当前屏幕范围内进行 OCR 识别
|
// 在当前屏幕范围内进行 OCR 识别
|
||||||
let ocrResults = await performOcr(whitelistKeywords, textxRange, { min: fRes.y - texttolerance, max: fRes.y + fRes.height + texttolerance * 2 }, 200);
|
let ocrResults = await performOcr(whitelistKeywords, textxRange, { min: fRes.y - texttolerance, max: fRes.y + fRes.height + texttolerance * 2 });
|
||||||
|
|
||||||
// 检查所有目标文本是否在当前页面中
|
// 检查所有目标文本是否在当前页面中
|
||||||
let foundTarget = false;
|
let foundTarget = false;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 1,
|
"manifest_version": 1,
|
||||||
"name": "锄地一条龙",
|
"name": "锄地一条龙",
|
||||||
"version": "1.3.5",
|
"version": "1.3.6",
|
||||||
"description": "一站式解决自动化锄地,支持只拾取狗粮,请仔细阅读README.md后使用",
|
"description": "一站式解决自动化锄地,支持只拾取狗粮,请仔细阅读README.md后使用",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"settings_ui": "settings.json",
|
"settings_ui": "settings.json",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"saved_files": [
|
"saved_files": [
|
||||||
"records/",
|
"records/*.json",
|
||||||
"assets/拾取名单.json"
|
"assets/拾取名单.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user