Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PylonCameraOptions.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   : ICLIO/src/ICLIO/PylonCameraOptions.h                   **
00010 ** Module : ICLIO                                                  **
00011 ** Authors: Viktor Richter                                         **
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 <ICLIO/PylonIncludes.h>
00034 
00035 #include <ICLUtils/Macros.h>
00036 #include <ICLIO/PylonUtils.h>
00037 #include <ICLUtils/Configurable.h>
00038 
00039 namespace icl {
00040   namespace io{
00041     namespace pylon {
00042 
00044       class ICLIO_API PylonCameraOptions : public utils::Configurable{
00045         public:
00047 
00052           PylonCameraOptions(Pylon::IPylonDevice* camera, Interruptable* interu);
00053 
00055           ~PylonCameraOptions();
00056 
00058           Pylon::PixelType getCameraPixelType();
00060           int getCameraPixelSize();
00062           long getNeededBufferSize();
00064           void acquisitionStart();
00066           void acquisitionStop();
00068           int getHeight();
00070           int getWidth();
00072           std::string getFormatString();
00074           bool omitDoubleFrames();
00076           double getResultingFrameRateAbs();
00077 
00078         private:
00080           Interruptable* m_Interu;
00082           Pylon::IPylonDevice* m_Camera;
00084           bool m_OmitDoubleFrames;
00085 
00087           std::string getType(const std::string &name);
00089           std::string getInfo(const std::string &name);
00091           std::string getValue(const std::string &name);
00093           int isVolatile(const std::string &propertyName);
00095           void processPropertyChange(const utils::Configurable::Property &prop);
00097           void addToPropertyList(std::vector<std::string> &ps, const GenApi::CNodePtr& node);
00098 
00100           GenApi::INode *getNode(std::string name);
00101       };
00102 
00103     } // namespace pylon
00104 
00105     // here come some convenience functions for pylon namespace
00106     namespace pylon {
00107       
00109       template <typename NODE, typename RET>
00110       RET getNodeValue(NODE* node){
00111         return node -> GetValue();
00112       }
00113 
00115       template <typename NODE, typename RET>
00116       int64_t getNodeValue(GenApi::IEnumeration* node){
00117         return node -> GetIntValue();
00118       }
00119 
00121       template <typename NODE, typename VAL>
00122       void setNodeValue(NODE* node, VAL value){
00123         node -> SetValue(value, true);
00124         return;
00125       }
00126 
00128       template <typename NODE, typename VAL>
00129       void setNodeValue(GenApi::IEnumeration* node, std::string value){
00130         node -> FromString(value.c_str(), true);
00131         return;
00132       }
00133 
00135       template <typename NODE, typename VAL>
00136       void setNodeValue(GenApi::IEnumeration* node, int64_t value){
00137         node -> SetIntValue(value, true);
00138         return;
00139       }
00140 
00142       template <typename OBJ, typename NODE, typename VAL>
00143       bool setParameterValueOf(OBJ* object, std::string parameter, VAL value){
00144         GenApi::INode* node = object -> GetNodeMap() -> GetNode(parameter.c_str());
00145         if (!node) {
00146           DEBUG_LOG("There is no parameter called '" << parameter << "'")
00147               return false;
00148         }
00149         //dynamic cast to needed node-type
00150         NODE* node2;
00151         try{
00152           node2 = dynamic_cast<NODE*>(node);
00153         } catch (std::exception &e){
00154           DEBUG_LOG ("Could not cast node '"<< parameter << "' to desired type2")
00155               return false;
00156         }
00157         if(!GenApi::IsWritable(node2)){
00158           DEBUG_LOG("Parameter called '" << parameter << "' is not writable.")
00159               return false;
00160         }
00161         // now setting parameter
00162         try{
00163           setNodeValue<NODE, VAL>(node2, value);
00164           return true;
00165         }
00166         catch (GenICam::GenericException &e) {
00167           std::cerr << e.what() << std::endl;
00168           return false;
00169         }
00170       }
00171 
00173       template <typename SOURCE, typename NODE, typename RET>
00174       RET getParameterValueOf(SOURCE* source, std::string param){
00175         GenApi::INode* node = source -> GetNodeMap() -> GetNode(param.c_str());
00176         if(!node){
00177           throw utils::ICLException("parameter of this type not found");
00178         }
00179         //dynamic cast to needed node-type
00180         try{
00181           NODE* node2 = dynamic_cast<NODE*>(node);
00182           if(!node2){
00183             throw utils::ICLException("Could not cast " + param + " to desired type");
00184           }
00185           if(!GenApi::IsReadable(node2)){
00186             throw utils::ICLException("The node " + param + " is not Readable");
00187           }
00188           return getNodeValue<NODE, RET>(node2);
00189         } catch (std::exception &e){
00190           throw utils::ICLException(e.what());
00191         }
00192       }
00193 
00195       ICLIO_API std::string getParameterValueString(
00196           Pylon::IPylonDevice* device, std::string parameter);
00197       
00198     } //namespace pylon
00199   } // namespace io
00200 } //namespace icl
00201 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines