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
39namespace 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");
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 static std::string
83 {
84 return "OpenCVImageStabilizer";
85 }
86
87 std::string
88 getDefaultName() const override
89 {
90 return GetDefaultName();
91 }
92
93 protected:
94 /**
95 * @see PropertyUser::createPropertyDefinitions()
96 */
98
99 // ImageProcessor interface
100 protected:
101 void onInitImageProcessor() override;
102 void onConnectImageProcessor() override;
103 void onExitImageProcessor() override;
104 void process() override;
105
106 private:
107 visionx::ImageProviderInterfacePrx imageProviderPrx;
108 CByteImage** cameraImages;
109
110 cv::Mat prev, prevGrey, prevTransform;
111 std::vector<cv::Point2f> prevFeatures;
112 std::vector<cv::Vec3d> deltaTransformations, smoothedTrajectory;
113 std::queue<cv::Mat> oldImages;
114
115 std::mutex imageMutex;
116
117 std::string providerName;
118 float frameRate;
119 bool drawFeatures;
120
121 // OpenCVImageStabilizerInterface interface
122 public:
123 void resetOpenCVStabilization(const Ice::Current&) override;
124 };
125} // namespace armarx
Brief description of class OpenCVImageStabilizer.
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 onInitImageProcessor() override
Setup the vision component.
void resetOpenCVStabilization(const Ice::Current &) override
std::string getDefaultName() const override
Retrieve default name of component.
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...
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.