FlyCaptureImageProvider.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package VisionX::ArmarXObjects::FlyCaptureImageProvider
19  * @author Markus Grotz ( markus dot grotz at kit dot edu )
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 
29 
31 #include <VisionX/interface/components/Calibration.h>
32 
33 #include <Calibration/Rectification.h>
34 #include <Calibration/Undistortion.h>
35 #include <Image/ImageProcessor.h>
36 #include <flycapture/FlyCapture2.h>
37 
38 namespace armarx
39 {
40 
41  /**
42  * @class FlyCaptureImageProviderPropertyDefinitions
43  * @brief
44  */
46  {
47  public:
50  {
51  defineOptionalProperty<std::string>(
52  "serialNumbers", "10121969 10121966 10121963 10121968", "camera serial numbers");
53 
54  defineRequiredProperty<std::string>("CalibrationFile", "Camera calibration file");
55 
56  defineOptionalProperty<visionx::ImageDimension>(
57  "dimensions", visionx::ImageDimension(1600, 1200), "")
58  .map("640x480", visionx::ImageDimension(640, 480))
59  .map("1600x1200", visionx::ImageDimension(1600, 1200));
60 
61  defineOptionalProperty<float>("FrameRate", 7.5f, "Frames per second")
62  .setMatchRegex("\\d+(.\\d*)?")
63  .setMin(0.0f)
64  .setMax(60.0f);
65 
66  defineOptionalProperty<bool>(
67  "UndistortImages", true, "Perform undistortion of the images.");
68  defineOptionalProperty<bool>(
69  "RectifyImages", true, "Perform rectification of the images.");
70 
71  defineOptionalProperty<std::string>(
72  "ReferenceFrameName", "EyeLeftCamera", "Optional reference frame name.");
73 
74  defineOptionalProperty<float>(
75  "Exposure",
76  300,
77  "Exposure value. Negative values can be used to enable auto exposure.");
78  defineOptionalProperty<float>(
79  "Shutter", 20, "Shutter value. Negative values can be used to enable auto mode.");
80  defineOptionalProperty<float>(
81  "Gain", 0.0, "Gain value. Negative values can be used to enable auto mode.");
82  }
83  };
84 
85  /**
86  * @class FlyCaptureImageProvider
87  *
88  * @ingroup VisionX-Components
89  * @brief A brief description
90  *
91  *
92  * Detailed Description
93  */
95  {
96  public:
97  /**
98  * @see armarx::ManagedIceObject::getDefaultName()
99  */
100  std::string
101  getDefaultName() const override
102  {
103  return "FlyCaptureImageProvider";
104  }
105 
106  protected:
107  void onInitCapturingImageProvider() override;
108 
109  void onExitCapturingImageProvider() override;
110 
111  void onStartCapture(float frameRate) override;
112 
113  void onStopCapture() override;
114 
115  bool capture(void** ppImageBuffers) override;
116 
117  /**
118  * @see PropertyUser::createPropertyDefinitions()
119  */
121 
122  CUndistortion* undistortion;
123  CRectification* rectification;
124 
127 
128  std::string calibrationFileName;
129 
130  private:
131  FlyCapture2::BusManager busManager;
132  std::vector<FlyCapture2::Camera*> cameras;
133 
134  std::vector<std::string> serialNumbers;
135 
136  std::vector<FlyCapture2::Image*> colorImages;
137 
138  CByteImage** cameraImages;
139  };
140 
142  virtual public FlyCaptureImageProvider,
143  virtual public visionx::StereoCalibrationCaptureProviderInterface
144  {
145 
146  public:
147  void onInitCapturingImageProvider() override;
148 
149  visionx::StereoCalibration
150  getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override
151  {
152  return stereoCalibration;
153  }
154 
155  bool
156  getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override
157  {
158  return undistortImages;
159  }
160 
161  std::string
162  getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
163  {
164  return getProperty<std::string>("ReferenceFrameName").getValue();
165  }
166 
167 
168  private:
169  visionx::StereoCalibration stereoCalibration;
170  };
171 } // namespace armarx
armarx::FlyCaptureImageProvider::rectifyImages
bool rectifyImages
Definition: FlyCaptureImageProvider.h:126
armarx::FlyCaptureImageProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: FlyCaptureImageProvider.cpp:292
armarx::FlyCaptureImageProvider::getDefaultName
std::string getDefaultName() const override
Definition: FlyCaptureImageProvider.h:101
visionx::CapturingImageProvider::frameRate
float frameRate
Required frame rate.
Definition: CapturingImageProvider.h:201
armarx::FlyCaptureImageProvider::onStopCapture
void onStopCapture() override
This is called when the image provider capturing has been stopped.
Definition: FlyCaptureImageProvider.cpp:232
armarx::FlyCaptureStereoCameraProvider::getImagesAreUndistorted
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
Definition: FlyCaptureImageProvider.h:156
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::FlyCaptureStereoCameraProvider::onInitCapturingImageProvider
void onInitCapturingImageProvider() override
This is called when the Component::onInitComponent() is called.
Definition: FlyCaptureImageProvider.cpp:299
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::FlyCaptureImageProvider::onInitCapturingImageProvider
void onInitCapturingImageProvider() override
This is called when the Component::onInitComponent() is called.
Definition: FlyCaptureImageProvider.cpp:38
armarx::FlyCaptureImageProvider::onStartCapture
void onStartCapture(float frameRate) override
This is called when the image provider capturing has been started.
Definition: FlyCaptureImageProvider.cpp:143
visionx::CapturingImageProvider::capture
virtual void capture()
Definition: CapturingImageProvider.cpp:109
visionx::CapturingImageProvider
The CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
Definition: CapturingImageProvider.h:52
armarx::FlyCaptureImageProvider::undistortion
CUndistortion * undistortion
Definition: FlyCaptureImageProvider.h:122
armarx::FlyCaptureImageProvider::undistortImages
bool undistortImages
Definition: FlyCaptureImageProvider.h:125
Component.h
armarx::FlyCaptureImageProvider::rectification
CRectification * rectification
Definition: FlyCaptureImageProvider.h:123
CapturingImageProvider.h
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::FlyCaptureStereoCameraProvider::getStereoCalibration
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
Definition: FlyCaptureImageProvider.h:150
armarx::FlyCaptureImageProvider
A brief description.
Definition: FlyCaptureImageProvider.h:94
armarx::FlyCaptureStereoCameraProvider
Definition: FlyCaptureImageProvider.h:141
armarx::FlyCaptureStereoCameraProvider::getReferenceFrame
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
Definition: FlyCaptureImageProvider.h:162
armarx::FlyCaptureImageProvider::calibrationFileName
std::string calibrationFileName
Definition: FlyCaptureImageProvider.h:128
armarx::FlyCaptureImageProvider::onExitCapturingImageProvider
void onExitCapturingImageProvider() override
This is called when the Component::onExitComponent() setup is called.
Definition: FlyCaptureImageProvider.cpp:114
armarx::FlyCaptureImageProviderPropertyDefinitions
Definition: FlyCaptureImageProvider.h:45
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::FlyCaptureImageProviderPropertyDefinitions::FlyCaptureImageProviderPropertyDefinitions
FlyCaptureImageProviderPropertyDefinitions(std::string prefix)
Definition: FlyCaptureImageProvider.h:48