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

added akaze and fixed problem with yaml

parent 67e3f479
No related branches found
No related tags found
No related merge requests found
Showing
with 167 additions and 17 deletions
......@@ -40,6 +40,8 @@ SET(sources
descriptors/brisk/descriptor_brisk_load_yaml.cpp
descriptors/kaze/descriptor_kaze.cpp
descriptors/kaze/descriptor_kaze_load_yaml.cpp
descriptors/akaze/descriptor_akaze.cpp
descriptors/akaze/descriptor_akaze_load_yaml.cpp
matchers/matcher_base.cpp )
# application header files
......@@ -70,6 +72,7 @@ SET(headers
descriptors/surf/descriptor_surf.h
descriptors/brisk/descriptor_brisk.h
descriptors/kaze/descriptor_kaze.h
descriptors/akaze/descriptor_akaze.h
matchers/matcher_factory.h
matchers/matcher_base.h)
......
#include "descriptor_akaze.h"
namespace vision_utils {
DescriptorAKAZE::DescriptorAKAZE(void)
{}
DescriptorAKAZE::~DescriptorAKAZE(void)
{}
} /* namespace vision_utils */
// Register in the DescriptorsFactory
namespace vision_utils
{
VU_REGISTER_DESCRIPTOR("AKAZE", DescriptorAKAZE);
} /* namespace vision_utils */
#ifndef _DESCRIPTOR_AKAZE_H_
#define _DESCRIPTOR_AKAZE_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(DescriptorAKAZE);
VU_PTR_TYPEDEFS(DescriptorParamsAKAZE);
/** \brief Class parameters
*
*/
struct DescriptorParamsAKAZE: public ParamsBase
{
int descriptor_type = cv::AKAZE::DESCRIPTOR_MLDB; // Type of the extracted descriptor. DESCRIPTOR_KAZE_UPRIGHT=2, DESCRIPTOR_KAZE=3, DESCRIPTOR_MLDB_UPRIGHT=4, DESCRIPTOR_MLDB=5
int descriptor_size = 0; // Size of the descriptor in bits. 0 -> Full size
int descriptor_channels = 3; // Number of channels in the descriptor (1, 2, 3)
float threshold = 0.001f; // Descriptor response threshold to accept point
int nOctaves = 4; // Maximum octave evolution of the image
int nOctaveLayers = 4; // Default number of sublevels per scale level
int diffusivity = cv::KAZE::DIFF_PM_G2; // Diffusivity type. DIFF_PM_G1=0, DIFF_PM_G2=1, DIFF_WEICKERT=2, DIFF_CHARBONNIER=3
};
/** \brief DETECTOR class
*
*/
class DescriptorAKAZE : public DescriptorBase {
public:
DescriptorAKAZE();
virtual ~DescriptorAKAZE(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 DescriptorAKAZE::defineDescriptor(const ParamsBasePtr _params)
{
DescriptorParamsAKAZEPtr params_ptr = std::static_pointer_cast<DescriptorParamsAKAZE>(_params);
descriptor_ = cv::AKAZE::create(params_ptr->descriptor_type,
params_ptr->descriptor_size,
params_ptr->descriptor_channels,
params_ptr->threshold,
params_ptr->nOctaves,
params_ptr->nOctaveLayers,
params_ptr->diffusivity);
}
/*
* brief Create object in factory
*/
inline DescriptorBasePtr DescriptorAKAZE::create(const std::string& _unique_name, const ParamsBasePtr _params)
{
DescriptorAKAZEPtr det_ptr = std::make_shared<DescriptorAKAZE>();
det_ptr->setName(_unique_name);
det_ptr->defineDescriptor(_params);
return det_ptr;
}
} /* namespace vision_utils */
#endif /* _DESCRIPTOR_AKAZE_H_ */
#include "descriptor_akaze.h"
#ifdef USING_YAML
// yaml-cpp library
#include <yaml-cpp/yaml.h>
namespace vision_utils
{
namespace
{
static ParamsBasePtr createParamsAKAZEDescriptor(const std::string & _filename_dot_yaml)
{
DescriptorParamsAKAZEPtr params_ptr = std::make_shared<DescriptorParamsAKAZE>();
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>() == "AKAZE")
{
params_ptr->descriptor_type = d_yaml["descriptor_type"].as<int>();
params_ptr->descriptor_size = d_yaml["descriptor_size"].as<int>();
params_ptr->descriptor_channels = d_yaml["descriptor_channels"].as<int>();
params_ptr->threshold = d_yaml["threshold"].as<float>();
params_ptr->nOctaves = d_yaml["nOctaves"].as<int>();
params_ptr->nOctaveLayers = d_yaml["nOctaveLayers"].as<int>();
params_ptr->diffusivity = d_yaml["diffusivity"].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_desAKAZE_params = ParamsFactory::get().registerCreator("AKAZE DES", createParamsAKAZEDescriptor);
} /* namespace [unnamed] */
} /* namespace vision_utils */
#endif /* IF USING_YAML */
......@@ -13,5 +13,5 @@ DescriptorBRISK::~DescriptorBRISK(void)
// Register in the DescriptorsFactory
namespace vision_utils
{
VU_REGISTER_DESCRIPTOR("BRISK DES", DescriptorBRISK);
VU_REGISTER_DESCRIPTOR("BRISK", DescriptorBRISK);
} /* namespace vision_utils */
......@@ -21,7 +21,7 @@ static ParamsBasePtr createParamsBRISKDescriptor(const std::string & _filename_d
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["descriptor"];
if(d_yaml["type"].as<string>() == "BRISK DES")
if(d_yaml["type"].as<string>() == "BRISK")
{
params_ptr->thresh = d_yaml["thresh"].as<int>();
params_ptr->octaves = d_yaml["octaves"].as<int>();
......
......@@ -38,7 +38,7 @@ DescriptorBasePtr setupDescriptor(const std::string& _type, const std::string& _
#ifdef USING_YAML
DescriptorBasePtr setupDescriptor(const std::string& _type, const std::string& _unique_name, const std::string& _filename_dot_yaml)
{
ParamsBasePtr params_ptr = ParamsFactory::get().create(_type, _filename_dot_yaml);
ParamsBasePtr params_ptr = ParamsFactory::get().create(_type+" DES", _filename_dot_yaml);
return setupDescriptor(_type, _unique_name, params_ptr);
}
#endif
......
......@@ -13,5 +13,5 @@ DescriptorKAZE::~DescriptorKAZE(void)
// Register in the DescriptorsFactory
namespace vision_utils
{
VU_REGISTER_DESCRIPTOR("KAZE DES", DescriptorKAZE);
VU_REGISTER_DESCRIPTOR("KAZE", DescriptorKAZE);
} /* namespace vision_utils */
......@@ -21,7 +21,7 @@ static ParamsBasePtr createParamsKAZEDescriptor(const std::string & _filename_do
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["descriptor"];
if(d_yaml["type"].as<string>() == "KAZE DES")
if(d_yaml["type"].as<string>() == "KAZE")
{
params_ptr->extended = d_yaml["extended"].as<bool>();
params_ptr->upright = d_yaml["upright"].as<bool>();
......
......@@ -13,5 +13,5 @@ DescriptorORB::~DescriptorORB(void)
// Register in the DescriptorsFactory
namespace vision_utils
{
VU_REGISTER_DESCRIPTOR("ORB DES", DescriptorORB);
VU_REGISTER_DESCRIPTOR("ORB", DescriptorORB);
} /* namespace vision_utils */
......@@ -21,7 +21,7 @@ static ParamsBasePtr createParamsORBDescriptor(const std::string & _filename_dot
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["descriptor"];
if(d_yaml["type"].as<string>() == "ORB DES")
if(d_yaml["type"].as<string>() == "ORB")
{
params_ptr->nfeatures = d_yaml["nfeatures"].as<unsigned int>();
params_ptr->scaleFactor = d_yaml["scale factor"].as<float>();
......
......@@ -13,5 +13,5 @@ DescriptorSIFT::~DescriptorSIFT(void)
// Register in the DescriptorsFactory
namespace vision_utils
{
VU_REGISTER_DESCRIPTOR("SIFT DES", DescriptorSIFT);
VU_REGISTER_DESCRIPTOR("SIFT", DescriptorSIFT);
} /* namespace vision_utils */
......@@ -21,7 +21,7 @@ static ParamsBasePtr createParamsSIFTDescriptor(const std::string & _filename_do
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["descriptor"];
if(d_yaml["type"].as<string>() == "SIFT DES")
if(d_yaml["type"].as<string>() == "SIFT")
{
params_ptr->nfeatures = d_yaml["nfeatures"].as<int>();
params_ptr->nOctaveLayers = d_yaml["nOctaveLayers"].as<int>();
......@@ -30,7 +30,7 @@ static ParamsBasePtr createParamsSIFTDescriptor(const std::string & _filename_do
params_ptr->sigma = d_yaml["sigma"].as<double>();
}else
{
std::cerr << "Bad configuration file. Wrong type " << d_yaml["type"].as<string>() << std::endl;
std::cerr << "DESCRIPTOR Bad configuration file. Wrong type " << d_yaml["type"].as<string>() << std::endl;
return nullptr;
}
}
......
......@@ -13,5 +13,5 @@ DescriptorSURF::~DescriptorSURF(void)
// Register in the DescriptorsFactory
namespace vision_utils
{
VU_REGISTER_DESCRIPTOR("SURF DES", DescriptorSURF);
VU_REGISTER_DESCRIPTOR("SURF", DescriptorSURF);
} /* namespace vision_utils */
......@@ -21,7 +21,7 @@ static ParamsBasePtr createParamsSURFDescriptor(const std::string & _filename_do
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["descriptor"];
if(d_yaml["type"].as<string>() == "SURF DES")
if(d_yaml["type"].as<string>() == "SURF")
{
params_ptr->hessianThreshold = d_yaml["hessianThreshold"].as<double>();
params_ptr->nOctaves = d_yaml["nOctaves"].as<int>();
......
......@@ -13,5 +13,5 @@ DetectorAGAST::~DetectorAGAST(void)
// Register in the DetectorsFactory
namespace vision_utils
{
VU_REGISTER_DETECTOR("AGAST DET", DetectorAGAST);
VU_REGISTER_DETECTOR("AGAST", DetectorAGAST);
} /* namespace vision_utils */
......@@ -21,7 +21,7 @@ static ParamsBasePtr createParamsAGASTDetector(const std::string & _filename_dot
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["detector"];
if(d_yaml["type"].as<string>() == "AGAST DET")
if(d_yaml["type"].as<string>() == "AGAST")
{
params_ptr->threshold = d_yaml["threshold"].as<int>();
params_ptr->nonmaxSuppression = d_yaml["nonmaxSuppression"].as<bool>();
......
......@@ -13,5 +13,5 @@ DetectorAKAZE::~DetectorAKAZE(void)
// Register in the DetectorsFactory
namespace vision_utils
{
VU_REGISTER_DETECTOR("AKAZE DET", DetectorAKAZE);
VU_REGISTER_DETECTOR("AKAZE", DetectorAKAZE);
} /* namespace vision_utils */
......@@ -21,7 +21,7 @@ static ParamsBasePtr createParamsAKAZEDetector(const std::string & _filename_dot
if (!yaml_params.IsNull())
{
Node d_yaml = yaml_params["detector"];
if(d_yaml["type"].as<string>() == "AKAZE DET")
if(d_yaml["type"].as<string>() == "AKAZE")
{
params_ptr->descriptor_type = d_yaml["descriptor_type"].as<int>();
params_ptr->descriptor_size = d_yaml["descriptor_size"].as<int>();
......
......@@ -13,5 +13,5 @@ DetectorBRISK::~DetectorBRISK(void)
// Register in the DetectorsFactory
namespace vision_utils
{
VU_REGISTER_DETECTOR("BRISK DET", DetectorBRISK);
VU_REGISTER_DETECTOR("BRISK", DetectorBRISK);
} /* namespace vision_utils */
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