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

added matcher bruteforce hamming

parent 4309e066
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,9 @@ SET(sources
matchers/bruteforce/matcher_bruteforce.cpp
matchers/bruteforce/matcher_bruteforce_load_yaml.cpp
matchers/bruteforce_l1/matcher_bruteforce_l1.cpp
matchers/bruteforce_l1/matcher_bruteforce_l1_load_yaml.cpp)
matchers/bruteforce_l1/matcher_bruteforce_l1_load_yaml.cpp
matchers/bruteforce_hamming/matcher_bruteforce_hamming.cpp
matchers/bruteforce_hamming/matcher_bruteforce_hamming_load_yaml.cpp )
# application header files
SET(headers
......@@ -98,7 +100,8 @@ SET(headers
matchers/matcher_base.h
matchers/flannbased/matcher_flannbased.h
matchers/bruteforce/matcher_bruteforce.h
matchers/bruteforce_l1/matcher_bruteforce_l1.h)
matchers/bruteforce_l1/matcher_bruteforce_l1.h
matchers/bruteforce_hamming/matcher_bruteforce_hamming.h)
# locate the necessary dependencies
FIND_PACKAGE(Eigen3 REQUIRED)
......
......@@ -38,6 +38,7 @@
#include "../matchers/flannbased/matcher_flannbased.h"
#include "../matchers/bruteforce/matcher_bruteforce.h"
#include "../matchers/bruteforce_l1/matcher_bruteforce_l1.h"
#include "../matchers/bruteforce_hamming/matcher_bruteforce_hamming.h"
int main(void)
{
......@@ -118,7 +119,7 @@ int main(void)
std::cout << "\n================ MATCHER TEST =================" << std::endl;
std::string def_matcher = "BRUTEFORCEL1";
std::string def_matcher = "BRUTEFORCE_HAMMING";
std::cout << std::endl << "Which MATCHER do you want to test? Type one of the registered names [default: " << def_matcher << "]: ";
std::string mat_name = readFromUser(def_matcher);
......@@ -128,8 +129,10 @@ int main(void)
mat_ptr = std::static_pointer_cast<MatcherFLANNBASED>(mat_ptr);
if (mat_name.compare("BRUTEFORCE") == 0)
mat_ptr = std::static_pointer_cast<MatcherBRUTEFORCE>(mat_ptr);
if (mat_name.compare("BRUTEFORCEL1") == 0)
mat_ptr = std::static_pointer_cast<MatcherBRUTEFORCEL1>(mat_ptr);
if (mat_name.compare("BRUTEFORCE_L1") == 0)
mat_ptr = std::static_pointer_cast<MatcherBRUTEFORCE_L1>(mat_ptr);
if (mat_name.compare("BRUTEFORCE_HAMMING") == 0)
mat_ptr = std::static_pointer_cast<MatcherBRUTEFORCE_HAMMING>(mat_ptr);
std::cout << std::endl << "... Testing " << det_ptr->getName() << " with " << des_ptr->getName() << " and " << mat_ptr->getName() << " ..." << std::endl;
......
sensor:
type: "USB_CAM"
matcher:
type: "BRUTEFORCE_HAMMING"
match type: 1 # Match type. MATCH = 1, KNNMATCH = 2, RADIUSMATCH = 3
\ No newline at end of file
sensor:
type: "USB_CAM"
matcher:
type: "BRUTEFORCEL1"
type: "BRUTEFORCE_L1"
match type: 1 # Match type. MATCH = 1, KNNMATCH = 2, RADIUSMATCH = 3
\ No newline at end of file
#include "matcher_bruteforce_hamming.h"
namespace vision_utils {
MatcherBRUTEFORCE_HAMMING::MatcherBRUTEFORCE_HAMMING(void)
{}
MatcherBRUTEFORCE_HAMMING::~MatcherBRUTEFORCE_HAMMING(void)
{}
} /* namespace vision_utils */
// Register in the MatchersFactory
namespace vision_utils
{
VU_REGISTER_MATCHER("BRUTEFORCE_HAMMING", MatcherBRUTEFORCE_HAMMING);
} /* namespace vision_utils */
#ifndef _MATCHER_BRUTEFORCE_HAMMING_H_
#define _MATCHER_BRUTEFORCE_HAMMING_H_
#include "../matcher_base.h"
#include "../matcher_factory.h"
// yaml-cpp library
#ifdef USING_YAML
#include <yaml-cpp/yaml.h>
#endif
namespace vision_utils {
// Create all pointers
VU_PTR_TYPEDEFS(MatcherBRUTEFORCE_HAMMING);
VU_PTR_TYPEDEFS(MatcherParamsBRUTEFORCE_HAMMING);
/** \brief Class parameters
*
*/
struct MatcherParamsBRUTEFORCE_HAMMING: public MatcherParamsBase
{
// TODO: Add possible parameters
};
/** \brief DETECTOR class
*
*/
class MatcherBRUTEFORCE_HAMMING : public MatcherBase {
public:
MatcherBRUTEFORCE_HAMMING();
virtual ~MatcherBRUTEFORCE_HAMMING(void);
// Factory method
static MatcherBasePtr create(const std::string& _unique_name, const ParamsBasePtr _params);
private:
void defineMatcher(const ParamsBasePtr _params);
};
/*
* brief Define detector
*/
inline void MatcherBRUTEFORCE_HAMMING::defineMatcher(const ParamsBasePtr _params)
{
params_base_ptr_ = std::static_pointer_cast<MatcherParamsBase>(_params);
MatcherParamsBRUTEFORCE_HAMMINGPtr params_ptr = std::static_pointer_cast<MatcherParamsBRUTEFORCE_HAMMING>(_params);
matcher_ = cv::DescriptorMatcher::create("BruteForce-Hamming");
}
/*
* brief Create object in factory
*/
inline MatcherBasePtr MatcherBRUTEFORCE_HAMMING::create(const std::string& _unique_name, const ParamsBasePtr _params)
{
MatcherBRUTEFORCE_HAMMINGPtr mat_ptr = std::make_shared<MatcherBRUTEFORCE_HAMMING>();
mat_ptr->setName(_unique_name);
mat_ptr->defineMatcher(_params);
return mat_ptr;
}
} /* namespace vision_utils */
#endif /* _MATCHER_BRUTEFORCE_HAMMING_H_ */
#include "matcher_bruteforce_hamming.h"
#ifdef USING_YAML
// yaml-cpp library
#include <yaml-cpp/yaml.h>
namespace vision_utils
{
namespace
{
static ParamsBasePtr createParamsBRUTEFORCE_HAMMINGMatcher(const std::string & _filename_dot_yaml)
{
MatcherParamsBRUTEFORCE_HAMMINGPtr params_ptr = std::make_shared<MatcherParamsBRUTEFORCE_HAMMING>();
using std::string;
using YAML::Node;
Node yaml_params = YAML::LoadFile(_filename_dot_yaml);
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["matcher"];
if(d_yaml["type"].as<string>() == "BRUTEFORCE_HAMMING")
{
params_ptr->match_type = d_yaml["match type"].as<int>();
// TODO: Add possible parameters
}else
{
std::cerr << "Bad configuration file. Wrong type " << d_yaml["type"].as<string>() << std::endl;
return nullptr;
}
}
return params_ptr;
}
// Register in the SensorFactory
const bool registered_matBRUTEFORCE_HAMMING_params = ParamsFactory::get().registerCreator("BRUTEFORCE_HAMMING MAT", createParamsBRUTEFORCE_HAMMINGMatcher);
} /* namespace [unnamed] */
} /* namespace vision_utils */
#endif /* IF USING_YAML */
......@@ -2,10 +2,10 @@
namespace vision_utils {
MatcherBRUTEFORCEL1::MatcherBRUTEFORCEL1(void)
MatcherBRUTEFORCE_L1::MatcherBRUTEFORCE_L1(void)
{}
MatcherBRUTEFORCEL1::~MatcherBRUTEFORCEL1(void)
MatcherBRUTEFORCE_L1::~MatcherBRUTEFORCE_L1(void)
{}
} /* namespace vision_utils */
......@@ -13,5 +13,5 @@ MatcherBRUTEFORCEL1::~MatcherBRUTEFORCEL1(void)
// Register in the MatchersFactory
namespace vision_utils
{
VU_REGISTER_MATCHER("BRUTEFORCEL1", MatcherBRUTEFORCEL1);
VU_REGISTER_MATCHER("BRUTEFORCE_L1", MatcherBRUTEFORCE_L1);
} /* namespace vision_utils */
#ifndef _MATCHER_BRUTEFORCEL1_H_
#define _MATCHER_BRUTEFORCEL1_H_
#ifndef _MATCHER_BRUTEFORCE_L1_H_
#define _MATCHER_BRUTEFORCE_L1_H_
#include "../matcher_base.h"
#include "../matcher_factory.h"
......@@ -12,13 +12,13 @@
namespace vision_utils {
// Create all pointers
VU_PTR_TYPEDEFS(MatcherBRUTEFORCEL1);
VU_PTR_TYPEDEFS(MatcherParamsBRUTEFORCEL1);
VU_PTR_TYPEDEFS(MatcherBRUTEFORCE_L1);
VU_PTR_TYPEDEFS(MatcherParamsBRUTEFORCE_L1);
/** \brief Class parameters
*
*/
struct MatcherParamsBRUTEFORCEL1: public MatcherParamsBase
struct MatcherParamsBRUTEFORCE_L1: public MatcherParamsBase
{
// TODO: Add possible parameters
};
......@@ -26,11 +26,11 @@ struct MatcherParamsBRUTEFORCEL1: public MatcherParamsBase
/** \brief DETECTOR class
*
*/
class MatcherBRUTEFORCEL1 : public MatcherBase {
class MatcherBRUTEFORCE_L1 : public MatcherBase {
public:
MatcherBRUTEFORCEL1();
virtual ~MatcherBRUTEFORCEL1(void);
MatcherBRUTEFORCE_L1();
virtual ~MatcherBRUTEFORCE_L1(void);
// Factory method
static MatcherBasePtr create(const std::string& _unique_name, const ParamsBasePtr _params);
......@@ -43,19 +43,19 @@ class MatcherBRUTEFORCEL1 : public MatcherBase {
/*
* brief Define detector
*/
inline void MatcherBRUTEFORCEL1::defineMatcher(const ParamsBasePtr _params)
inline void MatcherBRUTEFORCE_L1::defineMatcher(const ParamsBasePtr _params)
{
params_base_ptr_ = std::static_pointer_cast<MatcherParamsBase>(_params);
MatcherParamsBRUTEFORCEL1Ptr params_ptr = std::static_pointer_cast<MatcherParamsBRUTEFORCEL1>(_params);
MatcherParamsBRUTEFORCE_L1Ptr params_ptr = std::static_pointer_cast<MatcherParamsBRUTEFORCE_L1>(_params);
matcher_ = cv::DescriptorMatcher::create("BruteForce-L1");
}
/*
* brief Create object in factory
*/
inline MatcherBasePtr MatcherBRUTEFORCEL1::create(const std::string& _unique_name, const ParamsBasePtr _params)
inline MatcherBasePtr MatcherBRUTEFORCE_L1::create(const std::string& _unique_name, const ParamsBasePtr _params)
{
MatcherBRUTEFORCEL1Ptr mat_ptr = std::make_shared<MatcherBRUTEFORCEL1>();
MatcherBRUTEFORCE_L1Ptr mat_ptr = std::make_shared<MatcherBRUTEFORCE_L1>();
mat_ptr->setName(_unique_name);
mat_ptr->defineMatcher(_params);
return mat_ptr;
......@@ -63,4 +63,4 @@ inline MatcherBasePtr MatcherBRUTEFORCEL1::create(const std::string& _unique_nam
} /* namespace vision_utils */
#endif /* _MATCHER_BRUTEFORCEL1_H_ */
#endif /* _MATCHER_BRUTEFORCE_L1_H_ */
......@@ -11,9 +11,9 @@ namespace vision_utils
namespace
{
static ParamsBasePtr createParamsBRUTEFORCEL1Matcher(const std::string & _filename_dot_yaml)
static ParamsBasePtr createParamsBRUTEFORCE_L1Matcher(const std::string & _filename_dot_yaml)
{
MatcherParamsBRUTEFORCEL1Ptr params_ptr = std::make_shared<MatcherParamsBRUTEFORCEL1>();
MatcherParamsBRUTEFORCE_L1Ptr params_ptr = std::make_shared<MatcherParamsBRUTEFORCE_L1>();
using std::string;
using YAML::Node;
......@@ -21,7 +21,7 @@ static ParamsBasePtr createParamsBRUTEFORCEL1Matcher(const std::string & _filena
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["matcher"];
if(d_yaml["type"].as<string>() == "BRUTEFORCEL1")
if(d_yaml["type"].as<string>() == "BRUTEFORCE_L1")
{
params_ptr->match_type = d_yaml["match type"].as<int>();
// TODO: Add possible parameters
......@@ -36,7 +36,7 @@ static ParamsBasePtr createParamsBRUTEFORCEL1Matcher(const std::string & _filena
}
// Register in the SensorFactory
const bool registered_matBRUTEFORCEL1_params = ParamsFactory::get().registerCreator("BRUTEFORCEL1 MAT", createParamsBRUTEFORCEL1Matcher);
const bool registered_matBRUTEFORCE_L1_params = ParamsFactory::get().registerCreator("BRUTEFORCE_L1 MAT", createParamsBRUTEFORCE_L1Matcher);
} /* namespace [unnamed] */
......
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