-1

I want to find best match by a level of threshold.

Here is what i did but the values are staying at 0.

cvMatchTemplate(src, tmp, result, CV_TM_CCORR_NORMED);
CvPoint minLoc = new CvPoint();
CvPoint maxLoc = new CvPoint();
DoublePointer min_val = new DoublePointer();
DoublePointer max_val = new DoublePointer();

cvMinMaxLoc(result,min_val, max_val, minLoc, maxLoc, null);

I don't really get the double pointers but it was required by the mothode. min_value and max_value are staying at zero so i cant find the best matches.

Thanks in advanced.Using javaCV.

David Barishev
  • 534
  • 7
  • 30

1 Answers1

0

In the example here they used primitive doubles, not Double type and they defined arrays, not just objects. So, why don't you give it a shot and let us know if it would make any difference.

cvMatchTemplate(src, tmp, result, CV_TM_CCORR_NORMED);

double[] min_val = new double[2];
double[] max_val = new double[2];
CvPoint minLoc = new CvPoint();
CvPoint maxLoc = new CvPoint();

cvMinMaxLoc(result, min_val, max_val, minLoc, maxLoc,null);

__UPDATE__

I found the following code from here

// Match Template Function from OpenCV
cvMatchTemplate(src, tmp, result, CV_TM_CCORR_NORMED);

// double[] min_val = new double[2];
// double[] max_val = new double[2];
DoublePointer min_val = new DoublePointer();
DoublePointer max_val = new DoublePointer();

CvPoint minLoc = new CvPoint();
CvPoint maxLoc = new CvPoint();

cvMinMaxLoc(result, min_val, max_val, minLoc, maxLoc, null);

Pay attention to how they instantiated DoublePointer() without any params. If it does not help, I am not sure what this thing is about. I hope it works.

Alp
  • 3,027
  • 1
  • 13
  • 28