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.GPL  **
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 <ICLFilter/OpROIHandler.h>
00034 #include <ICLUtils/Configurable.h>
00035 
00036 namespace icl{
00038   namespace utils{
00039     class MultiThreader;
00040   }
00043   namespace filter{
00044     
00045     
00047 
00050     class UnaryOp : public utils::Configurable{
00051       void initConfigurable();
00052       
00053       public:
00054   
00056       UnaryOp();
00057   
00059       UnaryOp(const UnaryOp &other);
00060   
00062       UnaryOp &operator=(const UnaryOp &other);
00063   
00064       
00066       virtual ~UnaryOp();
00067         
00069       virtual void apply(const core::ImgBase *operand1, core::ImgBase **dst)=0;
00070   
00072       virtual ICL_DEPRECATED void applyMT(const core::ImgBase *operand1, 
00073                                           core::ImgBase **dst, unsigned int nThreads);
00074   
00076 
00079       virtual const core::ImgBase *apply(const core::ImgBase *src);
00080       
00082       inline void operator()(const core::ImgBase *src, core::ImgBase **dst){
00083         apply(src,dst);
00084       }
00085 
00087       inline const core::ImgBase *operator()(const core::ImgBase *src){
00088         return apply(src);
00089       }
00090 
00092       inline const core::ImgBase &operator()(const core::ImgBase &src){
00093         return *apply(&src);
00094       }
00095 
00096       
00098 
00101       void setClipToROI (bool bClipToROI) { 
00102         m_oROIHandler.setClipToROI(bClipToROI); 
00103         prop("UnaryOp.clip to ROI").value = bClipToROI ? "on" : "off";
00104         call_callbacks("UnaryOp.clip to ROI");
00105       }
00106       
00108 
00111       void setCheckOnly (bool bCheckOnly) { 
00112         m_oROIHandler.setCheckOnly(bCheckOnly); 
00113         prop("UnaryOp.check only").value = bCheckOnly ? "on" : "off";
00114         call_callbacks("UnaryOp.check only");
00115       }
00116       
00118 
00121       bool getClipToROI() const { return m_oROIHandler.getClipToROI(); }
00122       
00124 
00127       bool getCheckOnly() const { return m_oROIHandler.getCheckOnly(); }
00128       
00129       
00131       virtual void setPropertyValue(const std::string &propertyName, const utils::Any &value) throw (utils::ICLException);
00132   
00134 
00146       static UnaryOp *fromString(const std::string &definition) throw (utils::ICLException);
00147   
00149 
00150       static std::string getFromStringSyntax(const std::string &opSpecifier) throw (utils::ICLException);
00151   
00153       static std::vector<std::string> listFromStringOps();
00154   
00156       static void applyFromString(const std::string &definition, 
00157                                   const core::ImgBase *src, 
00158                                   core::ImgBase **dst) throw (utils::ICLException);
00159       
00160       protected:
00161       bool prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize, 
00162                     core::format eFormat, int nChannels, const utils::Rect& roi, 
00163                     utils::Time timestamp=utils::Time::null){
00164         return m_oROIHandler.prepare(ppoDst, eDepth,imgSize,eFormat, nChannels, roi, timestamp);
00165       }
00166       
00168       virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc) {
00169         return m_oROIHandler.prepare(ppoDst, poSrc);
00170       }
00171       
00174       virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepth) {
00175         return m_oROIHandler.prepare(ppoDst, poSrc, eDepth);
00176       }
00177   
00178       utils::MultiThreader *m_poMT;
00179       
00180       private:
00181     
00182       OpROIHandler m_oROIHandler;
00183       
00184       core::ImgBase *m_buf;
00185     };    
00186   
00187   
00188   #define DYNAMIC_UNARY_OP_CREATION_FUNCTION(NAME)       \
00189     extern "C" {                                         \
00190       UnaryOp *create_##NAME(const std::string &s){      \
00191         return NAME(s);                                  \
00192       }                                                  \
00193     }
00194     
00195   } // namespace filter
00196 }
00197 
00198 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines