Skip to content
Snippets Groups Projects
Commit 758cdee6 authored by Angel Santamaria-Navarro's avatar Angel Santamaria-Navarro
Browse files

adde update of kp in example

parent d83a1b0c
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
std::cout << std::endl << "Which DETECTOR do you want to test?[default: " << detectors_list[feat_type] << "]";
feat_type = readFromUser(feat_type);
// feat_type = readFromUser(feat_type);
detector.set(detectors_list[feat_type],detector_params);
......@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
std::cout << std::endl << "Which DESCRIPTOR do you want to test?[default: " << descriptor_list[desc_type] << "]";
desc_type = readFromUser(desc_type);
// desc_type = readFromUser(desc_type);
descriptor.set(descriptor_list[desc_type],descriptor_params);
......@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
std::cout << std::endl << "Which MATCHER do you want to test?[default: " << matchers_list[match_type] << "]";
match_type = readFromUser(match_type);
// match_type = readFromUser(match_type);
matcher.set(matchers_list[match_type],matcher_params);
......@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
std::cout << std::endl << "Which MATCHER do you want to test?[default: " << matchers_search_list[match_search_type] << "]";
match_search_type = readFromUser(match_search_type);
// match_search_type = readFromUser(match_search_type);
matcher.setSearchType(matchers_search_list[match_search_type],matcher_search_params);
......@@ -137,13 +137,17 @@ int main(int argc, char *argv[])
cv::Mat descriptors;
descriptors = descriptor.getDescriptor(frame,keypoints);
// // Matcher
// if (nframe > 0)
// {
// std::vector<cv::DMatch> matches;
// matcher.match(keypoints,keypoints_old,matches);
// }
// keypoints_old = keypoints;
// Matcher
if (nframe > 1)
{
std::vector<cv::DMatch> matches;
matcher.match(keypoints,keypoints_old,matches);
}
// update old keypoints
keypoints_old.clear();
for (unsigned int ii = 0; ii < keypoints.size(); ++ii)
keypoints_old.push_back(keypoints[ii]);
// Show frame with features
detector.drawKeyFeatures(frame, keypoints);
......
......@@ -113,7 +113,8 @@ cv::Mat CFeature_Descriptor::getDescriptor(const cv::Mat& _image, KeyPointVector
cv::Mat descriptors;
clock_t tStart = clock();
feature_descriptor_->compute(_image, _kpts, descriptors);
if (!_kpts.empty())
feature_descriptor_->compute(_image, _kpts, descriptors);
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
return descriptors;
......
......@@ -112,6 +112,7 @@ bool CFeature_Matcher::init(const std::string& _type, const CMatcher_Params& _pa
// TODO: Match features and process matches (e.g. https://github.com/kipr/opencv/blob/master/samples/cpp/detector_descriptor_matcher_evaluation.cpp)
void CFeature_Matcher::match(const KeyPointVector& _kpts1, const KeyPointVector& _kpts2, std::vector<cv::DMatch>& matches)
{
std::cout << __LINE__ << std::endl;
if (!is_init_)
std::cerr << "[CFeature_Matcher::match]: Matcher non initialized." << std::endl;
......@@ -119,7 +120,9 @@ void CFeature_Matcher::match(const KeyPointVector& _kpts1, const KeyPointVector&
{
clock_t tStart = clock();
// TODO: use parameters related with the search type (match_search_params_)
feature_matcher_->match( _kpts1, _kpts2, matches);
std::cout << __LINE__ << " " << _kpts1.size() << " " << _kpts2.size() << std::endl;
if (!_kpts1.empty() && !_kpts2.empty())
feature_matcher_->match( _kpts1, _kpts2, matches);
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
}
else
......@@ -136,16 +139,17 @@ void CFeature_Matcher::match(const KeyPointVector& _kpts1, const KeyPointVector&
{
clock_t tStart = clock();
// TODO: use parameters related with the search type (match_search_params_)
feature_matcher_->knnMatch(_kpts1, _kpts2, matches, 2);
if (!_kpts1.empty() && !_kpts2.empty())
feature_matcher_->knnMatch(_kpts1, _kpts2, matches, 2);
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
}
else if (match_search_type_.compare(match_search_types_(2))==0) // radius match
{
clock_t tStart = clock();
// TODO: use parameters related with the search type (match_search_params_)
feature_matcher_->radiusMatch(_kpts1, _kpts2, matches, 2);
if (!_kpts1.empty() && !_kpts2.empty())
feature_matcher_->radiusMatch(_kpts1, _kpts2, matches, 2);
comp_time_ = (double)(clock() - tStart) / CLOCKS_PER_SEC;
}
else
std::cerr << "[CFeature_Matcher::match]: The selected matcher output is different than your object." << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment