can identifier validation button
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
+3
-2
@@ -17,15 +17,16 @@
|
||||
"mongodb": "^4.9.1",
|
||||
"mongoose": "^6.5.4",
|
||||
"node-schedule": "^2.1.0",
|
||||
"node-tesseract-ocr": "^2.2.1",
|
||||
"node-wget": "^0.4.3",
|
||||
"node-xlsx": "^0.21.0",
|
||||
"opencv4nodejs": "wandenberg/opencv4nodejs",
|
||||
"playwright": "^1.32.1",
|
||||
"puppeteer": "^15.5.0",
|
||||
"node-tesseract-ocr": "^2.2.1",
|
||||
"ws": "^6.2.0",
|
||||
"read-ini-file": "^3.0.1",
|
||||
"uuid": "^9.0.0",
|
||||
"winston": "^3.8.2",
|
||||
"ws": "^6.2.0",
|
||||
"yarn": "^1.22.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const cv = require('opencv4nodejs');
|
||||
|
||||
// cv.imread('/Users/lpan/Downloads/Screenshot_2023-05-19-14-09-11-82_40deb401b9ffe8e1df2f1cc5ba480b12.jpg', function (err, im) {
|
||||
// if (err) return console.error('error loading image');
|
||||
//
|
||||
// var output = im.matchTemplate('../assets/templates/valid_btn_template.png', 3);
|
||||
//
|
||||
// var matches = output.templateMatches(0.80, 1.0, 5, false);
|
||||
//
|
||||
// console.log(matches);
|
||||
// });
|
||||
|
||||
const findWaldo = async () => {
|
||||
// Load images
|
||||
const originalMat = await cv.imreadAsync(`/Users/lpan/Downloads/Screenshot_2023-05-19-14-09-11-82_40deb401b9ffe8e1df2f1cc5ba480b12.jpg`);
|
||||
const waldoMat = await cv.imreadAsync(`${__dirname}/../assets/templates/valid_btn_template.png`);
|
||||
|
||||
// Match template (the brightest locations indicate the highest match)
|
||||
const matched = originalMat.matchTemplate(waldoMat, 3);
|
||||
|
||||
// Use minMaxLoc to locate the highest value (or lower, depending of the type of matching method)
|
||||
const minMax = matched.minMaxLoc();
|
||||
const {maxLoc: {x, y}} = minMax;
|
||||
console.log("x is " + x);
|
||||
console.log("y is " + y);
|
||||
// Draw bounding rectangle
|
||||
originalMat.drawRectangle(
|
||||
new cv.Rect(x, y, waldoMat.cols, waldoMat.rows),
|
||||
new cv.Vec(0, 255, 0),
|
||||
2,
|
||||
cv.LINE_8
|
||||
);
|
||||
|
||||
// Open result in new window
|
||||
cv.imshow('We\'ve found Waldo!', originalMat);
|
||||
cv.waitKey();
|
||||
};
|
||||
|
||||
// noinspection JSIgnoredPromiseFromCall
|
||||
findWaldo();
|
||||
Reference in New Issue
Block a user