Image Component Library (ICL)
PylonCameraOptions.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLIO/src/ICLIO/PylonCameraOptions.h **
10 ** Module : ICLIO **
11 ** Authors: Viktor Richter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLIO/PylonIncludes.h>
34 
35 #include <ICLUtils/Macros.h>
36 #include <ICLIO/PylonUtils.h>
37 #include <ICLUtils/Configurable.h>
38 
39 namespace icl {
40  namespace io{
41  namespace pylon {
42 
45  public:
47 
52  PylonCameraOptions(Pylon::IPylonDevice* camera, Interruptable* interu);
53 
56 
58  Pylon::PixelType getCameraPixelType();
60  int getCameraPixelSize();
62  long getNeededBufferSize();
64  void acquisitionStart();
66  void acquisitionStop();
68  int getHeight();
70  int getWidth();
72  std::string getFormatString();
74  bool omitDoubleFrames();
76  double getResultingFrameRateAbs();
77 
78  private:
82  Pylon::IPylonDevice* m_Camera;
85 
87  std::string getType(const std::string &name);
89  std::string getInfo(const std::string &name);
91  std::string getValue(const std::string &name);
93  int isVolatile(const std::string &propertyName);
95  void processPropertyChange(const utils::Configurable::Property &prop);
97  void addToPropertyList(std::vector<std::string> &ps, const GenApi::CNodePtr& node);
98 
100  GenApi::INode *getNode(std::string name);
101  };
102 
103  } // namespace pylon
104 
105  // here come some convenience functions for pylon namespace
106  namespace pylon {
107 
109  template <typename NODE, typename RET>
110  RET getNodeValue(NODE* node){
111  return node -> GetValue();
112  }
113 
115  template <typename NODE, typename RET>
116  int64_t getNodeValue(GenApi::IEnumeration* node){
117  return node -> GetIntValue();
118  }
119 
121  template <typename NODE, typename VAL>
122  void setNodeValue(NODE* node, VAL value){
123  node -> SetValue(value, true);
124  return;
125  }
126 
128  template <typename NODE, typename VAL>
129  void setNodeValue(GenApi::IEnumeration* node, std::string value){
130  node -> FromString(value.c_str(), true);
131  return;
132  }
133 
135  template <typename NODE, typename VAL>
136  void setNodeValue(GenApi::IEnumeration* node, int64_t value){
137  node -> SetIntValue(value, true);
138  return;
139  }
140 
142  template <typename OBJ, typename NODE, typename VAL>
143  bool setParameterValueOf(OBJ* object, std::string parameter, VAL value){
144  GenApi::INode* node = object -> GetNodeMap() -> GetNode(parameter.c_str());
145  if (!node) {
146  DEBUG_LOG("There is no parameter called '" << parameter << "'")
147  return false;
148  }
149  //dynamic cast to needed node-type
150  NODE* node2;
151  try{
152  node2 = dynamic_cast<NODE*>(node);
153  } catch (std::exception &e){
154  DEBUG_LOG ("Could not cast node '"<< parameter << "' to desired type2")
155  return false;
156  }
157  if(!GenApi::IsWritable(node2)){
158  DEBUG_LOG("Parameter called '" << parameter << "' is not writable.")
159  return false;
160  }
161  // now setting parameter
162  try{
163  setNodeValue<NODE, VAL>(node2, value);
164  return true;
165  }
166  catch (GenICam::GenericException &e) {
167  std::cerr << e.what() << std::endl;
168  return false;
169  }
170  }
171 
173  template <typename SOURCE, typename NODE, typename RET>
174  RET getParameterValueOf(SOURCE* source, std::string param){
175  GenApi::INode* node = source -> GetNodeMap() -> GetNode(param.c_str());
176  if(!node){
177  throw utils::ICLException("parameter of this type not found");
178  }
179  //dynamic cast to needed node-type
180  try{
181  NODE* node2 = dynamic_cast<NODE*>(node);
182  if(!node2){
183  throw utils::ICLException("Could not cast " + param + " to desired type");
184  }
185  if(!GenApi::IsReadable(node2)){
186  throw utils::ICLException("The node " + param + " is not Readable");
187  }
188  return getNodeValue<NODE, RET>(node2);
189  } catch (std::exception &e){
190  throw utils::ICLException(e.what());
191  }
192  }
193 
196  Pylon::IPylonDevice* device, std::string parameter);
197 
198  } //namespace pylon
199  } // namespace io
200 } //namespace icl
201 
ICLIO_API std::string getParameterValueString(Pylon::IPylonDevice *device, std::string parameter)
returns a string representation of the value of a parameter of the camera.
undocument this line if you encounter any issues!
Definition: Any.h:37
Interruptable * m_Interu
the Interruptable that provides interruption for the camera.
Definition: PylonCameraOptions.h:80
#define DEBUG_LOG(x)
Definition: Macros.h:57
RET getParameterValueOf(SOURCE *source, std::string param)
get the value of a parameter of a specific type from a spec. source (camera/grabber)
Definition: PylonCameraOptions.h:174
Pylon::IPylonDevice * m_Camera
The camera.
Definition: PylonCameraOptions.h:82
bool m_OmitDoubleFrames
whether double frames should be omitted.
Definition: PylonCameraOptions.h:84
bool setParameterValueOf(OBJ *object, std::string parameter, VAL value)
set the value of a parameter of a specific type on a specific source (camera/grabber)
Definition: PylonCameraOptions.h:143
#define ICLIO_API
Definition: CompatMacros.h:176
void setNodeValue(NODE *node, VAL value)
template function to set the value of an IValue-subclass
Definition: PylonCameraOptions.h:122
Utility Structure.
Definition: PylonUtils.h:202
Interface for classes that can be configured from configuration-files and GUI-Components.
Definition: Configurable.h:194
Base class for Exception handling in the ICL.
Definition: Exception.h:42
RET getNodeValue(NODE *node)
template function to get the value of an IValue-subclass
Definition: PylonCameraOptions.h:110
Represents a single property.
Definition: Configurable.h:200
This is a helper class for Pylon camera settings.
Definition: PylonCameraOptions.h:44