BearExtrCamUtils.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00029 
00033 
00034 #ifndef __BEAR_EXTR_CAM_UTILS_H_
00035 #define __BEAR_EXTR_CAM_UTILS_H_
00036 
00037 #include <opencv2/imgproc/imgproc.hpp>
00038 #include <opencv2/imgproc/imgproc_c.h>
00039 #include <TooN/TooN.h>
00040 #include <visp/vpDot2.h>
00041 #include <visp/vpImageConvert.h>
00042 #include <SpacesArma.h>
00043 
00044 using namespace std;
00045 namespace MipAlgorithms{
00046  
00050  class BearExtrCamPar{
00051   private:
00053    uint        _widthCam;
00055    uint        _heightCam;
00057    int         _areaCircMin; 
00059    int         _areaCircMax;
00061    Decimal      _rndThr;
00063    Decimal      _crThr;
00065    int        _sigmaBlur;
00067    int        _edgeThr;
00069    int        _maxVal;
00071    int        _typeThrAlgo;
00073    Decimal      _sonarStaticHeight;
00075    Position3DArma  _sonarQuadPos;
00077    Roto3DArma    _sonarQuadRot;
00079    int        _widthROI;
00081    int        _heightROI;
00083    int         _areaCircMinRect; 
00085    int         _areaCircMaxRect;
00087    Decimal      _sigmaBlurRect;
00089    int        _edgeThrRect;
00091    Decimal      _searchNewFeature;
00093    bool       _useRect;
00094    
00095   public:
00097    BearExtrCamPar();
00098    
00100    BearExtrCamPar(const uint &w, const uint &h, const int &acm, const int &acM, const Decimal &rndThr, const Decimal &crThr, const int &sigmaBlr, const int &edgeThr, const int& mv, const int& ta, const Decimal &ssh, const Position3DArma& pos, const Roto3DArma& rot, const int &wROI, const int &hROI, const int &acmRect, const int &acMRect, const Decimal &sbRect, const int &edthrRect, const Decimal &time, const bool &ur);
00101    
00105    BearExtrCamPar(const Position3DArma& pos, const Roto3DArma& rot);
00106    
00110    BearExtrCamPar(const Decimal &w, const Decimal &h, const Position3DArma& pos, const Roto3DArma& rot);
00111    
00113    BearExtrCamPar(const BearExtrCamPar &A);
00114    
00116    BearExtrCamPar& operator=(const BearExtrCamPar& A);
00117    
00119    ~BearExtrCamPar();
00120    
00123    uint getWidthCamera() const;
00124    
00127    uint getHeightCamera() const;
00128    
00131    int getAreaCircMin() const;
00132    
00135    int getAreaCircMax() const;
00136    
00139    Decimal getRndThr() const;
00140    
00143    Decimal getCrThr() const;
00144    
00147    int getSigmaBlur() const;
00148    
00151    int getEdgeThr() const;
00152    
00155    int getMaxVal() const;
00156    
00159    int getTypeThrAlgo() const;
00160    
00163    Decimal getStaticSonarHeight() const;
00164    
00167    Position3DArma getSonarQuadPos() const;
00168    
00171    Roto3DArma getSonarQuadRot() const;
00172    
00175    int getWidthROI() const;
00176    
00179    int getHeightROI() const;
00180    
00183    int getAreaCircMinRect() const;
00184    
00187    int getAreaCircMaxRect() const;
00188    
00191    int getSigmaBlurRect() const;
00192    
00195    int getEdgeThrRect() const;
00196    
00199    Decimal getSearchNewFeatureTimer() const;
00200    
00203    bool getUseRect() const;
00204    
00207    void setWidthCamera(const uint& w);
00208    
00211    void setHeightCamera(const uint& h);
00212    
00215    void setAreaCircMin(const int& mca);
00216    
00219    void setAreaCircMax(const int& mca);
00220    
00223    Decimal setRndThr(const Decimal &rndThr);
00224    
00227    Decimal setCrThr(const Decimal &crThr);
00228    
00231    void setSigmaBlur(const int& sb);
00232    
00235    void setEdgeThr(const int& et);
00236    
00239    void setMaxVal(const int &vo);
00240    
00243    void setTypeThrAlgo(const int &at);
00244    
00247    void setStaticSonarHeight(const Decimal &h);
00248    
00251    void setSonarQuadPos(const Position3DArma& pos);
00252    
00255    void setSonarQuadRot(const Roto3DArma& rot);
00256    
00259    void setWidthROI(const int &wROI);
00260    
00263    void setHeightROI(const int &hROI);
00264    
00267    void setAreaCircMinRect(const int& mca);
00268    
00271    void setAreaCircMaxRect(const int& mca);
00272    
00275    void setSigmaBlurRect(const int& sb);
00276    
00279    void setEdgeThrRect(const int& et);
00280    
00283    void setSearchNewFeatureTimer(const Decimal& time);
00284    
00287    void setUseRect(const bool &ur);
00288  };
00289  
00293  class BearExtrCamVar{
00294   private:
00296    int         _areaCircMin; 
00298    int         _areaCircMax;
00300    Decimal      _crThr;
00302    int        _widthROI;
00304    int        _heightROI;
00306    int         _areaCircMinRect; 
00308    int         _areaCircMaxRect;
00310    Decimal       _actTime;
00312    Decimal       _lastTime;
00313    
00314   public:
00315    
00317    BearExtrCamVar();
00318    
00320    BearExtrCamVar(const int &acm, const int &acM, const Decimal &ct, const int &wROI, const int &hROI, const int &acmRect, const int &acMRect, const Decimal at, const Decimal &lt);
00321    
00323    ~BearExtrCamVar();
00324    
00326    BearExtrCamVar(const BearExtrCamVar &A);
00327    
00329    BearExtrCamVar& operator=(const BearExtrCamVar& A);
00330    
00333    int getAreaCircMin() const;
00334    
00337    int getAreaCircMax() const;
00338    
00341    Decimal getCrThr() const;
00342    
00345    int getWidthROI() const;
00346    
00349    int getHeightROI() const;
00350    
00353    int getAreaCircMinRect() const;
00354    
00357    int getAreaCircMaxRect() const;
00358    
00361    Decimal getActualTime() const;
00362    
00365    Decimal getLastTime() const;
00366    
00369    void setAreaCircMin(const int& mca);
00370    
00373    void setAreaCircMax(const int& mca);
00374    
00377    Decimal setCrThr(const Decimal &crThr);
00378    
00381    void setWidthROI(const int &wROI);
00382    
00385    void setHeightROI(const int &hROI);
00386    
00389    void setAreaCircMinRect(const int& mca);
00390    
00393    void setAreaCircMaxRect(const int& mca);
00394    
00397    void setActualTime(const Decimal& act);
00398    
00401    void setLastTime(const Decimal& l);
00402  };
00403  
00407  class BearExtrCamUtils{
00408   public:
00423    static std::vector<std::vector<cv::Point> >  circle_detect_thresh(cv::Mat &src,int &Tl_x, int &Tl_y,int &_Tp_width, int &_Tp_height,const int &sigma,const int &thresh,const int &max_val, const int &area_circ_min,const int &area_circ_max, const Decimal &tresh_roundness);
00424    
00428    static std::vector<std::vector<cv::Point> >  detect_rectangle_in_roi(cv::Mat Image, std::vector<std::vector<cv::Point> > circles, BearExtrCamPar* par, BearExtrCamVar* var);
00429    
00436    static cv::Rect build_roi_around_circle(std::vector<cv::Point> circle,int img_width, int img_height,cv::Point  & center_C, BearExtrCamPar* par, BearExtrCamVar* var);
00437    
00438    static cv::Point computeContourCenter(std::vector< cv::Point > & square, BearExtrCamPar* par);
00439    
00440    static void computeContourMaxMin(std::vector<cv::Point>& square, cv::Point& max, cv::Point& min, BearExtrCamPar* par);
00441    
00442    static void findSquares1( const cv::Mat image, std::vector<std::vector<cv::Point> >& squares, BearExtrCamPar* par, BearExtrCamVar* var);
00443    
00444    static Decimal angle( cv::Point pt1, cv::Point pt2, cv::Point pt0 );
00445    
00447    static void findRoiInImage(std::vector<cv::Point> &region, cv::Point pointRoi);
00448    
00450    static Decimal distPoint(cv::Point first, cv::Point second);
00451    
00453    static cv::Point calc_middle_square(std::vector<cv::Point> square,cv::Point C_center);
00454  };
00455 }
00456 #endif

Generated on Mon Feb 20 07:01:06 2017 for MIP by  doxygen 1.5.6