The return value problem of Sample() function in GCoptimization.h for linux version code
wangmaoCS opened this issue · 2 comments
wangmaoCS commented
sorry for trouble!
I have configure the code in Linux OS.
However, I have found the function Sample() in file GCoptimization.h may have a problem when running the code. There is no return value, which may result in a bug in the while loop in function Run().
template <class ModelEstimator, class Model>
bool GCRANSAC<ModelEstimator, Model>::Sample(const cv::Mat &points, std::vector<int> &pool, const std::vector<std::vector<cv::DMatch>> &neighbors, int sample_number, int *sample)
{
// TODO: replacable sampler
for (int i = 0; i < sample_number; ++i)
{
int idx = (pool.size() - 1) * static_cast<float>(rand()) / RAND_MAX;
sample[i] = pool[idx];
pool.erase(pool.begin() + idx);
}
pool.reserve(pool.size() + sample_number);
for (int i = 0; i < sample_number; ++i)
pool.push_back(sample[i]);
}
while (1) // Sample while needed
{
if (!Sample(points, pool, neighbours, sample_number, sample)) // Sampling
continue;
if (estimator.EstimateModel(points, sample, &models)) // Estimate (and validate) models using the current sample
break;
}
``
I find my code will run in the while(1) loop and never end!
Is this a problem for my modified Linux version.
danini commented
Nice, it did not even give me a warning :)
I updated it and fixed things which threw warnings.
wangmaoCS commented
Thanks!
The updated code is OK!