Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Engine.hpp
00001 /* $Id$ */
00002 #ifndef _GFM_ENGINE_HPP_
00003 #define _GFM_ENGINE_HPP_
00004 
00005 #include <boost/serialization/nvp.hpp>
00006 #include <boost/serialization/utility.hpp>
00007 #include <boost/serialization/version.hpp>
00008 #include <boost/noncopyable.hpp>
00009 
00010 #include "image/Image.hpp"
00011 #include "fdetect/Detector.hpp"
00012 #include "fdetect/Descriptor.hpp"
00013 #include "gfm/Matcher.hpp"
00014 #include "gfm/MatchingResult.hpp"
00015 
00016 
00017 namespace jafar {
00018   namespace gfm {
00019     //    class DescriptorFactory;
00020     //    class Detector;
00021     //    class Matcher;
00022     //    class MatchingResult;
00027     class Engine: public boost::noncopyable {
00028       public:
00029         Engine(jafar::fdetect::Detector* detector, jafar::gfm::Matcher* matcher, jafar::fdetect::Detector* snddetector/*, jafar::gfm::DescriptorFactory* descriptor = 0*/)
00030         : m_detector(detector), m_snddetector(snddetector ? snddetector : detector), m_descriptorFactory(0 /*descriptor*/), m_matcher(matcher)
00031         { }
00032         ~Engine();
00033       public:
00034         jafar::gfm::MatchingResult computeMatch(jafar::image::Image const& image_ref, jafar::image::Image const& image_match );
00035       private:
00036         fdetect::Detector* m_detector, *m_snddetector;
00037         fdetect::DescriptorFactory* m_descriptorFactory;
00038         Matcher* m_matcher;
00040       friend class boost::serialization::access;
00041       template<class Archive>
00042       void serialize(Archive &ar, const unsigned int version)
00043       {
00044         ar & BOOST_SERIALIZATION_NVP(m_detector);
00045         ar & BOOST_SERIALIZATION_NVP(m_snddetector);
00046         ar & BOOST_SERIALIZATION_NVP(m_matcher);
00047       }
00048 
00049     };
00050   }
00051 
00052   namespace gfm_v2 {
00057     template<typename InterestFeatureT>
00058     class Engine: public boost::noncopyable {
00059       public:
00060       Engine(jafar::fdetect_v2::Detector<InterestFeatureT>* detector, 
00061              jafar::gfm_v2::Matcher<InterestFeatureT>* matcher, 
00062              jafar::fdetect_v2::Detector<InterestFeatureT>* snddetector
00063              /*, jafar::gfm::DescriptorFactory* descriptor = 0*/)
00064         : m_detector(detector), 
00065           m_snddetector(snddetector ? snddetector : detector), 
00066           m_descriptorFactory(0 /*descriptor*/), 
00067           m_matcher(matcher)
00068         { }
00069       ~Engine()
00070       {
00071         JFR_DEBUG("delete Engine()");
00072         if(m_snddetector != m_detector)
00073           delete m_snddetector;
00074         delete m_detector;
00075         if(m_descriptorFactory)
00076           delete m_descriptorFactory;
00077         delete m_matcher;
00078       }
00079       public:
00080       MatchingResult<InterestFeatureT> computeMatch(jafar::image::Image const& image_ref, 
00081                                               jafar::image::Image const& image_match )
00082       {
00083         using namespace fdetect_v2;
00084         DetectionResult<InterestFeatureT> points_ref = m_detector->detectIn(image_ref) ;
00085         DetectionResult<InterestFeatureT> points_match = m_snddetector->detectIn(image_match);
00086         if(m_descriptorFactory)
00087         {
00088           m_descriptorFactory->createDescriptor(points_ref, image_ref);
00089           m_descriptorFactory->createDescriptor(points_match, image_match);
00090         }
00091         MatchSourceInfo<InterestFeatureT>* inforef = m_matcher->initMatchSourceInfo(points_ref);
00092         MatchSourceInfo<InterestFeatureT>* infosource = m_matcher->initMatchSourceInfo(points_match);
00093         MatchingResult<InterestFeatureT> result = m_matcher->computeMatch(inforef, infosource);
00094         delete inforef;
00095         delete infosource;
00096         JFR_DEBUG("Found " << result.matches().size() << " matches");
00097         return result;
00098       }
00099 
00100       private:
00101       fdetect_v2::Detector<InterestFeatureT>* m_detector, *m_snddetector;
00102       fdetect_v2::DescriptorFactory<InterestFeatureT>* m_descriptorFactory;
00103       Matcher<InterestFeatureT>* m_matcher;
00105       friend class boost::serialization::access;
00106       template<class Archive>
00107       void serialize(Archive &ar, const unsigned int version)
00108       {
00109         ar & BOOST_SERIALIZATION_NVP(m_detector);
00110         ar & BOOST_SERIALIZATION_NVP(m_snddetector);
00111         ar & BOOST_SERIALIZATION_NVP(m_matcher);
00112       }
00113     };
00114   }
00115 }
00116 
00117 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:20 for Jafar by doxygen 1.7.6.1
LAAS-CNRS