Ask Your Question

Revision history [back]

how to set the threshold for matchtemplate result in cpp?

Hi, I want to set the threshold for the matchtemplate result,

In this python tutorial link, you can check the last example.

It is a easy job in python, you can use np.where( im > threshold), to get it done. Which also shown in the example code,

But I don't know how to make in cpp.

Seems no numpy tool in cpp.

I check the stack overflow link

And use the syntax Mat >threshold but seems not work. I use the image watch extension in Vi sual Studio, and get the totally white result.

image description.

So how to make the threshold for the result in cpp.

how to set the threshold for matchtemplate result in cpp?

Hi, I want to set the threshold for the matchtemplate result,

In this python tutorial link, you can check the last example.

It is a easy job in python, you can use np.where( im > threshold), to get it done. Which also shown in the example code,

But I don't know how to make in cpp.

Seems no numpy tool in cpp.

I check the stack overflow link

And use the syntax Mat >threshold but seems not work. I use the image watch extension in Vi sual Studio, and get the totally white result.

image description.

So how to make the threshold for the result in cpp.

---update---

Thanks for all the reply.

I already make it.

I wrote a post to answer this question but don't why is gone after I click the "answer" button...

Make it brief, I want to use threshold to filter the matchtemplate result in cpp. All code is here, the key points are : * normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() ); so the result can be thresholded by the value in the range(0~1) which is more convenient.

  • Mat threshold_im = result > 0.9 // filter the points which is matched.

  • findNonZero(threshold_im, locations); //// find the matched points

Really unfamiliar with the post syntax... bad format sorry...

I upload the code, if any one use it. Maybe just me need it :D code link