KinectAndCameraCalibration.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::Component
19  * @author David Schiebener (schiebener at kit dot edu)
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #pragma once
27 
28 #include <opencv2/opencv.hpp>
29 #include <string>
30 
31 // VisionX
33 #include <VisionX/interface/components/KinectAndCameraCalibration.h>
34 
35 // IVT
36 #include <Math/Math3d.h>
37 #include <Math/Math2d.h>
38 
40 
41 
42 class CvCalibFilter;
43 class CByteImage;
44 
45 
46 
47 namespace visionx
48 {
49 
52  {
53  public:
56  {
57  defineOptionalProperty<std::string>("CameraImageProviderAdapterName", "Armar3ImageProvider", "Ice Adapter name of the camera image provider");
58  defineOptionalProperty<std::string>("KinectImageProviderAdapterName", "OpenNIPointCloudProvider", "Ice Adapter name of the Kinect image provider");
59  defineOptionalProperty<int>("NumberOfImages", 20, "Number of images used for the calibration");
60  defineOptionalProperty<int>("WaitingIntervalBetweenImages", 500, "Waiting time between captured images, in ms");
61  defineOptionalProperty<int>("NumberOfRows", 5, "Number of rows on the calibration pattern");
62  defineOptionalProperty<int>("NumberOfColumns", 5, "Number of columns on the calibration pattern");
63  defineOptionalProperty<double>("PatternSquareSize", 30.0, "Size of the squares on the calibration pattern");
64  defineOptionalProperty<std::string>("OutputFileName", "cameras.txt", "Path to the file for saving the calibration");
65  }
66  };
67 
68  /**
69  * KinectAndCameraCalibration executes the calibration for the left camera of the stereo and kinect rgb camera.
70  * To this end, it gives you the pose of the left camera based on the kinect frame with saving the file including calibration data.
71  *
72  * \componentproperties
73  * \prop VisionX.KinectAndCameraCalibration.CameraImageProviderAdapterName: Ice Adapter name of the camera image provider.
74  * \prop VisionX.KinectAndCameraCalibration.KinectImageProviderAdapterName: Ice Adapter name of the Kinect image provider.
75  * \prop VisionX.KinectAndCameraCalibration.NumberOfImages: Number of images used for the calibration.
76  * \prop VisionX.KinectAndCameraCalibration.WaitingIntervalBetweenImages: Waiting time between captured images, in ms.
77  * \prop VisionX.KinectAndCameraCalibration.NumberOfRows: Number of rows on the calibration pattern.
78  * \prop VisionX.KinectAndCameraCalibration.NumberOfColumns: Number of columns on the calibration pattern.
79  * \prop VisionX.KinectAndCameraCalibration.PatternSquareSize: Size of the squares on the calibration pattern.
80  * \prop VisionX.KinectAndCameraCalibration.OutputFileName: Path to the file for saving the calibration.
81  */
82 
84  virtual public visionx::ImageProcessor,
85  virtual public visionx::KinectAndCameraCalibrationInterface
86  {
87  public:
88 
89  /**
90  * @see Component::getDefaultName()
91  */
92  std::string getDefaultName() const override
93  {
94  return "KinectAndCameraCalibration";
95  }
96 
97 
98  /**
99  * ice related functions (todo: put comments)
100  */
101  void startCalibration(const ::Ice::Current& c = Ice::emptyCurrent) override;
102  void stopCalibration(const ::Ice::Current& c = Ice::emptyCurrent) override;
103  visionx::KinectPoseCalibration getCalibrationParameters(const ::Ice::Current& c = Ice::emptyCurrent) override;
104 
105 
106  protected:
107  // inherited from VisionComponent
108  void onInitImageProcessor() override;
109  void onConnectImageProcessor() override;
110  void onExitImageProcessor() override;
111 
112  void process() override;
113 
114 
115  /**
116  * @see PropertyUser::createPropertyDefinitions()
117  */
119  {
123  }
124 
125  private:
126  std::string cameraImageProviderName, kinectImageProviderName;
127  ImageProviderInterfacePrx cameraImageProviderPrx, kinectImageProviderPrx;
128  CvCalibFilter* m_pCalibFilter;
129 
130  CByteImage** cameraImages, ** kinectImages;
131  int waitingIntervalBetweenImages, desiredNumberOfImages, numberOfCapturedImages;
132  double etalonParams[3];
133 
134  std::string m_sCameraParameterFileName;
135 
136  IceUtil::Time startingTime, timeOfLastCapture;
137  bool finished;
138 
139  bool requested;
140  KinectPoseCalibration result;
141  KinectAndCameraCalibrationListenerPrx listenerPrx;
142  };
143 
144 }
145 
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::KinectAndCameraCalibration::startCalibration
void startCalibration(const ::Ice::Current &c=Ice::emptyCurrent) override
ice related functions (todo: put comments)
Definition: KinectAndCameraCalibration.cpp:214
visionx::ImageProcessor
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
Definition: ImageProcessor.h:87
visionx::KinectAndCameraCalibration::onExitImageProcessor
void onExitImageProcessor() override
Exit the ImapeProcessor component.
Definition: KinectAndCameraCalibration.cpp:105
visionx::KinectAndCameraCalibration::onConnectImageProcessor
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
Definition: KinectAndCameraCalibration.cpp:75
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
visionx::KinectAndCameraCalibration::stopCalibration
void stopCalibration(const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: KinectAndCameraCalibration.cpp:220
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
visionx::KinectAndCameraCalibration
KinectAndCameraCalibration executes the calibration for the left camera of the stereo and kinect rgb ...
Definition: KinectAndCameraCalibration.h:83
visionx::KinectAndCameraCalibration::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: KinectAndCameraCalibration.h:118
visionx::KinectAndCameraCalibration::process
void process() override
Process the vision component.
Definition: KinectAndCameraCalibration.cpp:118
ImageProcessor.h
calibfilter.h
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
visionx::KinectAndCameraCalibration::getCalibrationParameters
visionx::KinectPoseCalibration getCalibrationParameters(const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: KinectAndCameraCalibration.cpp:238
visionx::KinectAndCameraCalibration::getDefaultName
std::string getDefaultName() const override
Definition: KinectAndCameraCalibration.h:92
visionx::KinectAndCameraCalibration::onInitImageProcessor
void onInitImageProcessor() override
Setup the vision component.
Definition: KinectAndCameraCalibration.cpp:44
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::ImageProcessorPropertyDefinitions
Definition: ImageProcessor.h:61
visionx::KinectAndCameraCalibrationPropertyDefinitions::KinectAndCameraCalibrationPropertyDefinitions
KinectAndCameraCalibrationPropertyDefinitions(std::string prefix)
Definition: KinectAndCameraCalibration.h:54
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
visionx::KinectAndCameraCalibrationPropertyDefinitions
Definition: KinectAndCameraCalibration.h:50
CvCalibFilter
Definition: calibfilter.h:78