Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
descriptorImageSeg.hpp
00001 /*
00002  * descriptorImageSeg.hpp
00003  *
00004  *  Created on: 24 Feb 2011
00005  *      Author: bhautboi
00006  * \ingroup rtslam
00007  */
00008 
00009 #ifndef DESCRIPTORIMAGESEG_H_
00010 #define DESCRIPTORIMAGESEG_H_
00011 
00012 #ifdef HAVE_MODULE_DSEG
00013 
00014 #include "boost/shared_ptr.hpp"
00015 
00016 //#include "rtslam/rtSlam.hpp"
00017 #include "rtslam/observationAbstract.hpp"
00018 //#include "rtslam/observationPinHoleEuclideanPoint.hpp"
00019 #include "rtslam/observationPinHoleAnchoredHomogeneousPointsLine.hpp"
00020 
00021 
00022 #include "rtslam/descriptorAbstract.hpp"
00023 #include "rtslam/featureSegment.hpp"
00024 #include "rtslam/appearanceImage.hpp"
00025 
00026 namespace jafar {
00027    namespace rtslam {
00028 
00029       class DescriptorImageSegFirstView;
00030       typedef boost::shared_ptr<DescriptorImageSegFirstView> desc_img_seg_fv_ptr_t;
00031       class DescriptorImageSegMultiView;
00032       typedef boost::shared_ptr<DescriptorImageSegMultiView> desc_img_seg_mv_ptr_t;
00033 
00038       class ImgSegFeatureView
00039       {
00040          public:
00041             jblas::vec7 senPose;
00042             appearance_ptr_t appearancePtr;
00043             observation_model_ptr_t obsModelPtr;
00044             jblas::vec measurement;
00045             unsigned frame;
00046             bool used;
00047 
00048             void clear()
00049             {
00050                appearancePtr.reset();
00051                obsModelPtr.reset();
00052             }
00053 
00054             void initFromObs(const observation_ptr_t & obsPtr, int descSize);
00055       };
00056 
00057       std::ostream& operator <<(std::ostream & s, ImgSegFeatureView const & fv);
00058       image::oimstream& operator <<(image::oimstream & s, ImgSegFeatureView const & fv);
00059 
00065       class DescriptorImageSegFirstView: public DescriptorAbstract {
00066          protected:
00067             ImgSegFeatureView view;
00068          protected:
00069             int descSize;
00070          public:
00071             DescriptorImageSegFirstView(int descSize);
00072             virtual ~DescriptorImageSegFirstView();
00073 
00074             virtual std::string typeName() const {
00075                return "Image-Seg-First-View";
00076             }
00077 
00078             virtual bool addObservation(const observation_ptr_t & obsPtr);
00079             virtual bool predictAppearance(const observation_ptr_t & obsPtrNew);
00080             virtual bool isPredictionValid(const observation_ptr_t & obsPtr) { return true; }
00081 
00082             virtual void desc_text(std::ostream& os) const;
00083             virtual void desc_image(image::oimstream& os) const;
00084 
00085         float getLeftExtremity() {return left_extremity;}
00086         float getRightExtremity() {return right_extremity;}
00087 
00088          private:
00089             float left_extremity;
00090             float right_extremity;
00091       };
00092 
00093       class DescriptorImageSegFirstViewFactory: public DescriptorFactoryAbstract
00094       {
00095          protected:
00096             int descSize; 
00097          public:
00098             DescriptorImageSegFirstViewFactory(int descSize):
00099                descSize(descSize) {}
00100             DescriptorAbstract *createDescriptor()
00101                { return new DescriptorImageSegFirstView(descSize); }
00102       };
00103 
00104 
00105 
00106 
00112       class DescriptorImageSegMultiView: public DescriptorAbstract
00113       {
00114          public:
00115             typedef std::vector<ImgSegFeatureView> ImgSegFeatureViewList; 
00116             enum PredictionType { ptNone, ptAffine, ptHomographic };
00117 
00118          protected:
00119             ImgSegFeatureViewList views; 
00120             ImgSegFeatureView lastValidView; 
00121             bool lastObsFailed;
00122          protected:
00123             int descSize; 
00124             double scaleStep; 
00125             double angleStep; 
00126             PredictionType predictionType;
00127          private:
00128             double cosAngleStep;
00129          public:
00130             DescriptorImageSegMultiView(int descSize, double scaleStep, double angleStep, PredictionType predictionType);
00131             virtual ~DescriptorImageSegMultiView() {}
00132 
00133             virtual std::string typeName() const {
00134                return "Image-Seg-Multi-View";
00135             }
00136 
00137             virtual bool addObservation(const observation_ptr_t & obsPtr);
00138             virtual bool predictAppearance(const observation_ptr_t & obsPtr);
00139             virtual bool isPredictionValid(const observation_ptr_t & obsPtr);
00140 
00141             virtual void desc_text(std::ostream& os) const;
00142             virtual void desc_image(image::oimstream& os) const;
00143          protected:
00147             inline void checkView(jblas::vec const &current_pov, double const &current_pov_norm2, jblas::vec const &lmk, ImgSegFeatureView &view, double &cosClosestAngle, ImgSegFeatureView* &closestView) const;
00148             bool getClosestView(const observation_ptr_t & obsPtr, ImgSegFeatureView* &closestView);
00149       };
00150 
00151       class DescriptorImageSegMultiViewFactory: public DescriptorFactoryAbstract
00152       {
00153          protected:
00154             int descSize; 
00155             double scaleStep; 
00156             double angleStep; 
00157             DescriptorImageSegMultiView::PredictionType predictionType; 
00158          public:
00159             DescriptorImageSegMultiViewFactory(int descSize, double scaleStep, double angleStep, DescriptorImageSegMultiView::PredictionType predictionType):
00160                descSize(descSize), scaleStep(scaleStep), angleStep(angleStep), predictionType(predictionType) {}
00161             DescriptorAbstract *createDescriptor()
00162                { return new DescriptorImageSegMultiView(descSize, scaleStep, angleStep, predictionType); }
00163       };
00164 
00165    }
00166 }
00167 
00168 #endif /* HAVE_MODULE_DSEG */
00169 
00170 #endif /* DESCRIPTORIMAGESEG_H_ */
00171 
 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