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 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
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
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.