Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
UnaryOp.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   : ICLFilter/src/ICLFilter/UnaryOp.h                      **
00010 ** Module : ICLFilter                                              **
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/Configurable.h>
00035 #include <ICLFilter/OpROIHandler.h>
00036 
00037 namespace icl{
00039   namespace utils{
00040     class MultiThreader;
00041   }
00044   namespace filter{
00045     
00046     
00048 
00051     class ICLFilter_API UnaryOp : public utils::Configurable{
00052       void initConfigurable();
00053       
00054       public:
00055   
00057       UnaryOp();
00058   
00060       UnaryOp(const UnaryOp &other);
00061   
00063       UnaryOp &operator=(const UnaryOp &other);
00064   
00065       
00067       virtual ~UnaryOp();
00068         
00070       virtual void apply(const core::ImgBase *operand1, core::ImgBase **dst)=0;
00071   
00073       virtual ICL_DEPRECATED void applyMT(const core::ImgBase *operand1, 
00074                                           core::ImgBase **dst, unsigned int nThreads);
00075   
00077 
00080       virtual const core::ImgBase *apply(const core::ImgBase *src);
00081       
00083       inline void operator()(const core::ImgBase *src, core::ImgBase **dst){
00084         apply(src,dst);
00085       }
00086 
00088       inline const core::ImgBase *operator()(const core::ImgBase *src){
00089         return apply(src);
00090       }
00091 
00093       inline const core::ImgBase &operator()(const core::ImgBase &src){
00094         return *apply(&src);
00095       }
00096 
00097       
00099 
00102       void setClipToROI (bool bClipToROI) { 
00103         m_oROIHandler.setClipToROI(bClipToROI); 
00104         prop("UnaryOp.clip to ROI").value = bClipToROI ? "on" : "off";
00105         call_callbacks("UnaryOp.clip to ROI",this);
00106       }
00107       
00109 
00112       void setCheckOnly (bool bCheckOnly) { 
00113         m_oROIHandler.setCheckOnly(bCheckOnly); 
00114         prop("UnaryOp.check only").value = bCheckOnly ? "on" : "off";
00115         call_callbacks("UnaryOp.check only",this);
00116       }
00117       
00119 
00122       bool getClipToROI() const { return m_oROIHandler.getClipToROI(); }
00123       
00125 
00128       bool getCheckOnly() const { return m_oROIHandler.getCheckOnly(); }
00129       
00130       
00132       virtual void setPropertyValue(const std::string &propertyName, const utils::Any &value) throw (utils::ICLException);
00133   
00135 
00147       static UnaryOp *fromString(const std::string &definition) throw (utils::ICLException);
00148   
00150 
00151       static std::string getFromStringSyntax(const std::string &opSpecifier) throw (utils::ICLException);
00152   
00154       static std::vector<std::string> listFromStringOps();
00155   
00157       static void applyFromString(const std::string &definition, 
00158                                   const core::ImgBase *src, 
00159                                   core::ImgBase **dst) throw (utils::ICLException);
00160       
00161       protected:
00162       bool prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize, 
00163                     core::format eFormat, int nChannels, const utils::Rect& roi, 
00164                     utils::Time timestamp=utils::Time::null){
00165         return m_oROIHandler.prepare(ppoDst, eDepth,imgSize,eFormat, nChannels, roi, timestamp);
00166       }
00167       
00169       virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc) {
00170         return m_oROIHandler.prepare(ppoDst, poSrc);
00171       }
00172       
00175       virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepth) {
00176         return m_oROIHandler.prepare(ppoDst, poSrc, eDepth);
00177       }
00178   
00179       utils::MultiThreader *m_poMT;
00180       
00181       private:
00182     
00183       OpROIHandler m_oROIHandler;
00184       
00185       core::ImgBase *m_buf;
00186     };    
00187   
00188   
00189   #define DYNAMIC_UNARY_OP_CREATION_FUNCTION(NAME)       \
00190     extern "C" {                                         \
00191       UnaryOp *create_##NAME(const std::string &s){      \
00192         return NAME(s);                                  \
00193       }                                                  \
00194     }
00195     
00196   } // namespace filter
00197 }
00198 
00199 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines