Corrects search results for pixel density, closes #29

This commit is contained in:
Simon Hofmann
2019-02-10 18:50:16 +01:00
parent 630a47e201
commit cb7d191de4
2 changed files with 8 additions and 10 deletions
@@ -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
View File
@@ -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": []
}
}