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

FIX API

parent 8c55a392
No related branches found
No related tags found
No related merge requests found
...@@ -261,7 +261,7 @@ int main(int argc, char** argv) ...@@ -261,7 +261,7 @@ int main(int argc, char** argv)
t_filter += double(tFilter - tMatch )/CLOCKS_PER_MSEC; t_filter += double(tFilter - tMatch )/CLOCKS_PER_MSEC;
t_fund += double( tFund - tFilter)/CLOCKS_PER_MSEC; t_fund += double( tFund - tFilter)/CLOCKS_PER_MSEC;
std::cout << "det: " << t_det/n_iter << "ms - desc: " << t_desc/n_iter << "ms - match: " << t_match/n_iter << "ms - filter: " << t_filter/n_iter << "ms - fund: " << t_fund/n_iter << "ms" << std::endl; std::cout << "det: " << t_det/n_iter << "ms - desc: " << t_desc/n_iter << "ms - match: " << t_match/n_iter << "ms - filter: " << t_filter/n_iter << "ms - found: " << t_fund/n_iter << "ms" << std::endl;
std::cout << "+++++++++++++++" << std::endl; std::cout << "+++++++++++++++" << std::endl;
......
...@@ -142,8 +142,6 @@ int main(void) ...@@ -142,8 +142,6 @@ int main(void)
if (nframe > 1) if (nframe > 1)
{ {
DMatchVector best_matches; DMatchVector best_matches;
KeyPointVector kpts_matched_curf;
KeyPointVector kpts_matched_prevf;
// get params // get params
MatcherParamsBasePtr mat_params_ptr = mat_ptr->getParams(); MatcherParamsBasePtr mat_params_ptr = mat_ptr->getParams();
...@@ -155,7 +153,7 @@ int main(void) ...@@ -155,7 +153,7 @@ int main(void)
mat_ptr->match(descriptors_old,descriptors,des_ptr->getSize(),matches); mat_ptr->match(descriptors_old,descriptors,des_ptr->getSize(),matches);
// filter // filter
mat_ptr->filterByDistance(10, 0.25, kpts_old, kpts, matches, frame_cur.rows, frame_cur.cols, kpts_matched_prevf, kpts_matched_curf, best_matches); mat_ptr->filterByDistance(10, 0.25, kpts_old, kpts, matches, frame_cur.rows, frame_cur.cols, best_matches);
} }
else else
{ {
...@@ -164,9 +162,19 @@ int main(void) ...@@ -164,9 +162,19 @@ int main(void)
mat_ptr->match(descriptors_old,descriptors,des_ptr->getSize(),matches); mat_ptr->match(descriptors_old,descriptors,des_ptr->getSize(),matches);
//filter //filter
mat_ptr->filterByDistance(10, 0.25, kpts_old, kpts, matches, frame_cur.rows, frame_cur.cols, kpts_matched_prevf, kpts_matched_curf, best_matches); mat_ptr->filterByDistance(10, 0.25, kpts_old, kpts, matches, frame_cur.rows, frame_cur.cols, best_matches);
} }
// Get matched KeyPoints
KeyPointVector kpts_matched_curf;
KeyPointVector kpts_matched_prevf;
for (auto match : best_matches)
{
kpts_matched_prevf.push_back(kpts_old[match.queryIdx]);
kpts_matched_curf.push_back(kpts[match.trainIdx]);
}
// Draw // Draw
frame_old = frame_cur.clone(); frame_old = frame_cur.clone();
frame_matches = frame_cur.clone(); frame_matches = frame_cur.clone();
......
This diff is collapsed.
...@@ -95,10 +95,6 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa ...@@ -95,10 +95,6 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa
const cv::Mat& _raw_desc1, const cv::Mat& _raw_desc1,
const cv::Mat& _raw_desc2, const cv::Mat& _raw_desc2,
const int& desc_size_bytes, const int& desc_size_bytes,
KeyPointVector& _inlier_kps1,
KeyPointVector& _inlier_kps2,
cv::Mat& _inlier_desc1,
cv::Mat& _inlier_desc2,
DMatchVector& _inlier_matches, DMatchVector& _inlier_matches,
cv::InputArray _mask=cv::noArray()); cv::InputArray _mask=cv::noArray());
...@@ -109,8 +105,6 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa ...@@ -109,8 +105,6 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa
const DMatchVector& _dirty, const DMatchVector& _dirty,
const int& _img_width, const int& _img_width,
const int& _img_height, const int& _img_height,
KeyPointVector& _inlier_kps1,
KeyPointVector& _inlier_kps2,
DMatchVector& _inlier_matches); DMatchVector& _inlier_matches);
void filterByDistance(const int& _max_pixel_dist, void filterByDistance(const int& _max_pixel_dist,
...@@ -120,46 +114,23 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa ...@@ -120,46 +114,23 @@ class MatcherBase : public VUBase, public std::enable_shared_from_this<MatcherBa
const std::vector< DMatchVector >& _dirty, const std::vector< DMatchVector >& _dirty,
const int& _img_width, const int& _img_width,
const int& _img_height, const int& _img_height,
KeyPointVector& _inlier_kps1,
KeyPointVector& _inlier_kps2,
DMatchVector& _inlier_matches); DMatchVector& _inlier_matches);
std::vector<Scalar> filterByDistance(const KeyPointVector& _raw_kps1, void filterByDistance(const KeyPointVector& _raw_kps1,
const KeyPointVector& _raw_kps2, const KeyPointVector& _raw_kps2,
const cv::Mat& _raw_desc1,
const cv::Mat& _raw_desc2,
const DMatchVector& _raw_matches, const DMatchVector& _raw_matches,
KeyPointVector& _inlier_kps1, DMatchVector& _inlier_matches);
KeyPointVector& _inlier_kps2,
cv::Mat& _inlier_desc1, void filterByDistance(const KeyPointVector& _raw_kps1,
cv::Mat& _inlier_desc2,
DMatchVector& _inlier_matches,
const std::vector<Scalar>& _normalized_scores = std::vector<Scalar>());
std::vector<Scalar> filterByDistance(const KeyPointVector& _raw_kps1,
const KeyPointVector& _raw_kps2, const KeyPointVector& _raw_kps2,
const cv::Mat& _raw_desc1,
const cv::Mat& _raw_desc2,
const std::vector< DMatchVector >& _raw_matches, const std::vector< DMatchVector >& _raw_matches,
KeyPointVector& _inlier_kps1, DMatchVector& _inlier_matches);
KeyPointVector& _inlier_kps2,
cv::Mat& _inlier_desc1,
cv::Mat& _inlier_desc2,
DMatchVector& _inlier_matches,
const std::vector<Scalar>& _normalized_scores = std::vector<Scalar>());
// Identify good matches using RANSAC // Identify good matches using RANSAC
std::vector<Scalar> ransacTest(const KeyPointVector& _raw_kps1, void ransacTest(const KeyPointVector& _raw_kps1,
const KeyPointVector& _raw_kps2, const KeyPointVector& _raw_kps2,
cv::Mat& _raw_desc1,
cv::Mat& _raw_desc2,
const DMatchVector& _raw_matches, const DMatchVector& _raw_matches,
KeyPointVector& _inlier_kps1, DMatchVector& _inlier_matches);
KeyPointVector& _inlier_kps2,
cv::Mat& _inlier_desc1,
cv::Mat& _inlier_desc2,
DMatchVector& _inlier_matches,
const std::vector<Scalar>& _normalized_scores = std::vector<Scalar>());
// Check symmetry between nn matches from <im1->im2> and from <im2->im1> pairs // Check symmetry between nn matches from <im1->im2> and from <im2->im1> pairs
void nnSymmetryTest(const std::vector<DMatchVector>& _matches1, void nnSymmetryTest(const std::vector<DMatchVector>& _matches1,
......
...@@ -97,11 +97,8 @@ TEST(MatcherBase, filterByDistance) ...@@ -97,11 +97,8 @@ TEST(MatcherBase, filterByDistance)
mat_ptr->match(desc1,desc2,des_ptr->getSize(),matches); mat_ptr->match(desc1,desc2,des_ptr->getSize(),matches);
ASSERT_TRUE(matches.size()-75>0); ASSERT_TRUE(matches.size()-75>0);
KeyPointVector inlier_kpts1, inlier_kpts2;
cv::Mat inlier_desc1, inlier_desc2;
DMatchVector inlier_matches; DMatchVector inlier_matches;
mat_ptr->filterByDistance(kpts1, kpts2, desc1, desc2, matches, mat_ptr->filterByDistance(kpts1, kpts2, matches, inlier_matches);
inlier_kpts1, inlier_kpts2, inlier_desc1, inlier_desc2, inlier_matches);
ASSERT_TRUE(inlier_matches.size()<40); ASSERT_TRUE(inlier_matches.size()<40);
} }
...@@ -155,11 +152,8 @@ TEST(MatcherBase, ransacTest) ...@@ -155,11 +152,8 @@ TEST(MatcherBase, ransacTest)
mat_ptr->match(desc1,desc2,des_ptr->getSize(),matches); mat_ptr->match(desc1,desc2,des_ptr->getSize(),matches);
ASSERT_TRUE(matches.size()-75>0); ASSERT_TRUE(matches.size()-75>0);
KeyPointVector inlier_kpts1, inlier_kpts2;
cv::Mat inlier_desc1, inlier_desc2;
DMatchVector inlier_matches; DMatchVector inlier_matches;
mat_ptr->ransacTest(kpts1, kpts2, desc1, desc2, matches, mat_ptr->ransacTest(kpts1, kpts2, matches, inlier_matches);
inlier_kpts1, inlier_kpts2, inlier_desc1, inlier_desc2, inlier_matches);
ASSERT_TRUE(inlier_matches.size()<50); ASSERT_TRUE(inlier_matches.size()<50);
} }
......
...@@ -66,9 +66,7 @@ TEST(Matchers, MATCH) ...@@ -66,9 +66,7 @@ TEST(Matchers, MATCH)
// filter // filter
DMatchVector best_matches; DMatchVector best_matches;
KeyPointVector kpts_matched_img2; mat_ptr->filterByDistance(10, 0.25, kpts1, kpts2, matches, image1.rows, image1.cols, best_matches);
KeyPointVector kpts_matched_img1;
mat_ptr->filterByDistance(10, 0.25, kpts1, kpts2, matches, image1.rows, image1.cols, kpts_matched_img1, kpts_matched_img2, best_matches);
ASSERT_TRUE(best_matches.size()-35>0); ASSERT_TRUE(best_matches.size()-35>0);
} }
...@@ -119,9 +117,7 @@ TEST(Matchers, KNNMATCH) ...@@ -119,9 +117,7 @@ TEST(Matchers, KNNMATCH)
// filter // filter
DMatchVector best_matches; DMatchVector best_matches;
KeyPointVector kpts_matched_img2; mat_ptr->filterByDistance(10, 0.25, kpts1, kpts2, matches_vec, image1.rows, image1.cols, best_matches);
KeyPointVector kpts_matched_img1;
mat_ptr->filterByDistance(10, 0.25, kpts1, kpts2, matches_vec, image1.rows, image1.cols, kpts_matched_img1, kpts_matched_img2, best_matches);
ASSERT_TRUE(best_matches.size()-45>0); ASSERT_TRUE(best_matches.size()-45>0);
} }
......
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