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