Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
descriptorSeg.hpp
00001 /*
00002  * descriptorSeg.hpp
00003  *
00004  *  Created on: 24 Feb 2011
00005  *      Author: bhautboi
00006  * \ingroup rtslam
00007  */
00008 
00009 #ifndef DESCRIPTORSEG_HPP
00010 #define DESCRIPTORSEG_HPP
00011 
00012 #include "boost/shared_ptr.hpp"
00013 
00014 #include "rtslam/observationAbstract.hpp"
00015 #include "rtslam/observationPinHoleAnchoredHomogeneousPointsLine.hpp"
00016 
00017 
00018 #include "rtslam/descriptorAbstract.hpp"
00019 #include "rtslam/descriptorImageSeg.hpp"
00020 #include "rtslam/featureSegment.hpp"
00021 #include "rtslam/appearanceSegment.hpp"
00022 
00023 namespace jafar {
00024    namespace rtslam {
00025 
00026       class DescriptorSegFirstView;
00027       typedef boost::shared_ptr<DescriptorSegFirstView> desc_seg_fv_ptr_t;
00028       class DescriptorSegMultiView;
00029       typedef boost::shared_ptr<DescriptorSegMultiView> desc_seg_mv_ptr_t;
00030 
00035       class SegFeatureView
00036       {
00037          public:
00038             jblas::vec7 senPose;
00039             appearance_ptr_t appearancePtr;
00040             observation_model_ptr_t obsModelPtr;
00041             jblas::vec measurement;
00042             unsigned frame;
00043             bool used;
00044 
00045             void clear()
00046             {
00047                appearancePtr.reset();
00048                obsModelPtr.reset();
00049             }
00050 
00051             void initFromObs(const observation_ptr_t & obsPtr, int descSize);
00052       };
00053 
00054       std::ostream& operator <<(std::ostream & s, SegFeatureView const & fv);
00055       image::oimstream& operator <<(image::oimstream & s, SegFeatureView const & fv);
00056 
00062       class DescriptorSegFirstView: public DescriptorAbstract {
00063          protected:
00064             SegFeatureView view;
00065          protected:
00066             int descSize;
00067          public:
00068             DescriptorSegFirstView(int descSize);
00069             virtual ~DescriptorSegFirstView();
00070 
00071             virtual std::string typeName() const {
00072                return "Seg-First-View";
00073             }
00074 
00075             virtual bool addObservation(const observation_ptr_t & obsPtr);
00076             virtual bool predictAppearance(const observation_ptr_t & obsPtrNew);
00077             virtual bool isPredictionValid(const observation_ptr_t & obsPtr) { return true; }
00078 
00079             virtual void desc_text(std::ostream& os) const;
00080             virtual void desc_image(image::oimstream& os) const;
00081       };
00082 
00083       class DescriptorSegFirstViewFactory: public DescriptorFactoryAbstract
00084       {
00085          protected:
00086             int descSize; 
00087          public:
00088             DescriptorSegFirstViewFactory(int descSize):
00089                descSize(descSize) {}
00090             DescriptorAbstract *createDescriptor()
00091                { return new DescriptorSegFirstView(descSize); }
00092       };
00093 
00094 
00095 
00096 
00102 /*      class DescriptorSegMultiView: public DescriptorAbstract
00103       {
00104          public:
00105             typedef std::vector<SegFeatureView> SegFeatureViewList; ///< a SegFeatureView list
00106             enum PredictionType { ptNone, ptAffine, ptHomographic };
00107 
00108          protected:
00109             SegFeatureViewList views; ///< the different views of the feature
00110             SegFeatureView lastValidView; ///< the last valid view
00111             bool lastObsFailed;
00112          protected:
00113             int descSize; ///< the size of the patches in the descriptor
00114             double scaleStep; ///< the difference of scale that provokes storing of a new view, and the max difference of scale to use a view
00115             double angleStep; ///< the difference of angle that provokes storing of a new view, in degrees
00116             PredictionType predictionType;
00117          private:
00118             double cosAngleStep;
00119          public:
00120             DescriptorSegMultiView(int descSize, double scaleStep, double angleStep, PredictionType predictionType);
00121             virtual ~DescriptorSegMultiView() {}
00122 
00123             virtual std::string typeName() const {
00124                return "Seg-Multi-View";
00125             }
00126 
00127             virtual bool addObservation(const observation_ptr_t & obsPtr);
00128             virtual bool predictAppearance(const observation_ptr_t & obsPtr);
00129             virtual bool isPredictionValid(const observation_ptr_t & obsPtr);
00130 
00131             virtual void desc_text(std::ostream& os) const;
00132             virtual void desc_image(image::oimstream& os) const;
00133          protected:
00134             // return the closest view and if it is in the bounds or not
00135             inline void checkView(jblas::vec const &current_pov, double const &current_pov_norm2, jblas::vec const &lmk, SegFeatureView &view, double &cosClosestAngle, SegFeatureView* &closestView) const;
00136             bool getClosestView(const observation_ptr_t & obsPtr, SegFeatureView* &closestView);
00137       };
00138 
00139       class DescriptorSegMultiViewFactory: public DescriptorFactoryAbstract
00140       {
00141          protected:
00142             int descSize; ///< see DescriptorImageSegMultiView::descSize
00143             double scaleStep; ///< see DescriptorImageSegMultiView::scaleStep
00144             double angleStep; ///< see DescriptorImageSegMultiView::angleStep
00145             DescriptorSegMultiView::PredictionType predictionType; ///< see DescriptorImageSegMultiView::predictionType
00146          public:
00147             DescriptorSegMultiViewFactory(int descSize, double scaleStep, double angleStep, DescriptorSegMultiView::PredictionType predictionType):
00148                descSize(descSize), scaleStep(scaleStep), angleStep(angleStep), predictionType(predictionType) {}
00149             DescriptorAbstract *createDescriptor()
00150                { return new DescriptorSegMultiView(descSize, scaleStep, angleStep, predictionType); }
00151       };
00152 */
00153    }
00154 }
00155 #endif /* DESCRIPTORSEG_H_ */
00156 
00157 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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