Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Quick.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLQt/src/ICLQt/Quick.h                                **
00010 ** Module : ICLQt                                                  **
00011 ** Authors: Christof Elbrechter                                    **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #include <ICLUtils/CompatMacros.h>
00034 #include <ICLUtils/StringUtils.h>
00035 #include <ICLUtils/Exception.h>
00036 #include <ICLCore/Img.h>
00037 
00038 namespace icl{
00039   namespace utils{}
00040   namespace math{}
00041   namespace core{}
00042   namespace filter{}
00043   namespace io{}
00044   namespace qt{}
00045   namespace geom{}
00046   namespace cv{}
00047   namespace markers{}
00048 }
00049 
00050 #ifndef ICL_NO_USING_NAMESPACES
00051 using namespace icl;
00052 using namespace icl::utils;
00053 using namespace icl::math;
00054 using namespace icl::core;
00055 using namespace icl::filter;
00056 using namespace icl::io;
00057 using namespace icl::qt;
00058 using namespace icl::geom;
00059 using namespace icl::cv;
00060 using namespace icl::markers;
00061 #endif
00062 
00064 using namespace std;
00065 
00067 namespace icl{
00068   namespace qt{
00069   
00070   #ifdef ICL_HAVE_QT
00071 
00072 
00073     ICLQt_API std::string openFileDialog(const std::string &filter = "",
00074                                const std::string &caption="open file",
00075                                const std::string &initialDirectory="_____last", 
00076                                void *parentWidget=0) throw (utils::ICLException);
00077   
00079 
00080     ICLQt_API std::string saveFileDialog(const std::string &filter = "",
00081                                const std::string &caption="save file",
00082                                const std::string &initialDirectory="_____last", 
00083                                void *parentWidget=0) throw (utils::ICLException);
00084 
00086 
00089     std::string textInputDialog(const std::string &caption="text ...",
00090                                 const std::string &message="please write your text here",
00091                                 const std::string &initialText="",
00092                                 void *parentWidget=0,
00093                                 core::ImgBase *visImage=0) throw (utils::ICLException);
00094 
00095    
00097 
00098     ICLQt_API std::string execute_process(const std::string &command);
00099   #endif
00100   
00101   #define ICL_QUICK_DEPTH depth32f
00102   #define ICL_QUICK_TYPE icl32f
00103     
00104       
00106     typedef core::Img<ICL_QUICK_TYPE> ImgQ;
00107   
00109     /* {{{ open */
00111 
00115     template<class T> ICLQt_API
00116     core::Img<T> zeros(int width, int height, int channels=1);
00117     
00118     /***/
00119     inline ImgQ zeros(int width, int height, int channels=1){ 
00120       return zeros<ICL_QUICK_TYPE>(width,height,channels); 
00121     }
00122     
00123     
00125 
00129     template<class T> ICLQt_API
00130     core::Img<T> ones(int width, int height, int channels=1);
00131   
00133     inline ImgQ ones(int width, int height, int channels=1){ return ones<ICL_QUICK_TYPE>(width,height,channels);  }
00136 
00137 
00139     template<class T> ICLQt_API
00140     core::Img<T> load(const std::string &filename);
00141   
00143     inline ImgQ load(const std::string &filename) { return load<ICL_QUICK_TYPE>(filename); }
00146 
00147 
00150     template<class T> ICLQt_API
00151     core::Img<T> load(const std::string &filename, core::format fmt);
00152   
00154     inline ImgQ load(const std::string &filename, core::format fmt) { return load<ICL_QUICK_TYPE>(filename,fmt); }
00157 
00158 
00163     template<class T> ICLQt_API
00164     core::Img<T> create(const std::string &name, core::format fmt=icl::core::formatRGB);
00165   
00167     inline ImgQ create(const std::string &name, core::format fmt=icl::core::formatRGB) { return create<ICL_QUICK_TYPE>(name,fmt); }
00170 
00171 
00178     template<class T> ICLQt_API
00179     core::Img<T> grab(const std::string &dev, const std::string &devSpec, 
00180                 const utils::Size &size=utils::Size::null, core::format fmt=core::formatRGB,
00181                 bool releaseGrabber=false);
00182   
00184     inline ImgQ grab(const std::string &dev, const std::string &devSpec, 
00185                      const utils::Size &size=utils::Size::null, core::format fmt=icl::core::formatRGB,
00186                      bool releaseGrabber=false){
00187       return grab<ICL_QUICK_TYPE>(dev,devSpec,size,fmt,releaseGrabber);
00188     }
00192     /* }}} */
00193   
00195     /* {{{ open */
00196   
00198 
00201     ICLQt_API core::Img8u cvt8u(const ImgQ &image);
00202   
00204 
00207     ICLQt_API core::Img16s cvt16s(const ImgQ &image);
00208   
00210 
00213     ICLQt_API core::Img32s cvt32s(const ImgQ &image);
00214   
00216 
00219     ICLQt_API core::Img32f cvt32f(const ImgQ &image);
00220   
00222 
00225     ICLQt_API core::Img64f cvt64f(const ImgQ &image);
00226   
00228 
00231     ICLQt_API ImgQ cvt(const core::Img8u &image);
00232   
00234 
00235 
00238     ICLQt_API ImgQ cvt(const core::Img16s &image);
00239   
00241 
00244     ICLQt_API ImgQ cvt(const core::Img32s &image);
00245   
00247 
00251     ICLQt_API ImgQ cvt(const core::Img32f &image);
00252 
00254 
00257     ICLQt_API ImgQ cvt(const core::Img64f &image);
00260 
00261 
00264     ICLQt_API ImgQ cvt(const core::ImgBase *image);
00265   
00266   
00268 
00271     ICLQt_API ImgQ cvt(const core::ImgBase &image);
00273     /* }}} */
00274   
00276     /* {{{ open */
00277   
00279 
00284     template<class T> ICLQt_API
00285     core::Img<T> filter(const core::Img<T> &image, const std::string &filter);
00286     
00288     inline ImgQ filter(const ImgQ &image, const std::string &filter){
00289       return icl::qt::filter<float>(image,filter);
00290     }
00293 
00294 
00295     template<class T> ICLQt_API
00296     core::Img<T> blur(const core::Img<T> &image, int maskRadius=1);
00297     
00299     inline ImgQ blur(const ImgQ &image, int maskRadius=1){
00300       return icl::qt::blur<float>(image,maskRadius);
00301     }
00304 
00305 
00308     ICLQt_API ImgQ cc(const ImgQ& image, core::format fmt);
00309     
00311 
00312     ICLQt_API ImgQ rgb(const ImgQ &image);
00313     
00315 
00316     ICLQt_API ImgQ hls(const ImgQ &image);
00317   
00319 
00320     ICLQt_API ImgQ lab(const ImgQ &image);
00321   
00323 
00324     ICLQt_API ImgQ gray(const ImgQ &image);
00325     
00327 
00330     ICLQt_API ImgQ scale(const ImgQ& image, float factor);
00331   
00333 
00337     ICLQt_API ImgQ scale(const ImgQ& image, int width, int height);
00338     
00340 
00343     ICLQt_API ImgQ channel(const ImgQ &image, int channel);
00344   
00346 
00352     ICLQt_API ImgQ levels(const ImgQ &image, icl8u levels);
00353     
00355 
00358     ICLQt_API ImgQ thresh(const ImgQ &image, float threshold);
00359    
00361 
00362     template<class T> ICLQt_API
00363     core::Img<T> copy(const core::Img<T> &image);
00364     
00366 
00367     template <class T> ICLQt_API
00368     core::Img<T> copyroi(const core::Img<T> &image);
00369     
00371 
00372     template<class T> ICLQt_API
00373     core::Img<T> norm(const core::Img<T> &image);
00374     
00376 
00377     ICLQt_API ImgQ flipx(const ImgQ& image);
00378   
00380 
00381     ICLQt_API ImgQ flipy(const ImgQ& image);
00382   
00384     /* }}} */
00385     
00387     /* {{{ open */
00388     
00390 
00393     ICLQt_API void save(const core::ImgBase &image, const std::string &filename);
00394     
00396 
00403     ICLQt_API void show(const icl::core::ImgBase &image);
00404     
00406 
00417     ICLQt_API void showSetup(const string &showCommand = "xv %s", const string &rmCommand = "rm -rf %s", int msecBeforeDelete = 500);
00418     
00420 
00421     template<class T>
00422     void print(const core::Img<T> &image);
00423   
00425     /* }}} */
00426     
00428     /* {{{ open */
00429   
00431 
00434     ICLQt_API ImgQ operator+(const ImgQ &a, const ImgQ &b);
00435     
00437 
00440     ICLQt_API ImgQ operator-(const ImgQ &a, const ImgQ &b);
00441     
00443 
00446     ICLQt_API ImgQ operator*(const ImgQ &a, const ImgQ &b);
00447   
00449 
00452     ICLQt_API ImgQ operator/(const ImgQ &a, const ImgQ &b);
00453   
00455 
00458     ICLQt_API ImgQ operator+(const ImgQ &image, float val);
00459   
00461 
00464     ICLQt_API ImgQ operator-(const ImgQ &image, float val);
00465   
00467 
00470     ICLQt_API ImgQ operator*(const ImgQ &image, float val);
00471   
00473 
00476     ICLQt_API ImgQ operator/(const ImgQ &image, float val);
00477   
00479 
00482     ICLQt_API ImgQ operator+(float val, const ImgQ &image);
00483   
00485 
00488     ICLQt_API ImgQ operator-(float val, const ImgQ &image);
00489     
00491 
00494     ICLQt_API ImgQ operator*(float val, const ImgQ &image);
00495     
00497 
00500     ICLQt_API ImgQ operator/(float val, const ImgQ &image);
00501   
00503 
00504     ICLQt_API ImgQ operator-(const ImgQ &image);
00505   
00507     /* }}} */
00508     
00510     /* {{{ open */
00511   
00513 
00514     ICLQt_API ImgQ exp(const ImgQ &image);
00515   
00517 
00518     ICLQt_API ImgQ ln(const ImgQ &image);
00519   
00521 
00522     ICLQt_API ImgQ sqr(const ImgQ &image);
00523     
00525 
00526     ICLQt_API ImgQ sqrt(const ImgQ &image);
00527     
00529 
00530     ICLQt_API ImgQ abs(const ImgQ &image);
00531     
00533     /* }}} */
00534     
00536     /* {{{ open */
00537   
00538     
00540 
00543     ICLQt_API ImgQ operator||(const ImgQ &a, const ImgQ &b);
00544   
00546 
00549     ICLQt_API ImgQ operator&&(const ImgQ &a, const ImgQ &b);
00550   
00552     template<class T> ICLQt_API
00553     ImgQ binOR(const ImgQ &a, const ImgQ &b);
00554     
00556     template<class T> ICLQt_API
00557     ImgQ binXOR(const ImgQ &a, const ImgQ &b);
00558   
00560     template<class T> ICLQt_API
00561     ImgQ binAND(const ImgQ &a, const ImgQ &b);
00562     
00564     /* }}} */
00565     
00567     /* {{{ open */
00568   
00570 
00587     ICLQt_API ImgQ operator,(const ImgQ &a, const ImgQ &b);
00588     
00590 
00593     ICLQt_API ImgQ operator%(const ImgQ &a, const ImgQ &b);
00594   
00596 
00600     ICLQt_API ImgQ operator|(const ImgQ &a, const ImgQ &b);
00601   
00603     /* }}} */
00604     
00606     /* {{{ open */
00607   
00608   
00610 
00611     struct ICLQt_API ImgROI{
00613       ImgQ image;
00614       
00616 
00617       ImgROI &operator=(const ImgQ &i);
00618       
00620 
00621       ImgROI &operator=(float val);
00622       
00624 
00625       ImgROI &operator=(const ImgROI &r);
00626       
00628       operator ImgQ();
00629     };
00630     
00632 
00653     ICLQt_API ImgROI roi(ImgQ &r);
00654     
00656 
00676     ICLQt_API ImgROI data(ImgQ &r);
00677   
00679     /* }}} */
00680     
00682     /* {{{ open */
00683   
00685 
00690     ICLQt_API void color(float r, float g = -1, float b = -1, float alpha = 255);
00691   
00693 
00698     ICLQt_API void fill(float r, float g = -1, float b = -1, float alpha = 255);
00699   
00701 
00704     ICLQt_API void colorinfo(float color[4], float fill[4]);
00705     
00707 
00711     ICLQt_API void cross(ImgQ &image, int x, int y);
00712   
00714 
00717     inline void cross(ImgQ &image, const utils::Point &p) { cross(image,p.x,p.y); }
00718   
00720 
00727     ICLQt_API void rect(ImgQ &image, int x, int y, int w, int h, int rounding = 0);
00728   
00730 
00734     inline void rect(ImgQ &image, const utils::Rect &r, int rounding=0){ rect(image,r.x,r.y,r.width,r.height,rounding); }
00735     
00737 
00738     ICLQt_API void triangle(ImgQ &image, int x1, int y1, int x2, int y2, int x3, int y3);
00739   
00741     inline void triangle(ImgQ &image, const utils::Point &a, const utils::Point &b, const utils::Point &c){
00742       triangle(image,a.x,a.y,b.x,b.y,c.x,c.y);
00743     }
00744     
00746 
00752     ICLQt_API void line(ImgQ &image, int x1, int y1, int x2, int y2);
00753   
00755 
00759     inline void line(ImgQ &image, const utils::Point &p1, const utils::Point &p2){ line(image,p1.x,p1.y, p2.x,p2.y); }
00760   
00762 
00765     ICLQt_API void linestrip(ImgQ &image, const std::vector<utils::Point> &pts, bool closeLoop = true);
00766     
00768     ICLQt_API void polygon(ImgQ &image, const std::vector<utils::Point> &corners);
00769     
00771 
00775     ICLQt_API void pix(ImgQ &image, int x, int y);
00776   
00778 
00781     inline void pix(ImgQ &image, const utils::Point &p){ pix(image,p.x,p.y); }
00782     
00784 
00787     ICLQt_API void pix(ImgQ &image, const vector<utils::Point> &pts);
00788   
00790 
00793     ICLQt_API void pix(ImgQ &image, const vector<vector<utils::Point> > &pts);
00794     
00796 
00803     ICLQt_API void circle(ImgQ &image, int x, int y, int r);
00804     
00806 
00813     ICLQt_API void text(ImgQ &image, int x, int y, const string &text);
00814   
00816 
00822     inline void text(ImgQ &image, const utils::Point &p,const string &sText){ text(image,p.x,p.y,sText); }
00823   
00825 
00829     ICLQt_API ImgQ label(const ImgQ &image, const string &text);
00830   
00832 
00835     ICLQt_API void font(int size, const string &family = "Arial");
00836     
00838 
00839     ICLQt_API void fontsize(int size);
00841     /* }}} */
00842   
00844     /* {{{ open */
00845   
00847     ICLQt_API void tic(const std::string &label = "");
00848     
00850     ICLQt_API void toc();
00852     /* }}} */
00853                   
00854   } // namespace qt
00855 }
00856 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines