Я написал приложение на c ++, которое сравнивает совпадения точек из изображений (OpenSurf C ++), но иногда, 1 из нескольких тысяч «getUniqueMatches», приложение прерывается в некоторой точке внутри «getUniqueMatches».У меня есть этот журнал:
05/13/11 10:17:16: this->pointsA = 227
05/13/11 10:17:16: this->pointsB = 226
05/13/11 10:17:16: this->matches before = 0
05/13/11 10:17:16: 227 226 0 0.650000
05/13/11 10:17:16: Starting in getUniqueMatches
-- And here breaks, inside getUniqueMatches --
И это код:
inline bool findInVector(std::vector<int> v, int value) {
int size = v.size();
for(int i=0; i<size; i++) {
if(v[i] == value) {
return true;
}
}
return false;
}
void getUniqueMatches(IpVec &ipts1, IpVec &ipts2, IpPairVec &matches, float ratio) {
try {
wLog(f("%d %d %d %f", ipts1.size(), ipts2.size(), matches.size(), ratio));
float dist, d1, d2;
Ipoint *match;
matches.clear();
std::vector<int> matched;
wLog("Starting in getUniqueMatches");
// Breaks after here
int size = ipts1.size();
int size2 = ipts2.size();
for (int i = 0; i < size; i++) {
d1 = d2 = FLT_MAX;
int foundJ = -1;
for (unsigned int j = 0; j < size2; j++) {
dist = ipts1[i] - ipts2[j];
if (dist < d1 && !findInVector(matched, j)) {
d2 = d1;
d1 = dist;
match = &ipts2[j];
foundJ = j;
} else if (dist < d2) {
d2 = dist;
}
}
if (d1 / d2 < ratio) {
ipts1[i].dx = match->x - ipts1[i].x;
ipts1[i].dy = match->y - ipts1[i].y;
matches.push_back(std::make_pair(ipts1[i], *match));
matched.push_back(foundJ);
}
}
} catch(std::exception ex) {
wLog(f("Exception in getUniqueMatches: ", ex.what()));
return;
}
}
Только несколько раз здесь ломается.Я не знаю, что происходит, может, что-то не так?Приложение использует только 1 поток при выполнении этой функции.При извлечении очков используется 10 потоков.
Использование его на Centos5 (VPS).2 Gb RAm 20% hd используется Скомпилировано с использованием g ++ (режим Performance), в IDE используется Netbeans.OpenCV, libcurl.