Closed chankam1024 closed 8 months ago
JavaCV uses 1.5.9, OpenCV uses 4.7.0, and OpenBLAS uses 0.3.23. I tried not to perform scaling and template matching in the for loop, but still prompted for NullPointerException.
Oh, I'm very sorry, I found an error in Method 2. Original code:
if (maxLoc.get() > bestMatchValue) {
bestMatchValue = maxVal.get();
bestMatchLocation = maxLoc;
}
New code:
if (maxVal.get() > bestMatchValue) {
bestMatchValue = maxVal.get();
bestMatchLocation = maxLoc;
}
I'm very sorry, the code I provided is incorrect and has been corrected, but there is still a NullPointerException.
I tried to modify the code in Method 2, and although I don't know the reason, it can now run normally.Thank you very much!
double[] minVal = new double[1];
double[] maxVal = new double[1];
Point minLoc = new Point();
Point maxLoc = new Point();
// 查找最佳匹配位置
minMaxLoc(result, minVal, maxVal, minLoc, maxLoc, null);
if (maxVal[0] > bestMatchValue) {
bestMatchValue = maxVal[0];
bestMatchLocation = maxLoc;
}
I have written two methods, one is to directly perform template matching; The second method is to first zoom and then perform template matching, because I want to achieve image matching at different resolutions. Method 1 runs normally and can be matched, but Method 2 keeps prompting NullPointerException: This pointer address is NULL. I don't know why. I hope you can help me. Thank you very much~ The following is the code.