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 
32 #include <flycapture/FlyCapture2.h>
33 
34 #include <VisionX/interface/components/Calibration.h>
35 
36 #include <Image/ImageProcessor.h>
37 
38 #include <Calibration/Undistortion.h>
39 #include <Calibration/Rectification.h>
40 
41 
42 namespace armarx
43 {
44 
45  /**
46  * @class FlyCaptureImageProviderPropertyDefinitions
47  * @brief
48  */
51  {
52  public:
55  {
56  defineOptionalProperty<std::string>("serialNumbers", "10121969 10121966 10121963 10121968", "camera serial numbers");
57 
58  defineRequiredProperty<std::string>("CalibrationFile", "Camera calibration file");
59 
60  defineOptionalProperty<visionx::ImageDimension>("dimensions", visionx::ImageDimension(1600, 1200), "")
61  .map("640x480", visionx::ImageDimension(640, 480))
62  .map("1600x1200", visionx::ImageDimension(1600, 1200));
63 
64  defineOptionalProperty<float>("FrameRate", 7.5f, "Frames per second")
65  .setMatchRegex("\\d+(.\\d*)?")
66  .setMin(0.0f)
67  .setMax(60.0f);
68 
69  defineOptionalProperty<bool>("UndistortImages", true, "Perform undistortion of the images.");
70  defineOptionalProperty<bool>("RectifyImages", true, "Perform rectification of the images.");
71 
72  defineOptionalProperty<std::string>("ReferenceFrameName", "EyeLeftCamera", "Optional reference frame name.");
73 
74  defineOptionalProperty<float>("Exposure", 300, "Exposure value. Negative values can be used to enable auto exposure.");
75  defineOptionalProperty<float>("Shutter", 20, "Shutter value. Negative values can be used to enable auto mode.");
76  defineOptionalProperty<float>("Gain", 0.0, "Gain value. Negative values can be used to enable auto mode.");
77  }
78  };
79 
80  /**
81  * @class FlyCaptureImageProvider
82  *
83  * @ingroup VisionX-Components
84  * @brief A brief description
85  *
86  *
87  * Detailed Description
88  */
90  virtual public visionx::CapturingImageProvider
91  {
92  public:
93  /**
94  * @see armarx::ManagedIceObject::getDefaultName()
95  */
96  std::string getDefaultName() const override
97  {
98  return "FlyCaptureImageProvider";
99  }
100 
101  protected:
102 
103  void onInitCapturingImageProvider() override;
104 
105  void onExitCapturingImageProvider() override;
106 
107  void onStartCapture(float frameRate) override;
108 
109  void onStopCapture() override;
110 
111  bool capture(void** ppImageBuffers) override;
112 
113  /**
114  * @see PropertyUser::createPropertyDefinitions()
115  */
117 
118  CUndistortion* undistortion;
119  CRectification* rectification;
120 
123 
124  std::string calibrationFileName;
125 
126  private:
127 
128  FlyCapture2::BusManager busManager;
129  std::vector<FlyCapture2::Camera*> cameras;
130 
131  std::vector<std::string> serialNumbers;
132 
133  std::vector<FlyCapture2::Image*> colorImages;
134 
135  CByteImage** cameraImages;
136  };
137 
138 
140  virtual public FlyCaptureImageProvider,
141  virtual public visionx::StereoCalibrationCaptureProviderInterface
142  {
143 
144  public:
145 
146 
147  void onInitCapturingImageProvider() override;
148 
149  visionx::StereoCalibration getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override
150  {
151  return stereoCalibration;
152  }
153 
154  bool getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override
155  {
156  return undistortImages;
157  }
158 
159  std::string getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
160  {
161  return getProperty<std::string>("ReferenceFrameName").getValue();
162  }
163 
164 
165  private:
166 
167  visionx::StereoCalibration stereoCalibration;
168 
169  };
170 }
171 
armarx::FlyCaptureImageProvider::rectifyImages
bool rectifyImages
Definition: FlyCaptureImageProvider.h:122
armarx::FlyCaptureImageProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: FlyCaptureImageProvider.cpp:280
armarx::FlyCaptureImageProvider::getDefaultName
std::string getDefaultName() const override
Definition: FlyCaptureImageProvider.h:96
visionx::CapturingImageProvider::frameRate
float frameRate
Required frame rate.
Definition: CapturingImageProvider.h:198
armarx::FlyCaptureImageProvider::onStopCapture
void onStopCapture() override
This is called when the image provider capturing has been stopped.
Definition: FlyCaptureImageProvider.cpp:224
armarx::FlyCaptureStereoCameraProvider::getImagesAreUndistorted
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
Definition: FlyCaptureImageProvider.h:154
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::FlyCaptureStereoCameraProvider::onInitCapturingImageProvider
void onInitCapturingImageProvider() override
This is called when the Component::onInitComponent() is called.
Definition: FlyCaptureImageProvider.cpp:287
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
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:138
visionx::CapturingImageProvider::capture
virtual void capture()
Definition: CapturingImageProvider.cpp:106
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:118
armarx::FlyCaptureImageProvider::undistortImages
bool undistortImages
Definition: FlyCaptureImageProvider.h:121
Component.h
armarx::FlyCaptureImageProvider::rectification
CRectification * rectification
Definition: FlyCaptureImageProvider.h:119
CapturingImageProvider.h
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::FlyCaptureStereoCameraProvider::getStereoCalibration
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
Definition: FlyCaptureImageProvider.h:149
armarx::FlyCaptureImageProvider
A brief description.
Definition: FlyCaptureImageProvider.h:89
armarx::FlyCaptureStereoCameraProvider
Definition: FlyCaptureImageProvider.h:139
armarx::FlyCaptureStereoCameraProvider::getReferenceFrame
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
Definition: FlyCaptureImageProvider.h:159
armarx::FlyCaptureImageProvider::calibrationFileName
std::string calibrationFileName
Definition: FlyCaptureImageProvider.h:124
armarx::FlyCaptureImageProvider::onExitCapturingImageProvider
void onExitCapturingImageProvider() override
This is called when the Component::onExitComponent() setup is called.
Definition: FlyCaptureImageProvider.cpp:110
armarx::FlyCaptureImageProviderPropertyDefinitions
Definition: FlyCaptureImageProvider.h:49
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::FlyCaptureImageProviderPropertyDefinitions::FlyCaptureImageProviderPropertyDefinitions
FlyCaptureImageProviderPropertyDefinitions(std::string prefix)
Definition: FlyCaptureImageProvider.h:53