Open bigturtle88 opened 4 years ago
const cv = require('opencv4nodejs')
const robot = require('robotjs')
const width = 1920;
const height = 1080;
(async() => {
const screenshot = robot.screen.capture(0, 0, width, height);
const image = new cv.Mat(screenshot.image, height, width, cv.CV_8UC4);
const template = cv.imread('./template.png', cv.CV_8U);
const matched = (new cv.Mat(screenshot.image, height, width, cv.CV_8U)).matchTemplate(template, 5);
const minMax = matched.minMaxLoc();
const { maxLoc: { x, y } } = minMax;
image.drawRectangle(
new cv.Rect(x, y, template.cols, template.rows),
new cv.Vec(0, 255, 0),
2,
cv.LINE_8
);
cv.imshow('Result', image);
cv.waitKey();
})();
In this way, the picture is correct. But opencv can't find a template
I have the same problem
I am getting such a gray image.
https://i.stack.imgur.com/7AJ4F.png
How can a full-screenshot of desktop image be obtained for recognition. In this case, do not save the file but work with the buffer?