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 
26 #include <mutex>
27 #include <queue>
28 
29 #include <opencv2/opencv.hpp>
30 
32 
34 #include <VisionX/interface/components/OpenCVImageStabilizerInterface.h>
36 
37 #include <Image/IplImageAdaptor.h>
38 
39 namespace armarx
40 {
41  /**
42  * @class OpenCVImageStabilizerPropertyDefinitions
43  * @brief
44  */
47  {
48  public:
51  {
52  //defineRequiredProperty<std::string>("PropertyName", "Description");
53  //defineOptionalProperty<std::string>("PropertyName", "DefaultValue", "Description");
54 
55  defineOptionalProperty<float>("Framerate", 30.0, "the framerate");
56  defineOptionalProperty<std::string>(
57  "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
82  getDefaultName() const override
83  {
84  return "OpenCVImageStabilizer";
85  }
86 
87  protected:
88  /**
89  * @see PropertyUser::createPropertyDefinitions()
90  */
92 
93  // ImageProcessor interface
94  protected:
95  void onInitImageProcessor() override;
96  void onConnectImageProcessor() override;
97  void onExitImageProcessor() override;
98  void process() override;
99 
100  private:
101  visionx::ImageProviderInterfacePrx imageProviderPrx;
102  CByteImage** cameraImages;
103 
104  cv::Mat prev, prevGrey, prevTransform;
105  std::vector<cv::Point2f> prevFeatures;
106  std::vector<cv::Vec3d> deltaTransformations, smoothedTrajectory;
107  std::queue<cv::Mat> oldImages;
108 
109  std::mutex imageMutex;
110 
111  std::string providerName;
112  float frameRate;
113  bool drawFeatures;
114 
115  // OpenCVImageStabilizerInterface interface
116  public:
117  void resetOpenCVStabilization(const Ice::Current&) override;
118  };
119 } // namespace armarx
armarx::OpenCVImageStabilizerPropertyDefinitions::OpenCVImageStabilizerPropertyDefinitions
OpenCVImageStabilizerPropertyDefinitions(std::string prefix)
Definition: OpenCVImageStabilizer.h:49
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:98
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::OpenCVImageStabilizer::resetOpenCVStabilization
void resetOpenCVStabilization(const Ice::Current &) override
Definition: OpenCVImageStabilizer.cpp:245
visionx::ImageProcessorPropertyDefinitions::ImageProcessorPropertyDefinitions
ImageProcessorPropertyDefinitions(std::string prefix)
Definition: ImageProcessor.h:64
armarx::OpenCVImageStabilizer::onInitImageProcessor
void onInitImageProcessor() override
Setup the vision component.
Definition: OpenCVImageStabilizer.cpp:32
armarx::OpenCVImageStabilizer::getDefaultName
std::string getDefaultName() const override
Definition: OpenCVImageStabilizer.h:82
ImageProcessor.h
armarx::OpenCVImageStabilizer::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: OpenCVImageStabilizer.cpp:238
armarx::OpenCVImageStabilizerPropertyDefinitions
Definition: OpenCVImageStabilizer.h:45
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:42
armarx::OpenCVImageStabilizer::process
void process() override
Process the vision component.
Definition: OpenCVImageStabilizer.cpp:75
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:59
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27