OpenCVImageStabilizer.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package VisionX::ArmarXObjects::OpenCVImageStabilizer
17  * @author David Sippel ( uddoe at student dot kit dot edu )
18  * @date 2017
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 
27 
30 
31 #include <VisionX/interface/components/OpenCVImageStabilizerInterface.h>
32 
33 #include <Image/IplImageAdaptor.h>
34 
35 #include <opencv2/opencv.hpp>
36 
37 #include <queue>
38 #include <mutex>
39 
40 namespace armarx
41 {
42  /**
43  * @class OpenCVImageStabilizerPropertyDefinitions
44  * @brief
45  */
48  {
49  public:
52  {
53  //defineRequiredProperty<std::string>("PropertyName", "Description");
54  //defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
55 
56  defineOptionalProperty<float>("Framerate", 30.0, "the framerate");
57  defineOptionalProperty<std::string>("providerName", "Armar3WideImageProvider", "ImageProvider name");
58  defineOptionalProperty<bool>("drawFeatures", false, "Draw the detected features");
59  }
60  };
61 
62  /**
63  * @defgroup Component-OpenCVImageStabilizer OpenCVImageStabilizer
64  * @ingroup VisionX-Components
65  * A description of the component OpenCVImageStabilizer.
66  *
67  * @class OpenCVImageStabilizer
68  * @ingroup Component-OpenCVImageStabilizer
69  * @brief Brief description of class OpenCVImageStabilizer.
70  *
71  * Detailed description of class OpenCVImageStabilizer.
72  */
74  virtual public visionx::ImageProcessor,
75  virtual public OpenCVImageStabilizerInterface
76  {
77  public:
78  /**
79  * @see armarx::ManagedIceObject::getDefaultName()
80  */
81  std::string getDefaultName() const override
82  {
83  return "OpenCVImageStabilizer";
84  }
85 
86  protected:
87  /**
88  * @see PropertyUser::createPropertyDefinitions()
89  */
91 
92  // ImageProcessor interface
93  protected:
94  void onInitImageProcessor() override;
95  void onConnectImageProcessor() override;
96  void onExitImageProcessor() override;
97  void process() override;
98 
99  private:
100  visionx::ImageProviderInterfacePrx imageProviderPrx;
101  CByteImage** cameraImages;
102 
103  cv::Mat prev, prevGrey, prevTransform;
104  std::vector< cv::Point2f > prevFeatures;
105  std::vector< cv::Vec3d > deltaTransformations, smoothedTrajectory;
106  std::queue< cv::Mat > oldImages;
107 
108  std::mutex imageMutex;
109 
110  std::string providerName;
111  float frameRate;
112  bool drawFeatures;
113 
114  // OpenCVImageStabilizerInterface interface
115  public:
116  void resetOpenCVStabilization(const Ice::Current&) override;
117  };
118 }
119 
armarx::OpenCVImageStabilizerPropertyDefinitions::OpenCVImageStabilizerPropertyDefinitions
OpenCVImageStabilizerPropertyDefinitions(std::string prefix)
Definition: OpenCVImageStabilizer.h:50
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::ImageProcessor
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
Definition: ImageProcessor.h:87
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::OpenCVImageStabilizer::resetOpenCVStabilization
void resetOpenCVStabilization(const Ice::Current &) override
Definition: OpenCVImageStabilizer.cpp:222
visionx::ImageProcessorPropertyDefinitions::ImageProcessorPropertyDefinitions
ImageProcessorPropertyDefinitions(std::string prefix)
Definition: ImageProcessor.h:65
armarx::OpenCVImageStabilizer::onInitImageProcessor
void onInitImageProcessor() override
Setup the vision component.
Definition: OpenCVImageStabilizer.cpp:30
armarx::OpenCVImageStabilizer::getDefaultName
std::string getDefaultName() const override
Definition: OpenCVImageStabilizer.h:81
ImageProcessor.h
armarx::OpenCVImageStabilizer::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: OpenCVImageStabilizer.cpp:215
armarx::OpenCVImageStabilizerPropertyDefinitions
Definition: OpenCVImageStabilizer.h:46
armarx::OpenCVImageStabilizer
Brief description of class OpenCVImageStabilizer.
Definition: OpenCVImageStabilizer.h:73
Component.h
armarx::OpenCVImageStabilizer::onConnectImageProcessor
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
Definition: OpenCVImageStabilizer.cpp:39
armarx::OpenCVImageStabilizer::process
void process() override
Process the vision component.
Definition: OpenCVImageStabilizer.cpp:70
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::ImageProcessorPropertyDefinitions
Definition: ImageProcessor.h:61
ImageUtil.h
armarx::OpenCVImageStabilizer::onExitImageProcessor
void onExitImageProcessor() override
Exit the ImapeProcessor component.
Definition: OpenCVImageStabilizer.cpp:55
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28