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 <string>
29
30#include <opencv2/opencv.hpp>
31
32// VisionX
34#include <VisionX/interface/components/KinectAndCameraCalibration.h>
35
36// IVT
38
39#include <Math/Math2d.h>
40#include <Math/Math3d.h>
41
42
43class CvCalibFilter;
44class CByteImage;
45
46namespace visionx
47{
48
51 {
52 public:
55 {
56 defineOptionalProperty<std::string>("CameraImageProviderAdapterName",
57 "Armar3ImageProvider",
58 "Ice Adapter name of the camera image provider");
59 defineOptionalProperty<std::string>("KinectImageProviderAdapterName",
60 "OpenNIPointCloudProvider",
61 "Ice Adapter name of the Kinect image provider");
63 "NumberOfImages", 20, "Number of images used for the calibration");
65 "WaitingIntervalBetweenImages", 500, "Waiting time between captured images, in ms");
67 "NumberOfRows", 5, "Number of rows on the calibration pattern");
69 "NumberOfColumns", 5, "Number of columns on the calibration pattern");
71 "PatternSquareSize", 30.0, "Size of the squares on the calibration pattern");
73 "OutputFileName", "cameras.txt", "Path to the file for saving the calibration");
74 }
75 };
76
77 /**
78 * KinectAndCameraCalibration executes the calibration for the left camera of the stereo and kinect rgb camera.
79 * To this end, it gives you the pose of the left camera based on the kinect frame with saving the file including calibration data.
80 *
81 * \componentproperties
82 * \prop VisionX.KinectAndCameraCalibration.CameraImageProviderAdapterName: Ice Adapter name of the camera image provider.
83 * \prop VisionX.KinectAndCameraCalibration.KinectImageProviderAdapterName: Ice Adapter name of the Kinect image provider.
84 * \prop VisionX.KinectAndCameraCalibration.NumberOfImages: Number of images used for the calibration.
85 * \prop VisionX.KinectAndCameraCalibration.WaitingIntervalBetweenImages: Waiting time between captured images, in ms.
86 * \prop VisionX.KinectAndCameraCalibration.NumberOfRows: Number of rows on the calibration pattern.
87 * \prop VisionX.KinectAndCameraCalibration.NumberOfColumns: Number of columns on the calibration pattern.
88 * \prop VisionX.KinectAndCameraCalibration.PatternSquareSize: Size of the squares on the calibration pattern.
89 * \prop VisionX.KinectAndCameraCalibration.OutputFileName: Path to the file for saving the calibration.
90 */
91
93 virtual public visionx::ImageProcessor,
94 virtual public visionx::KinectAndCameraCalibrationInterface
95 {
96 public:
97 /**
98 * @see Component::getDefaultName()
99 */
100 std::string
101 getDefaultName() const override
102 {
103 return "KinectAndCameraCalibration";
104 }
105
106 /**
107 * ice related functions (todo: put comments)
108 */
109 void startCalibration(const ::Ice::Current& c = Ice::emptyCurrent) override;
110 void stopCalibration(const ::Ice::Current& c = Ice::emptyCurrent) override;
111 visionx::KinectPoseCalibration
112 getCalibrationParameters(const ::Ice::Current& c = Ice::emptyCurrent) override;
113
114
115 protected:
116 // inherited from VisionComponent
117 void onInitImageProcessor() override;
118 void onConnectImageProcessor() override;
119 void onExitImageProcessor() override;
120
121 void process() override;
122
123 /**
124 * @see PropertyUser::createPropertyDefinitions()
125 */
132
133 private:
134 std::string cameraImageProviderName, kinectImageProviderName;
135 ImageProviderInterfacePrx cameraImageProviderPrx, kinectImageProviderPrx;
136 CvCalibFilter* m_pCalibFilter;
137
138 CByteImage **cameraImages, **kinectImages;
139 int waitingIntervalBetweenImages, desiredNumberOfImages, numberOfCapturedImages;
140 double etalonParams[3];
141
142 std::string m_sCameraParameterFileName;
143
144 IceUtil::Time startingTime, timeOfLastCapture;
145 bool finished;
146
147 bool requested;
148 KinectPoseCalibration result;
149 KinectAndCameraCalibrationListenerPrx listenerPrx;
150 };
151
152} // namespace visionx
constexpr T c
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
ImageProcessorPropertyDefinitions(std::string prefix)
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
KinectAndCameraCalibration executes the calibration for the left camera of the stereo and kinect rgb ...
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
void onExitImageProcessor() override
Exit the ImapeProcessor component.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void process() override
Process the vision component.
void startCalibration(const ::Ice::Current &c=Ice::emptyCurrent) override
ice related functions (todo: put comments)
void stopCalibration(const ::Ice::Current &c=Ice::emptyCurrent) override
void onInitImageProcessor() override
Setup the vision component.
visionx::KinectPoseCalibration getCalibrationParameters(const ::Ice::Current &c=Ice::emptyCurrent) override
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.