Answer the question
In order to leave comments, you need to log in
How to make screenshot opencv4nodejs + robotjs?
const cv = require('opencv4nodejs');
const robot = require('robotjs');
var Jimp = require( 'jimp' );
const findWaldo = async () => {
var screen = robot.captureScreen();
//await screenCaptureToFile( screen );
// Load images
// const originalMat = await cv.imreadAsync(`${__dirname}/fone.png`);
console.log(screen);
const originalMat = new cv.Mat(screen.image , screen.width, screen.height, cv.CV_8UC3);
const waldoMat = await cv.imreadAsync(`${__dirname}/fire.png`);
const matched = originalMat.matchTemplate(waldoMat, 5);
const minMax = matched.minMaxLoc();
const { maxLoc: { x, y } } = minMax;
originalMat.drawRectangle(
new cv.Rect(x, y, waldoMat.cols, waldoMat.rows),
new cv.Vec(0, 255, 0),
1,
cv.LINE_8
);
cv.imshow('We\'ve found Waldo!', originalMat);
cv.waitKey();
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question