Skip to content
Snippets Groups Projects
Commit bdd5ae6e authored by Sergi Pujol's avatar Sergi Pujol
Browse files

scaneFalkoList created, functions adapted with static_pointer_cast

parent ca41f142
No related branches found
No related tags found
1 merge request!4Resolve "Implementation of Falko lib"
......@@ -51,7 +51,7 @@ public:
*closures
**/
virtual std::map<double,matchLoopClosurePtr>
findLoopClosure(std::list<sceneBasePtr> _l_scenes,
findLoopClosure(sceneBaseListPtr _l_scenes,
const sceneBasePtr _new_scene)=0;
};
} /* namespace laserscanutils */
......
......@@ -73,7 +73,7 @@ class loopClosureFalko : public loopClosureBase2d,
public falkolib::FALKOExtractor {
private:
public:
typedef std::shared_ptr<sceneFalko<D>> sceneFalkoBSCPtr;
typedef std::shared_ptr<SceneFalko<D>> sceneFalkoBSCPtr;
typedef std::shared_ptr<falkolib::LaserScan> laserScanPtr;
Extr extractor_;
......@@ -105,7 +105,7 @@ public:
/** \brief Create and update the scene struct with keypoints and descriptors
**/
sceneBasePtr extractScene(LaserScan &_scan, LaserScanParams &_scan_params) override{
auto new_scene = std::make_shared<sceneFalko<D>>();
auto new_scene = std::make_shared<SceneFalko<D>>();
auto scan_falko =
convert2LaserScanFALKO(_scan, _scan_params);
// Extract keypoints
......@@ -134,8 +134,8 @@ public:
matchLoopClosurePtr matchScene(sceneBasePtr _scene1,
sceneBasePtr _scene2) override{
std::vector<std::pair<int, int>> asso_nn;
auto scene_1_falko =std::static_pointer_cast<sceneFalko<D>>(_scene1);
auto scene_2_falko =std::static_pointer_cast<sceneFalko<D>>(_scene2);
auto scene_1_falko =std::static_pointer_cast<SceneFalko<D>>(_scene1);
auto scene_2_falko =std::static_pointer_cast<SceneFalko<D>>(_scene2);
int matching_number =
matcher_.match(scene_1_falko->keypoints_list_,
scene_2_falko->keypoints_list_, asso_nn);
......@@ -158,13 +158,14 @@ public:
*closures
**/
std::map<double,matchLoopClosurePtr>
findLoopClosure(std::list<sceneBasePtr> _l_scenes,
findLoopClosure(sceneBaseListPtr _l_scenes,
const sceneBasePtr _new_scene) override{
auto new_scene_falko = std::static_pointer_cast<sceneFalko<D>>(_new_scene);
auto _l_scenes_falko = std::static_pointer_cast<SceneFalkoList<D>>(_l_scenes);
auto new_scene_falko = std::static_pointer_cast<SceneFalko<D>>(_new_scene);
std::map<double,matchLoopClosurePtr> matchings;
for (auto scene : _l_scenes)
for (auto scene : _l_scenes_falko->scenes_)
{
auto ref_scene = std::static_pointer_cast<sceneFalko<D>>(scene);
auto ref_scene = std::static_pointer_cast<SceneFalko<D>>(scene);
auto match = matchScene(ref_scene, new_scene_falko);
matchings.emplace(match->score, match);
}
......
......@@ -13,10 +13,13 @@
namespace laserscanutils {
struct SceneBase {
};
typedef std::shared_ptr<SceneBase> sceneBasePtr;
struct sceneBase {
struct SceneBaseList {
};
typedef std::shared_ptr<sceneBase> sceneBasePtr;
typedef std::shared_ptr<SceneBaseList> sceneBaseListPtr;
} /* namespace laserscanutils */
......
......@@ -10,6 +10,9 @@
#include <fstream>
#include <iostream>
#include <iterator>
#include <list>
#include <memory>
/**************************
* LaserScanUtils includes *
......@@ -32,11 +35,16 @@
namespace laserscanutils {
template <typename D> struct sceneFalko : public sceneBase {
template <typename D> struct SceneFalko : public SceneBase {
std::vector<falkolib::FALKO> keypoints_list_;
std::vector<D> descriptors_list_;
};
template <typename D> struct SceneFalkoList : public SceneBaseList {
public:
std::list<std::shared_ptr<SceneFalko<D>>> scenes_;
};
} /* namespace laserscanutils */
#endif /* SCENE_FALKO_H_ */
......@@ -28,8 +28,8 @@ TEST(loop_closure_falko, TestLoopClosureFalkoAllFunctions) {
ASSERT_EQ(firstPoint, 250);
// Test extractScene
auto new_scene = std::static_pointer_cast<sceneFalko<bsc>>(loop_cl_falko.extractScene(scan, laser_params));
auto new_scene2 = std::static_pointer_cast<sceneFalko<bsc>>(loop_cl_falko.extractScene(scan2, laser_params));
auto new_scene = std::static_pointer_cast<SceneFalko<bsc>>(loop_cl_falko.extractScene(scan, laser_params));
auto new_scene2 = std::static_pointer_cast<SceneFalko<bsc>>(loop_cl_falko.extractScene(scan2, laser_params));
int detectedKeypoints = new_scene->keypoints_list_.size();
int detectedDescriptors = new_scene->descriptors_list_.size();
ASSERT_EQ(detectedKeypoints, 18);
......@@ -40,13 +40,12 @@ TEST(loop_closure_falko, TestLoopClosureFalkoAllFunctions) {
ASSERT_EQ(new_match->keypoints_number_match, 18);
// TEST findLoopClosure
std::list<std::shared_ptr<sceneFalko<bsc>>> ref_scenes;
ref_scenes.push_back(new_scene);
ref_scenes.push_back(new_scene2);
//auto matchings = loop_cl_falko.findLoopClosure(ref_scenes, new_scene);
/*
auto ref_scenes= std::make_shared<SceneFalkoList<bsc>>();
ref_scenes->scenes_.emplace_back(new_scene);
ref_scenes->scenes_.emplace_back(new_scene2);
auto matchings = loop_cl_falko.findLoopClosure(ref_scenes, new_scene);
ASSERT_EQ(matchings.size(), 2);
auto best_match = matchings.rbegin()->second;
ASSERT_EQ(best_match->match, true);
......@@ -55,7 +54,7 @@ TEST(loop_closure_falko, TestLoopClosureFalkoAllFunctions) {
ASSERT_EQ(best_match->scene_2, new_scene);
ASSERT_EQ(best_match->score, 1);
*/
// PRINTF("All good at TestTest::DummyTestExample !\n");
}
......
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