Ask Your Question

Mr_John's profile - activity

2020-03-24 05:01:42 -0600 marked best answer [OpenCV.js] Template matching with mask

Hello,

I'm trying to use template matching in OpenCV.js as per the example here: https://docs.opencv.org/3.4/d8/dd1/tu...

I have this working.

I am now trying to template match with a mask. I am using the following line:

cv.matchTemplate(image_to_search, template, output, cv.TM_CCORR_NORMED , mask);

If I use an empty mask:

mask = new cv.Mat();

Then the function is working correctly (this is the way the example is working), but as soon as I try to pass my own mask it fails (Uncaught error 6593664 is the console error message I am getting)

Can someone please provide some working code on how to perfrom a template match in OpenCV.js with a mask?

My template is a loaded via:

cv.imread(canvas); //canvas is a HTML5 <canvas> element

and I am currently generating the mask via the following function:

function generate_mask(source){
    let output =    new cv.Mat();
    //This gives me a black where there is currently transparency
    cv.cvtColor(source, output, cv.COLOR_RGBA2GRAY, 0);

    cv.threshold(output, output, 1, 255, cv.THRESH_BINARY);

    return output;
}

Thanks

2020-03-24 05:01:34 -0600 received badge  Necromancer (source)
2020-03-24 05:01:34 -0600 received badge  Self-Learner (source)
2020-03-22 09:51:49 -0600 answered a question [OpenCV.js] Template matching with mask

Found a solution using the following code: function(){ var method = cv.TM_CCORR_NORMED; var source =

2020-01-17 13:22:03 -0600 commented question [OpenCV.js] Template matching with mask

@Chris, that is how I am using it at the moment - and I'm getting the issue in the post

2020-01-16 12:41:45 -0600 commented question [OpenCV.js] Template matching with mask

@Chris, that is how I am using it at the moment

2020-01-12 07:04:50 -0600 received badge  Editor (source)
2020-01-12 07:04:50 -0600 edited question [OpenCV.js] Template matching with mask

[OpenCV.js] Template matching with mask Hello, I'm trying to use template matching in OpenCV.js as per the example here

2020-01-11 09:49:06 -0600 asked a question [OpenCV.js] Template matching with mask

[OpenCV.js] Template matching with mask Hello, I'm trying to use template matching in OpenCV.js as per the example here