1 | initial version |
No the problem is probably here that if there are NO 2 centroids, then the norm function will indeed give you problems. Add the following check before these lines of code.
if(mc.size() < 2){
cerr << "not enough points to match." << endl;
return -1;
}
This line will check if their is enough data for the norm function.
2 | No.2 Revision |
SOLUTION grabbed from comments:
To avoid the error the @LorenaGdL is talking about, you could add
if(!contours.empty()){
Moments mom = cv::moments(contours[0]);
}
And then you will be safe nevertheless.
No the problem is probably here that if there are NO 2 centroids, then the norm function will indeed give you problems. Add the following check before these lines of code.
if(mc.size() < 2){
cerr << "not enough points to match." << endl;
return -1;
}
This line will check if their is enough data for the norm function.