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

added freak descriptor and all previous missing files :(

parent 3ab5a4f1
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,9 @@ SET(sources
descriptors/akaze/descriptor_akaze.cpp
descriptors/akaze/descriptor_akaze_load_yaml.cpp
descriptors/latch/descriptor_latch.cpp
descriptors/latch/descriptor_latch_load_yaml.cpp
descriptors/latch/descriptor_latch_load_yaml.cpp
descriptors/freak/descriptor_freak.cpp
descriptors/freak/descriptor_freak_load_yaml.cpp
matchers/matcher_base.cpp )
# application header files
......@@ -76,6 +78,7 @@ SET(headers
descriptors/kaze/descriptor_kaze.h
descriptors/akaze/descriptor_akaze.h
descriptors/latch/descriptor_latch.h
descriptors/freak/descriptor_freak.h
matchers/matcher_factory.h
matchers/matcher_base.h)
......
#include "descriptor_freak.h"
namespace vision_utils {
DescriptorFREAK::DescriptorFREAK(void)
{}
DescriptorFREAK::~DescriptorFREAK(void)
{}
} /* namespace vision_utils */
// Register in the DescriptorsFactory
namespace vision_utils
{
VU_REGISTER_DESCRIPTOR("FREAK", DescriptorFREAK);
} /* namespace vision_utils */
#ifndef _DESCRIPTOR_FREAK_H_
#define _DESCRIPTOR_FREAK_H_
#include "../descriptor_base.h"
#include "../descriptor_factory.h"
// yaml-cpp library
#ifdef USING_YAML
#include <yaml-cpp/yaml.h>
#endif
namespace vision_utils {
// Create all pointers
VU_PTR_TYPEDEFS(DescriptorFREAK);
VU_PTR_TYPEDEFS(DescriptorParamsFREAK);
/** \brief Class parameters
*
*/
struct DescriptorParamsFREAK: public ParamsBase
{
bool orientationNormalized = true; // Enable orientation normalization.
bool scaleNormalized = true; // Enable scale normalization.
float patternScale = 22.0; // Scaling of the description pattern.
int nOctaves = 4; // Number of octaves covered by the detected keypoints.
std::vector< int > selectedPairs = std::vector< int >(); // (Optional) user defined selected pairs indexes,
};
/** \brief DETECTOR class
*
*/
class DescriptorFREAK : public DescriptorBase {
public:
DescriptorFREAK();
virtual ~DescriptorFREAK(void);
// Factory method
static DescriptorBasePtr create(const std::string& _unique_name, const ParamsBasePtr _params);
private:
void defineDescriptor(const ParamsBasePtr _params);
};
/*
* brief Define detector
*/
inline void DescriptorFREAK::defineDescriptor(const ParamsBasePtr _params)
{
DescriptorParamsFREAKPtr params_ptr = std::static_pointer_cast<DescriptorParamsFREAK>(_params);
descriptor_ = cv::xfeatures2d::FREAK::create(params_ptr->orientationNormalized,
params_ptr->scaleNormalized,
params_ptr->patternScale,
params_ptr->nOctaves,
params_ptr->selectedPairs);
}
/*
* brief Create object in factory
*/
inline DescriptorBasePtr DescriptorFREAK::create(const std::string& _unique_name, const ParamsBasePtr _params)
{
DescriptorFREAKPtr det_ptr = std::make_shared<DescriptorFREAK>();
det_ptr->setName(_unique_name);
det_ptr->defineDescriptor(_params);
return det_ptr;
}
} /* namespace vision_utils */
#endif /* _DESCRIPTOR_FREAK_H_ */
#include "descriptor_freak.h"
#ifdef USING_YAML
// yaml-cpp library
#include <yaml-cpp/yaml.h>
namespace vision_utils
{
namespace
{
static ParamsBasePtr createParamsFREAKDescriptor(const std::string & _filename_dot_yaml)
{
DescriptorParamsFREAKPtr params_ptr = std::make_shared<DescriptorParamsFREAK>();
using std::string;
using YAML::Node;
Node yaml_params = YAML::LoadFile(_filename_dot_yaml);
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["descriptor"];
if(d_yaml["type"].as<string>() == "FREAK")
{
params_ptr->orientationNormalized = d_yaml["orientationNormalized"].as<bool>();
params_ptr->scaleNormalized = d_yaml["scaleNormalized"].as<bool>();
params_ptr->patternScale = d_yaml["patternScale"].as<float>();
params_ptr->nOctaves = d_yaml["nOctaves"].as<int>();
params_ptr->selectedPairs = d_yaml["selectedPairs"].as<std::vector< int > >();
}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_desFREAK_params = ParamsFactory::get().registerCreator("FREAK DES", createParamsFREAKDescriptor);
} /* namespace [unnamed] */
} /* namespace vision_utils */
#endif /* IF USING_YAML */
#include "descriptor_latch.h"
namespace vision_utils {
DescriptorLATCH::DescriptorLATCH(void)
{}
DescriptorLATCH::~DescriptorLATCH(void)
{}
} /* namespace vision_utils */
// Register in the DescriptorsFactory
namespace vision_utils
{
VU_REGISTER_DESCRIPTOR("LATCH", DescriptorLATCH);
} /* namespace vision_utils */
#ifndef _DESCRIPTOR_LATCH_H_
#define _DESCRIPTOR_LATCH_H_
#include "../descriptor_base.h"
#include "../descriptor_factory.h"
// yaml-cpp library
#ifdef USING_YAML
#include <yaml-cpp/yaml.h>
#endif
namespace vision_utils {
// Create all pointers
VU_PTR_TYPEDEFS(DescriptorLATCH);
VU_PTR_TYPEDEFS(DescriptorParamsLATCH);
/** \brief Class parameters
*
*/
struct DescriptorParamsLATCH: public ParamsBase
{
int bytes = 32; // Size of the descriptor - can be 64, 32, 16, 8, 4, 2 or 1
bool rotationInvariance = true; // Whether or not the descriptor should compansate for orientation changes
int half_ssd_size = 3; // Size of half of the mini-patches size
};
/** \brief DETECTOR class
*
*/
class DescriptorLATCH : public DescriptorBase {
public:
DescriptorLATCH();
virtual ~DescriptorLATCH(void);
// Factory method
static DescriptorBasePtr create(const std::string& _unique_name, const ParamsBasePtr _params);
private:
void defineDescriptor(const ParamsBasePtr _params);
};
/*
* brief Define detector
*/
inline void DescriptorLATCH::defineDescriptor(const ParamsBasePtr _params)
{
DescriptorParamsLATCHPtr params_ptr = std::static_pointer_cast<DescriptorParamsLATCH>(_params);
descriptor_ = cv::xfeatures2d::LATCH::create(params_ptr->bytes,
params_ptr->rotationInvariance,
params_ptr->half_ssd_size);
}
/*
* brief Create object in factory
*/
inline DescriptorBasePtr DescriptorLATCH::create(const std::string& _unique_name, const ParamsBasePtr _params)
{
DescriptorLATCHPtr det_ptr = std::make_shared<DescriptorLATCH>();
det_ptr->setName(_unique_name);
det_ptr->defineDescriptor(_params);
return det_ptr;
}
} /* namespace vision_utils */
#endif /* _DESCRIPTOR_LATCH_H_ */
#include "descriptor_latch.h"
#ifdef USING_YAML
// yaml-cpp library
#include <yaml-cpp/yaml.h>
namespace vision_utils
{
namespace
{
static ParamsBasePtr createParamsLATCHDescriptor(const std::string & _filename_dot_yaml)
{
DescriptorParamsLATCHPtr params_ptr = std::make_shared<DescriptorParamsLATCH>();
using std::string;
using YAML::Node;
Node yaml_params = YAML::LoadFile(_filename_dot_yaml);
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["descriptor"];
if(d_yaml["type"].as<string>() == "LATCH")
{
params_ptr->bytes = d_yaml["bytes"].as<int>();
params_ptr->rotationInvariance = d_yaml["rotationInvariance"].as<bool>();
params_ptr->half_ssd_size = d_yaml["half_ssd_size"].as<int>();
}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_desLATCH_params = ParamsFactory::get().registerCreator("LATCH DES", createParamsLATCHDescriptor);
} /* namespace [unnamed] */
} /* namespace vision_utils */
#endif /* IF USING_YAML */
......@@ -29,7 +29,7 @@
#include "../descriptors/kaze/descriptor_kaze.h"
#include "../descriptors/akaze/descriptor_akaze.h"
#include "../descriptors/latch/descriptor_latch.h"
//#include "../descriptors/freak/descriptor_freak.h"
#include "../descriptors/freak/descriptor_freak.h"
//#include "../descriptors/brief/descriptor_brief.h"
//#include "../descriptors/daisy/descriptor_daisy.h"
//#include "../descriptors/lucid/descriptor_lucid.h"
......@@ -104,8 +104,8 @@ int main(void)
des_ptr = std::static_pointer_cast<DescriptorAKAZE>(des_ptr);
else if (des_name.compare("LATCH") == 0)
des_ptr = std::static_pointer_cast<DescriptorLATCH>(des_ptr);
// else if (des_name.compare("FREAK") == 0)
// des_ptr = std::static_pointer_cast<DescriptorFREAK>(des_ptr);
else if (des_name.compare("FREAK") == 0)
des_ptr = std::static_pointer_cast<DescriptorFREAK>(des_ptr);
// else if (des_name.compare("BRIEF") == 0)
// des_ptr = std::static_pointer_cast<DescriptorBRIEF>(des_ptr);
// else if (des_name.compare("DAISY") == 0)
......
sensor:
type: "USB_CAM"
descriptor:
type: "FREAK"
orientationNormalized: true
scaleNormalized: true
patternScale: 22.0
nOctaves: 4
selectedPairs: []
\ No newline at end of file
sensor:
type: "USB_CAM"
descriptor:
type: "LATCH"
bytes: 32
rotationInvariance: true
half_ssd_size: 3
\ No newline at end of file
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