CalibrationCreator.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 
35 // IVT
36 #include "calibfilter.h"
37 #include <Math/Math2d.h>
38 #include <Math/Math3d.h>
39 
40 
41 class CvCalibFilter;
42 class CByteImage;
43 
44 namespace visionx
45 {
46 
48  {
49  public:
52  {
53  defineOptionalProperty<std::string>("ImageProviderAdapterName",
54  "ImageProvider",
55  "Ice Adapter name of the image provider");
56  defineOptionalProperty<int>(
57  "NumberOfImages", 20, "Number of images used for the calibration");
58  defineOptionalProperty<int>(
59  "WaitingIntervalBetweenImages", 500, "Waiting time between captured images, in ms");
60  defineOptionalProperty<int>(
61  "NumberOfRows", 5, "Number of rows on the calibration pattern");
62  defineOptionalProperty<int>(
63  "NumberOfColumns", 5, "Number of columns on the calibration pattern");
64  defineOptionalProperty<double>(
65  "PatternSquareSize", 30.0, "Size of the squares on the calibration pattern");
66  defineOptionalProperty<std::string>(
67  "OutputFileName", "cameras.txt", "Path to the file for saving the calibration");
68  }
69  };
70 
71  /**
72  * CalibrationCreator determines if the robot hand is colliding with another object, causing it to move.
73  * To this end, it localizes the robot hand using the marker ball and the finger tips, calculates the optical
74  * flow in the image, clusters it, and looks for a cluster that exist solely in front of the hand.
75  *
76  * \componentproperties
77  * \prop VisionX.CalibrationCreator.ImageProviderAdapterName: Name of the
78  * image provider that delivers the camera images.
79  * \prop VisionX.CalibrationCreator.RobotStateProxyName: Name of the robot state
80  * proxy used to obtain the current robot state.
81  * \prop VisionX.CalibrationCreator.HandFrameName: Name of the frame in the robot
82  * model that corresponds to the localized hand.
83  * \prop VisionX.CalibrationCreator.CameraFrameName: Name of the robot state frame of the primary camera
84  */
86  {
87  public:
88  /**
89  * @see Component::getDefaultName()
90  */
91  std::string
92  getDefaultName() const override
93  {
94  return "CalibrationCreator";
95  }
96 
97 
98  protected:
99  // inherited from VisionComponent
100  void onInitImageProcessor() override;
101  void onConnectImageProcessor() override;
102  void onExitImageProcessor() override;
103 
104  void process() override;
105 
106  /**
107  * @see PropertyUser::createPropertyDefinitions()
108  */
111  {
114  }
115 
116  private:
117  std::string providerName;
118  ImageProviderInterfacePrx imageProviderPrx;
119  CvCalibFilter* m_pCalibFilter;
120  CvPoint2D32f* m_pCorners2DFloat;
121  CvPoint2D64f* m_pCorners2D;
122  CvPoint3D64f* m_pCorners3D;
123 
124  CByteImage** cameraImages;
125  int waitingIntervalBetweenImages, desiredNumberOfImages, numberOfCapturedImages;
126  std::string m_sCameraParameterFileName;
127 
128  IceUtil::Time startingTime, timeOfLastCapture;
129  bool finished;
130  };
131 
132 } // namespace visionx
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::CalibrationCreator::onConnectImageProcessor
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
Definition: CalibrationCreator.cpp:74
visionx::ImageProcessor
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
Definition: ImageProcessor.h:98
visionx::CalibrationCreator::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: CalibrationCreator.h:110
visionx::CalibrationCreator::process
void process() override
Process the vision component.
Definition: CalibrationCreator.cpp:109
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
visionx::CalibrationCreator
CalibrationCreator determines if the robot hand is colliding with another object, causing it to move.
Definition: CalibrationCreator.h:85
ImageProcessor.h
calibfilter.h
visionx::CalibrationCreator::onExitImageProcessor
void onExitImageProcessor() override
Exit the ImapeProcessor component.
Definition: CalibrationCreator.cpp:95
visionx::CalibrationCreatorPropertyDefinitions::CalibrationCreatorPropertyDefinitions
CalibrationCreatorPropertyDefinitions(std::string prefix)
Definition: CalibrationCreator.h:50
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:79
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::ImageProcessorPropertyDefinitions
Definition: ImageProcessor.h:61
visionx::CalibrationCreator::onInitImageProcessor
void onInitImageProcessor() override
Setup the vision component.
Definition: CalibrationCreator.cpp:42
visionx::CalibrationCreator::getDefaultName
std::string getDefaultName() const override
Definition: CalibrationCreator.h:92
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
CvCalibFilter
Definition: calibfilter.h:75
visionx::CalibrationCreatorPropertyDefinitions
Definition: CalibrationCreator.h:47