ImageSequenceProvider.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 Jan Issac (jan dot issac at gmx dot net)
20 * @date 2011
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
28#include <VisionX/interface/components/Calibration.h>
29
30
31// IVT
32#include <mutex>
33#include <string>
34
35#include <Calibration/StereoCalibration.h>
36#include <Image/ByteImage.h>
37#include <VideoCapture/BitmapSequenceCapture.h>
38
39namespace visionx
40{
42 {
43 public:
46 {
48 "PathLeft",
49 "Filename and path of the left camera images. Enter the path of the first image of "
50 "the sequence. Filenames need to follow the format: path/*%d.bmp (e.g. "
51 "path/image_left0000.bmp).");
53 "PathRight",
54 "",
55 "Filename and path of the right camera images. Enter the path of the first image "
56 "of the sequence. Filenames need to follow the format: path/*%d.bmp (e.g. "
57 "path/image_right0000.bmp).");
58 defineOptionalProperty<float>("FrameRate", 30.0f, "Frames per second")
59 .setMatchRegex("\\d+(.\\d*)?")
60 .setMin(0.0f)
61 .setMax(60.0f);
63 "ImageSize",
64 ImageDimension(640, 480),
65 "Target resolution of the images. Loaded images will be converted to this size.")
66 .setCaseInsensitive(true)
67 .map("320x240", ImageDimension(320, 240))
68 .map("640x480", ImageDimension(640, 480))
69 .map("648x482", ImageDimension(648, 482))
70 .map("800x600", ImageDimension(800, 600))
71 .map("768x576", ImageDimension(768, 576))
72 .map("1024x768", ImageDimension(1024, 768))
73 .map("1024x1024", ImageDimension(1024, 1024))
74 .map("1280x960", ImageDimension(1280, 960))
75 .map("1600x1200", ImageDimension(1600, 1200))
76 .map("none", ImageDimension(0, 0));
77
79 "CalibrationFile",
80 "",
81 "Camera calibration file, will be made available in the SLICE interface");
83 "ImagesAreUndistorted", false, "Sets whether images are provided undistorted.");
85 "LoadNextImageAutomatically",
86 true,
87 "If true, a new image is loaded everytime the 'capture()' function is executed. If "
88 "false, the same image is provided until 'loadNextImage()' is called from "
89 "somewhere");
91 "RepeatImageCount", 1, "Repeats the images for the specified amount of time.");
92
94 "ReferenceFrameName", "EyeLeftCamera", "Optional reference frame name.");
95 }
96 };
97
98 /**
99 * Image sequence provider loads images from a device and broadcasts
100 * notifications after loading at a specified frame rate.
101 *
102 * It supports the following image transmission formats:
103 *
104 * - RGB
105 * - Gray Scale
106 *
107 * \componentproperties
108 * \prop VisionX.ImageSequenceProvider.PathLeft: Image directory of the left
109 * (base) camera.
110 * \prop VisionX.ImageSequenceProvider.PathRight: Image directory of the
111 * right camera. Leave this empty if stereo is not required.
112 */
114 virtual public CapturingImageProvider,
115 virtual public ImageFileSequenceProviderInterface
116 {
117 public:
118 std::string
119 getDefaultName() const override
120 {
121 return "ImageSequenceProvider";
122 }
123
124 /**
125 * Returns the StereoCalibration as provided in configuration
126 *
127 * @return visionx::StereoCalibration
128 */
129 visionx::StereoCalibration
130 getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override;
131
132 /**
133 * Returns whether images are undistorted
134 *
135 * @return bool
136 */
137 bool getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override;
138
139 std::string
140 getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
141 {
142 return getProperty<std::string>("ReferenceFrameName").getValue();
143 }
144
145 /**
146 * Set the paths for the image files. If there are no stereo images, leave the right path empty
147 *
148 */
149 void setImageFilePath(const std::string& imageFilePathLeft,
150 const std::string& imageFilePathRight = "",
151 const Ice::Current& c = Ice::emptyCurrent) override;
152
153 void loadNextImage(const Ice::Current& c = Ice::emptyCurrent) override;
154
155
156 protected:
157 /**
158 * @see visionx::CapturingImageProvider::onInitCapturingImageProvider()
159 */
160 void onInitCapturingImageProvider() override;
161
162 /**
163 * @see visionx::CapturingImageProvider::onExitCapturingImageProvider()
164 */
165 void onExitCapturingImageProvider() override;
166
167 /**
168 * @see visionx::CapturingImageProvider::onStartCapture(float frameRate)
169 */
170 void onStartCapture(float frameRate) override;
171
172 /**
173 * @see visionx::CapturingImageProvider::onStopCapture()
174 */
175 void onStopCapture() override;
176
177 bool capture(void** ppImageBuffers) override;
178
179
180 void OpenImageFiles();
181
182 /**
183 * @see PropertyUser::createPropertyDefinitions()
184 */
191
192 CByteImage** images;
193 CByteImage** resizedImages;
194 CBitmapSequenceCapture* bitmapSequenceCapture;
195 std::string filePathLeft;
196 std::string filePathRight;
197 std::mutex captureMutex;
199
200 private:
201 /**
202 * IVT Stereo Calibration object
203 */
204 CStereoCalibration ivtStereoCalibration;
205
206 /**
207 * VisionX StereoCalibration object
208 */
209 StereoCalibration stereoCalibration;
210
211 int currentRepeatCount = 0;
212 int repeatImageCount;
213 };
214
215} // namespace visionx
constexpr T c
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
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)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
The CapturingImageProvider provides a callback function to trigger the capturing of images with diffe...
Image sequence provider loads images from a device and broadcasts notifications after loading at a sp...
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
void loadNextImage(const Ice::Current &c=Ice::emptyCurrent) override
CBitmapSequenceCapture * bitmapSequenceCapture
void setImageFilePath(const std::string &imageFilePathLeft, const std::string &imageFilePathRight="", const Ice::Current &c=Ice::emptyCurrent) override
Set the paths for the image files.
void onStartCapture(float frameRate) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
Returns whether images are undistorted.
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
Returns the StereoCalibration as provided in configuration.
std::string getDefaultName() const override
Retrieve default name of component.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
ArmarX headers.