@bettergi/utils 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/ocr.js +12 -4
  2. package/package.json +1 -1
package/dist/ocr.js CHANGED
@@ -32,7 +32,9 @@ export const findImage = (image, config = {}) => {
32
32
  try {
33
33
  const mat = typeof image === "string" ? file.readImageMatSync(image) : image;
34
34
  const ro = RecognitionObject.templateMatch(mat);
35
- Object.assign(ro, config);
35
+ if (Object.keys(config).length > 0) {
36
+ Object.assign(ro, config) && ro.initTemplate();
37
+ }
36
38
  return findFirst(ir, ro, region => region.isExist());
37
39
  }
38
40
  catch (err) {
@@ -57,7 +59,9 @@ export const findImageWithinBounds = (image, x, y, w, h, config = {}) => {
57
59
  try {
58
60
  const mat = typeof image === "string" ? file.readImageMatSync(image) : image;
59
61
  const ro = RecognitionObject.templateMatch(mat, x, y, w, h);
60
- Object.assign(ro, config);
62
+ if (Object.keys(config).length > 0) {
63
+ Object.assign(ro, config) && ro.initTemplate();
64
+ }
61
65
  return findFirst(ir, ro, region => region.isExist());
62
66
  }
63
67
  catch (err) {
@@ -104,7 +108,9 @@ export const findText = (text, options, config = {}) => {
104
108
  const ir = captureGameRegion();
105
109
  try {
106
110
  const ro = RecognitionObject.ocrThis;
107
- Object.assign(ro, config);
111
+ if (Object.keys(config).length > 0) {
112
+ Object.assign(ro, config) && ro.initTemplate();
113
+ }
108
114
  return findFirst(ir, ro, region => {
109
115
  const itemText = ignoreCase ? region.text.toLowerCase() : region.text;
110
116
  const isMatch = contains ? itemText.includes(searchText) : itemText === searchText;
@@ -135,7 +141,9 @@ export const findTextWithinBounds = (text, x, y, w, h, options, config = {}) =>
135
141
  const ir = captureGameRegion();
136
142
  try {
137
143
  const ro = RecognitionObject.ocr(x, y, w, h);
138
- Object.assign(ro, config);
144
+ if (Object.keys(config).length > 0) {
145
+ Object.assign(ro, config) && ro.initTemplate();
146
+ }
139
147
  return findFirst(ir, ro, region => {
140
148
  const itemText = ignoreCase ? region.text.toLowerCase() : region.text;
141
149
  const isMatch = contains ? itemText.includes(searchText) : itemText === searchText;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bettergi/utils",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "开发 BetterGI 脚本常用工具集",
5
5
  "type": "module",
6
6
  "author": "Bread Grocery<https://github.com/breadgrocery>",