mirror of
https://github.com/Mintplex-Labs/nut.js.git
synced 2026-07-19 14:06:17 -04:00
Corrects search results for pixel density, closes #29
This commit is contained in:
@@ -39,9 +39,12 @@ export class TemplateMatchingFinder implements FinderInterface {
|
||||
matchResults.push(await this.scaleAndMatchNeedle(haystack, needle));
|
||||
}
|
||||
|
||||
matchResults.map((matchResult) => {
|
||||
// Compensate pixel density
|
||||
matchResults.map(matchResult => {
|
||||
matchResult.location.left /= matchRequest.haystack.pixelDensity.scaleX;
|
||||
matchResult.location.width /= matchRequest.haystack.pixelDensity.scaleX;
|
||||
matchResult.location.top /= matchRequest.haystack.pixelDensity.scaleY;
|
||||
matchResult.location.height /= matchRequest.haystack.pixelDensity.scaleY;
|
||||
});
|
||||
|
||||
return matchResults.sort(
|
||||
@@ -186,12 +189,6 @@ export class TemplateMatchingFinder implements FinderInterface {
|
||||
private async scale(image: cv.Mat, scaleFactor: number): Promise<cv.Mat> {
|
||||
const scaledRows = Math.max(Math.floor(image.rows * scaleFactor), 1.0);
|
||||
const scaledCols = Math.max(Math.floor(image.cols * scaleFactor), 1.0);
|
||||
return image.resizeAsync(
|
||||
scaledRows,
|
||||
scaledCols,
|
||||
0,
|
||||
0,
|
||||
cv.INTER_AREA,
|
||||
);
|
||||
return image.resizeAsync(scaledRows, scaledCols, 0, 0, cv.INTER_AREA);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -8,7 +8,8 @@
|
||||
"no-empty": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"interface-name": false,
|
||||
"trailing-comma": true
|
||||
"trailing-comma": true,
|
||||
"arrow-parens": false
|
||||
},
|
||||
"rulesDirectory": []
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user